mirror of
https://github.com/ziglang/zig.git
synced 2026-01-17 21:05:12 +00:00
autdoc: install artifacts
This commit is contained in:
parent
2dcaed743f
commit
9ad9664ea8
@ -5,9 +5,9 @@ const Module = @import("Module.zig");
|
||||
const Zir = @import("Zir.zig");
|
||||
|
||||
module: *Module,
|
||||
doc_location: ?Compilation.EmitLoc,
|
||||
doc_location: Compilation.EmitLoc,
|
||||
|
||||
pub fn init(m: *Module, dl: ?Compilation.EmitLoc) Autodoc {
|
||||
pub fn init(m: *Module, dl: Compilation.EmitLoc) Autodoc {
|
||||
return .{
|
||||
.doc_location = dl,
|
||||
.module = m,
|
||||
@ -17,14 +17,12 @@ pub fn init(m: *Module, dl: ?Compilation.EmitLoc) Autodoc {
|
||||
pub fn generateZirData(self: Autodoc) !void {
|
||||
const gpa = self.module.gpa;
|
||||
std.debug.print("yay, you called me!\n", .{});
|
||||
if (self.doc_location) |loc| {
|
||||
if (loc.directory) |dir| {
|
||||
if (dir.path) |path| {
|
||||
std.debug.print("path: {s}\n", .{path});
|
||||
}
|
||||
if (self.doc_location.directory) |dir| {
|
||||
if (dir.path) |path| {
|
||||
std.debug.print("path: {s}\n", .{path});
|
||||
}
|
||||
std.debug.print("basename: {s}\n", .{loc.basename});
|
||||
}
|
||||
std.debug.print("basename: {s}\n", .{self.doc_location.basename});
|
||||
|
||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||
const dir =
|
||||
@ -74,7 +72,23 @@ pub fn generateZirData(self: Autodoc) !void {
|
||||
|
||||
data.packages[0].main = main_type_index.type;
|
||||
|
||||
const out = std.io.getStdOut().writer();
|
||||
if (self.doc_location.directory) |d|
|
||||
(d.handle.makeDir(self.doc_location.basename) catch |e| switch (e) {
|
||||
error.PathAlreadyExists => {},
|
||||
else => unreachable,
|
||||
})
|
||||
else
|
||||
(self.module.zig_cache_artifact_directory.handle.makeDir(self.doc_location.basename) catch |e| switch (e) {
|
||||
error.PathAlreadyExists => {},
|
||||
else => unreachable,
|
||||
});
|
||||
const output_dir = if (self.doc_location.directory) |d|
|
||||
(d.handle.openDir(self.doc_location.basename, .{}) catch unreachable)
|
||||
else
|
||||
(self.module.zig_cache_artifact_directory.handle.openDir(self.doc_location.basename, .{}) catch unreachable);
|
||||
const data_js_f = output_dir.createFile("data.js", .{}) catch unreachable;
|
||||
defer data_js_f.close();
|
||||
const out = data_js_f.writer();
|
||||
out.print("zigAnalysis=", .{}) catch unreachable;
|
||||
std.json.stringify(
|
||||
data,
|
||||
@ -85,6 +99,12 @@ pub fn generateZirData(self: Autodoc) !void {
|
||||
out,
|
||||
) catch unreachable;
|
||||
out.print(";", .{}) catch unreachable;
|
||||
// copy main.js, index.html
|
||||
const special = try self.module.comp.zig_lib_directory.join(gpa, &.{ "std", "special", "docs", std.fs.path.sep_str });
|
||||
var special_dir = std.fs.openDirAbsolute(special, .{}) catch unreachable;
|
||||
defer special_dir.close();
|
||||
special_dir.copyFile("main.js", output_dir, "main.js", .{}) catch unreachable;
|
||||
special_dir.copyFile("index.html", output_dir, "index.html", .{}) catch unreachable;
|
||||
}
|
||||
|
||||
const Scope = struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user