diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-03-28 02:17:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-28 02:17:50 -0700 |
| commit | 17053887d080bd125d2f5ccbb39238f23c706328 (patch) | |
| tree | 97ed7faba6053f50b668cd76bbfc5bbe5ebbbc89 /src/Compilation.zig | |
| parent | 9dac8db2df2332d6dd4aa52a0b524e5c88a9349b (diff) | |
| parent | 3fb6bb144998de72d03b58e7c1daf134e2438373 (diff) | |
| download | zig-17053887d080bd125d2f5ccbb39238f23c706328.tar.gz zig-17053887d080bd125d2f5ccbb39238f23c706328.zip | |
Merge pull request #19458 from ianprime0509/all-module-docs
Autodoc: include all modules in output
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 5bbca51ede..460a1e5d9e 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3693,6 +3693,9 @@ fn workerDocsCopy(comp: *Compilation, wg: *WaitGroup) void { } fn docsCopyFallible(comp: *Compilation) anyerror!void { + const zcu = comp.module orelse + return comp.lockAndSetMiscFailure(.docs_copy, "no Zig code to document", .{}); + const emit = comp.docs_emit.?; var out_dir = emit.directory.handle.makeOpenPath(emit.sub_path, .{}) catch |err| { return comp.lockAndSetMiscFailure( @@ -3723,7 +3726,25 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void { }; defer tar_file.close(); - const root = comp.root_mod.root; + var seen_table: std.AutoArrayHashMapUnmanaged(*Package.Module, void) = .{}; + defer seen_table.deinit(comp.gpa); + + try seen_table.put(comp.gpa, zcu.main_mod, {}); + try seen_table.put(comp.gpa, zcu.std_mod, {}); + + var i: usize = 0; + while (i < seen_table.count()) : (i += 1) { + const mod = seen_table.keys()[i]; + try comp.docsCopyModule(mod, tar_file); + + const deps = mod.deps.values(); + try seen_table.ensureUnusedCapacity(comp.gpa, deps.len); + for (deps) |dep| seen_table.putAssumeCapacity(dep, {}); + } +} + +fn docsCopyModule(comp: *Compilation, module: *Package.Module, tar_file: std.fs.File) !void { + const root = module.root; const sub_path = if (root.sub_path.len == 0) "." else root.sub_path; var mod_dir = root.root_dir.handle.openDir(sub_path, .{ .iterate = true }) catch |err| { return comp.lockAndSetMiscFailure(.docs_copy, "unable to open directory '{}': {s}", .{ @@ -3762,7 +3783,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void { var file_header = std.tar.output.Header.init(); file_header.typeflag = .regular; - try file_header.setPath(comp.root_name, entry.path); + try file_header.setPath(module.fully_qualified_name, entry.path); try file_header.setSize(stat.size); try file_header.updateChecksum(); |
