Skip to content

Commit 53e9712

Browse files
committed
autodoc: minor pr cleanup
1 parent 51a4861 commit 53e9712

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

lib/docs/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var zigAnalysis;
5151
const domHdrName = document.getElementById("hdrName");
5252
const domHelpModal = document.getElementById("helpModal");
5353
const domSearchPlaceholder = document.getElementById("searchPlaceholder");
54-
const sourceFileUrlTemplate = "src-viewer/{{file}}#L{{line}}"
54+
const sourceFileUrlTemplate = "src/{{file}}#L{{line}}"
5555
const domLangRefLink = document.getElementById("langRefLink");
5656

5757
let lineCounter = 1;
@@ -989,7 +989,7 @@ var zigAnalysis;
989989
"switch(" +
990990
cond +
991991
") {" +
992-
'<a href="/src-viewer/' +
992+
'<a href="/src/' +
993993
file_name +
994994
"#L" +
995995
line +

src/Autodoc.zig

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Package = @import("Package.zig");
99
const Zir = @import("Zir.zig");
1010
const Ref = Zir.Inst.Ref;
1111
const log = std.log.scoped(.autodoc);
12-
const Docgen = @import("Docgen.zig");
12+
const Docgen = @import("autodoc/render_source.zig");
1313

1414
module: *Module,
1515
doc_location: Compilation.EmitLoc,
@@ -243,6 +243,7 @@ pub fn generateZirData(self: *Autodoc) !void {
243243
try d.handle.openDir(self.doc_location.basename, .{})
244244
else
245245
try self.module.zig_cache_artifact_directory.handle.openDir(self.doc_location.basename, .{});
246+
246247
{
247248
const data_js_f = try output_dir.createFile("data.js", .{});
248249
defer data_js_f.close();
@@ -267,25 +268,27 @@ pub fn generateZirData(self: *Autodoc) !void {
267268
try buffer.flush();
268269
}
269270

270-
output_dir.makeDir("src-viewer") catch |e| switch (e) {
271-
error.PathAlreadyExists => {},
272-
else => |err| return err,
273-
};
274-
const html_dir = try output_dir.openDir("src-viewer", .{});
271+
{
272+
output_dir.makeDir("src") catch |e| switch (e) {
273+
error.PathAlreadyExists => {},
274+
else => |err| return err,
275+
};
276+
const html_dir = try output_dir.openDir("src", .{});
275277

276-
var files_iterator = self.files.iterator();
278+
var files_iterator = self.files.iterator();
277279

278-
while (files_iterator.next()) |entry| {
279-
const new_html_path = entry.key_ptr.*.sub_file_path;
280+
while (files_iterator.next()) |entry| {
281+
const new_html_path = entry.key_ptr.*.sub_file_path;
280282

281-
const html_file = try createFromPath(html_dir, new_html_path);
282-
defer html_file.close();
283-
var buffer = std.io.bufferedWriter(html_file.writer());
283+
const html_file = try createFromPath(html_dir, new_html_path);
284+
defer html_file.close();
285+
var buffer = std.io.bufferedWriter(html_file.writer());
284286

285-
const out = buffer.writer();
287+
const out = buffer.writer();
286288

287-
try Docgen.genHtml(self.module.gpa, entry.key_ptr.*, out);
288-
try buffer.flush();
289+
try Docgen.genHtml(self.module.gpa, entry.key_ptr.*, out);
290+
try buffer.flush();
291+
}
289292
}
290293

291294
// copy main.js, index.html

src/Docgen.zig renamed to src/autodoc/render_source.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const print = std.debug.print;
99
const mem = std.mem;
1010
const testing = std.testing;
1111
const Allocator = std.mem.Allocator;
12-
const Module = @import("Module.zig");
12+
const Module = @import("../Module.zig");
1313

1414
pub fn genHtml(
1515
allocator: Allocator,
@@ -33,7 +33,6 @@ pub fn genHtml(
3333
\\ line-height: 1.5;
3434
\\ }
3535
\\
36-
\\ @media screen and (min-width: 1025px) {
3736
\\ pre > code {
3837
\\ display: block;
3938
\\ overflow: auto;

0 commit comments

Comments
 (0)