Add autodoc website
This adds a `zig build docs` step that builds the documentation website and writes it to zig-out/docs. It further includes a GitHub Workflow that publishes this website to GitHub Pages. The GitHub Workflow is divided into two jobs: - build: builds the documentation and uploads it - publish: downloads the documentation and publishes it These are separate jobs to minimize permissions available to the build job. This workflow runs on two events: - after every push to master - `workflow_dispatch`: this allows manually running the workflow from its *Actions* page if something went wrong --- **Important pre-merge steps:** If this PR is accepted, the following steps should be taken before merging the PR: 1. Go to **Settings** for the repository 2. Select **Pages** on the left under *Code and automation* 3. Under *Build and deployment* set **Source** to **GitHub Actions** 4. Merge the PR. If the steps are missed, the PR will merge just fine, but the docs job will fail immediately on merge. This can be remedied by following steps 1-3 above, and either adding a new commit on master, or manually firing the workflow from the Actions > API Reference page.
This commit is contained in:
parent
cf3a4e7638
commit
7af04ee30d
47
.github/workflows/docs.yml
vendored
Normal file
47
.github/workflows/docs.yml
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
name: API Reference
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
# Allow manually starting the workflow.
|
||||
workflow_dispatch:
|
||||
|
||||
# If two concurrent runs are started,
|
||||
# prefer the latest one.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build website
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: goto-bus-stop/setup-zig@v2.0.1
|
||||
with:
|
||||
version: master
|
||||
- name: Build
|
||||
run: zig build docs
|
||||
- name: Upload
|
||||
uses: actions/upload-pages-artifact@v2
|
||||
with:
|
||||
path: "zig-out/docs/"
|
||||
|
||||
publish:
|
||||
name: Publish website
|
||||
runs-on: ubuntu-latest
|
||||
needs: build # wait for build to finish
|
||||
permissions:
|
||||
# Request sufficient permissions to publish the website.
|
||||
pages: write
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v3
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
|
@ -23,6 +23,12 @@ in the release notes.
|
|||
* Print help message from parameter specification.
|
||||
* Parse help message to parameter specification.
|
||||
|
||||
## API Reference
|
||||
|
||||
Automatically generated API Reference for the project
|
||||
can be found at https://Hejsil.github.io/zig-clap.
|
||||
Note that Zig autodoc is in beta; the website may be broken or incomplete.
|
||||
|
||||
## Examples
|
||||
|
||||
### `clap.parse`
|
||||
|
|
|
@ -35,6 +35,14 @@ pub fn build(b: *std.Build) void {
|
|||
example_step.dependOn(&install_example.step);
|
||||
}
|
||||
|
||||
const docs_step = b.step("docs", "Generate docs.");
|
||||
const install_docs = b.addInstallDirectory(.{
|
||||
.source_dir = tests.getEmittedDocs(),
|
||||
.install_dir = .prefix,
|
||||
.install_subdir = "docs",
|
||||
});
|
||||
docs_step.dependOn(&install_docs.step);
|
||||
|
||||
const readme_step = b.step("readme", "Remake README.");
|
||||
const readme = readMeStep(b);
|
||||
readme.dependOn(example_step);
|
||||
|
|
Loading…
Reference in New Issue
Block a user