Skip to content

Add a step to generate documentation to build.zig which zig init generates #22644

@sorairolake

Description

@sorairolake

Zig can generate documentation from doc comments.

For the library package, I think it would be useful to have a step in zig build to generate documentation. But there is no such step for build.zig which zig init generates.

So I think it would be useful to have a step like the following in build.zig which zig init generates:

zig/build.zig

Lines 51 to 68 in bf6ee7c

const autodoc_test = b.addObject(.{
.name = "std",
.zig_lib_dir = b.path("lib"),
.root_module = b.createModule(.{
.root_source_file = b.path("lib/std/std.zig"),
.target = target,
.optimize = .Debug,
}),
});
const install_std_docs = b.addInstallDirectory(.{
.source_dir = autodoc_test.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "doc/std",
});
//if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
if (std_docs) {
b.getInstallStep().dependOn(&install_std_docs.step);
}

For those unfamiliar with the Zig build system, I think it is easier to edit a template rather than writing such a step from scratch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions