Skip to content

Commit 0b13df3

Browse files
committed
WIP
1 parent bdd3dcf commit 0b13df3

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

build.zig

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,26 @@ pub fn build(b: *std.Build) void {
1616
});
1717
b.installArtifact(lib);
1818

19-
const lib_module = b.createModule(.{
20-
.root_source_file = lib_source,
19+
const lib_module = lib.root_module;
20+
21+
// --- Docs Setup ---
22+
const docs_step = b.step("docs", "Generate API documentation");
23+
const doc_install_path = "docs/api";
24+
25+
const gen_docs_cmd = b.addSystemCommand(&[_][]const u8{
26+
b.graph.zig_exe,
27+
"build-lib",
28+
"src/lib.zig",
29+
"-femit-docs=" ++ doc_install_path,
2130
});
2231

32+
const mkdir_cmd = b.addSystemCommand(&[_][]const u8{
33+
"mkdir", "-p", doc_install_path,
34+
});
35+
gen_docs_cmd.step.dependOn(&mkdir_cmd.step);
36+
37+
docs_step.dependOn(&gen_docs_cmd.step);
38+
2339
// --- Test Setup ---
2440
const lib_unit_tests = b.addTest(.{
2541
.root_source_file = lib_source,
@@ -33,7 +49,10 @@ pub fn build(b: *std.Build) void {
3349

3450
// --- Example Setup ---
3551
const examples_path = "examples";
36-
var examples_dir = fs.cwd().openDir(examples_path, .{ .iterate = true }) catch @panic("Can't open 'examples' directory");
52+
var examples_dir = fs.cwd().openDir(examples_path, .{ .iterate = true }) catch |err| {
53+
if (err == error.FileNotFound) return;
54+
@panic("Can't open 'examples' directory");
55+
};
3756
defer examples_dir.close();
3857

3958
var dir_iter = examples_dir.iterate();

0 commit comments

Comments
 (0)