scdoc – Zig package


I made a tiny wrapper for Drew DeVault’s scdoc, a simple man page generator for POSIX systems.

The wrapper uses zig cc to build scdoc from the original C sources, while providing convenience functions when used as a dependency for Zig projects. If you use the built-in options function, it can also provide a set of standardized build options, as well as a Zig system integration (-fsys=scdoc) for use by packagers.

I personally use it in ssx, a companion command for SSHFS.


It can be used like this:

zig fetch --save=scdoc git+https://codeberg.org/spiffyk/scdoc.zig.git
pub fn build(b: *std.Build) void {
    // ...

    const scdoc_mode: scdoc.Source = scdoc.options(b) orelse .vendored;

    // Add man page generation command
    const manpage = scdoc.generateManPage(
        b,
        scdoc_mode,
        b.path("my-command.1.scd"),
        "my-command.1",
    );
    b.getInstallStep().dependOn(
      &b.addInstallFile(manpage, "share/man/man1/my-command.1").step,
    );

    // Add convenience command to show the generated man page
    const man_step = b.step("man", "Show man page");
    man_step.dependOn(&scdoc.addRunMan(b, .{ .file = manpage }).step);

    // ...
}

const scdoc = @import("scdoc");
const std = @import("std");

Supported Zig versions

0.16.0

Link to the project

https://codeberg.org/spiffyk/scdoc.zig