@@ -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