From 7af04ee30d40e02e47bef4229bd823b541a0a352 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 21 Dec 2023 15:26:03 -0800 Subject: 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. --- build.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'build.zig') diff --git a/build.zig b/build.zig index bcf600e..ead9282 100644 --- a/build.zig +++ b/build.zig @@ -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); -- cgit v1.2.3