add api docs

This commit is contained in:
Daylin Morgan 2024-09-19 12:07:07 -05:00
parent dd8e0d563d
commit 308e323254
Signed by: daylin
GPG key ID: 950D13E9719334AD
3 changed files with 65 additions and 1 deletions

45
.github/workflows/docs.yml vendored Normal file
View file

@ -0,0 +1,45 @@
name: GitHub Pages
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v4
- uses: jiro4989/setup-nim-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docs
run: nim docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: ./public
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ tests/*
nimble.develop nimble.develop
nimble.paths nimble.paths
nimbledeps nimbledeps
public/

View file

@ -1,7 +1,25 @@
import std/[os, strformat, strutils]
task test, "run tests": task test, "run tests":
selfExec "r tests/tbbansi.nim" selfExec "r tests/tbbansi.nim"
task develop, "install cligen for development": task develop, "install cligen for development":
exec "nimble install -l 'cligen@1.7.5'" exec "nimble install -l 'cligen@1.7.5'"
task docs, "Deploy doc html + search index to public/ directory":
let
deployDir = getCurrentDir() / "public"
pkgName = "hwylterm"
srcFile = getCurrentDir() / fmt"src/{pkgName}.nim"
gitUrl = fmt"https://github.com/daylinmorgan/{pkgName}"
selfExec fmt"doc --index:on --git.url:{gitUrl} --git.commit:v{version} --outdir:{deployDir} --project {srcFile}"
withDir deployDir:
mvFile(pkgName & ".html", "index.html")
for file in walkDirRec(".", {pcFile}):
# As we renamed the file, we need to rename that in hyperlinks
exec(r"sed -i -r 's|$1\.html|index.html|g' $2" % [pkgName, file])
# drop 'src/' from titles
exec(r"sed -i -r 's/<(.*)>src\//<\1>/' $1" % file)
when withDir(thisDir(), system.dirExists("nimbledeps")):
--path:"./nimbledeps/pkgs2/cligen-1.7.5-f3ffe7329c8db755677d3ca377d02ff176cec8b1" --path:"./nimbledeps/pkgs2/cligen-1.7.5-f3ffe7329c8db755677d3ca377d02ff176cec8b1"