diff --git a/.build.yml b/.build.yml index 8903296..ae33198 100644 --- a/.build.yml +++ b/.build.yml @@ -1,11 +1,15 @@ image: alpine/edge packages: - git + - scdoc secrets: - 78f39fb6-1185-492f-9c21-f755e10b5e5d # ssh key for mirroring environment: GIT_SSH_COMMAND: ssh -o StrictHostKeyChecking=no tasks: + - docs: | + # Make sure there are no errors in the man page source + scdoc < ztags/ztags.1.scd >/dev/null - mirror: | # Don't run on GitHub PRs if [ "$BUILD_REASON" = 'github-pr' ]; then @@ -13,7 +17,4 @@ tasks: fi git clone --mirror https://git.sr.ht/~gpanders/ztags ztags.git - cd ztags.git - git push --force --mirror git@github.com:gpanders/ztags - cd .. - rm -rf ztags.git + git -C ztags.git push --force --mirror git@github.com:gpanders/ztags diff --git a/README.md b/README.md index c5d6a93..7b84593 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,20 @@ bit slow. To build a release build use $ zig build -Doptimize=ReleaseSafe ``` +To build the man page (requires [scdoc][]), run + +```console +$ zig build docs +``` + +This will install the man page to `man/man1/ztags.1` relative to the prefix +given with `-p`/`--prefix` (default `zig-out`). + The `master` branch tracks Zig `HEAD`. Use the `0.11.0` branch if using a stable release. +[scdoc]: https://sr.ht/~sircmpwn/scdoc/ + ## Usage Pass a source file to the `ztags` executable. `ztags` will find `@import` diff --git a/build.zig b/build.zig index b1782b0..e25df0d 100644 --- a/build.zig +++ b/build.zig @@ -32,4 +32,12 @@ pub fn build(b: *std.build.Builder) void { const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_unit_tests.step); + + const docs_cmd = b.addSystemCommand(&.{"scdoc"}); + docs_cmd.setStdIn(.{ .lazy_path = .{ .path = "ztags.1.scd" } }); + const docs_out = docs_cmd.captureStdOut(); + const docs = b.addInstallFileWithDir(docs_out, .{ .custom = b.pathJoin(&.{ "man", "man1" }) }, "ztags.1"); + + const docs_step = b.step("docs", "Build documentation"); + docs_step.dependOn(&docs.step); }