Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoff-it committed Aug 25, 2024
1 parent b25eb26 commit 2240f00
Show file tree
Hide file tree
Showing 32 changed files with 2,286 additions and 1,916 deletions.
41 changes: 33 additions & 8 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -339,20 +339,45 @@ fn defaultZineOptions(b: *std.Build, debug: bool) ZineOptions {

pub fn scriptyReferenceDocs(
project: *std.Build,
output_file_path: []const u8,
shtml_output_file_path: []const u8,
smd_output_file_path: []const u8,
) void {
const zine_dep = project.dependencyFromBuildZig(
zine,
.{ .optimize = .Debug },
);

const run_docgen = project.addRunArtifact(zine_dep.artifact("docgen"));
const reference_md = run_docgen.addOutputFileArg("scripty_reference.md");
const run_step = project.step(
"docgen",
"Regenerates Scripty reference docs",
);

{
const run_docgen = project.addRunArtifact(
zine_dep.artifact("shtml_docgen"),
);

const reference_md = run_docgen.addOutputFileArg(
"shtml_scripty_reference.md",
);

const wf = project.addWriteFiles();
wf.addCopyFileToSource(reference_md, shtml_output_file_path);

const wf = project.addWriteFiles();
wf.addCopyFileToSource(reference_md, output_file_path);
run_step.dependOn(&wf.step);
}
{
const run_docgen = project.addRunArtifact(
zine_dep.artifact("smd_docgen"),
);

const reference_md = run_docgen.addOutputFileArg(
"smd_scripty_reference.md",
);

const desc = project.fmt("Regenerates Scripty reference docs in '{s}'", .{output_file_path});
const run_step = project.step("docgen", desc);
run_step.dependOn(&wf.step);
const wf = project.addWriteFiles();
wf.addCopyFileToSource(reference_md, smd_output_file_path);

run_step.dependOn(&wf.step);
}
}
6 changes: 2 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
.path = "supermd",
},
.scripty = .{
.url = "git+https://github.com/kristoff-it/scripty#9ed452984a0d38eed3485bf2314553d5bffc17b0",
.hash = "122000048e34a01f4f57dcb17955df0a7c5bd57411c022916d8ea6f7e8c9c4a94c4d",
.path = "../scripty",
},
.superhtml = .{
.url = "git+https://github.com/kristoff-it/superhtml#5cdf5a1dd81801f052ebc99281f482c450cbf448",
.hash = "1220d57b3010d361f02335974779d5d89ad9e1eee314bed55bc8276f844b517d4a66",
.path = "../superhtml",
},
.ziggy = .{
.url = "git+https://github.com/kristoff-it/ziggy#c66f47bc632c66668d61fa06eda112b41d6e5130",
Expand Down
39 changes: 22 additions & 17 deletions build/content.zig
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,22 @@ fn writeAssetIndex(
\\
\\
;
switch (asset.lp) {
.src_path, .cwd_relative => {
std.debug.print(msg, .{asset.name});
std.process.exit(1);
},
.generated, .dependency => {
run.addArg(asset.name);
run.addFileArg(asset.lp);
run.addArg(asset.install_path orelse "null");
},
}

_ = msg;
// switch (asset.lp) {
// .src_path, .cwd_relative => {
// std.debug.print(msg, .{asset.name});
// std.process.exit(1);
// },
// .generated, .dependency => {
// run.addArg(asset.name);
// run.addFileArg(asset.lp);
// run.addArg(asset.install_path orelse "null");
// },
// }
run.addArg(asset.name);
run.addFileArg(asset.lp);
run.addArg(asset.install_path orelse "null");
}

index_step.dependOn(&run.step);
Expand Down Expand Up @@ -444,19 +449,19 @@ pub fn scanVariant(
const fm = switch (result) {
.success => |s| s.header,
.empty => {
std.debug.panic("WARNING: ignoring empty file '{s}{s}'\n", .{
std.debug.print("WARNING: ignoring empty file '{s}{s}'\n", .{
permalink, "index.md",
});
break :blk;
},
.framing_error => |line| {
std.debug.panic("ERROR: bad frontmatter framing in '{s}{s}' (line {})\n", .{
std.debug.print("ERROR: bad frontmatter framing in '{s}{s}' (line {})\n", .{
permalink, "index.md", line,
});
std.process.exit(1);
},
.ziggy_error => |diag| {
std.debug.panic("{s}{}", .{ permalink, diag });
std.debug.print("{s}{}", .{ permalink, diag });
std.process.exit(1);
},
};
Expand Down Expand Up @@ -524,19 +529,19 @@ pub fn scanVariant(
const fm = switch (result) {
.success => |s| s.header,
.empty => {
std.debug.panic("WARNING: ignoring empty file '{s}.md'\n", .{
std.debug.print("WARNING: ignoring empty file '{s}.md'\n", .{
permalink,
});
continue;
},
.framing_error => |line| {
std.debug.panic("ERROR: bad frontmatter framing in '{s}.md' (line {})\n", .{
std.debug.print("ERROR: bad frontmatter framing in '{s}.md' (line {})\n", .{
permalink, line,
});
std.process.exit(1);
},
.ziggy_error => |diag| {
std.debug.panic("{}", .{diag});
std.debug.print("{}", .{diag});
std.process.exit(1);
},
};
Expand Down
30 changes: 21 additions & 9 deletions build/tools.zig
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ pub fn build(b: *std.Build) !void {
// "BDFL version resolution" strategy
const scripty = b.dependency("scripty", .{}).module("scripty");

const supermd = b.dependency("supermd", mode).module("supermd");
supermd.addImport("scripty", scripty);

const superhtml = b.dependency("superhtml", mode).module("superhtml");
superhtml.addImport("scripty", scripty);

const supermd = b.dependency("supermd", mode).module("supermd");
supermd.addImport("scripty", scripty);
supermd.addImport("superhtml", superhtml);

const ziggy = b.dependency("ziggy", mode).module("ziggy");
const zeit = b.dependency("zeit", mode).module("zeit");
const syntax = b.dependency("flow-syntax", mode);
Expand Down Expand Up @@ -99,16 +100,27 @@ pub fn build(b: *std.Build) !void {

b.installArtifact(layout);

const docgen = b.addExecutable(.{
.name = "docgen",
const shtml_docgen = b.addExecutable(.{
.name = "shtml_docgen",
.root_source_file = b.path("src/exes/docgen.zig"),
.target = target,
.optimize = .Debug,
});
docgen.root_module.addImport("zine", zine);
docgen.root_module.addImport("zeit", zeit);
docgen.root_module.addImport("ziggy", ziggy);
b.installArtifact(docgen);
shtml_docgen.root_module.addImport("zine", zine);
shtml_docgen.root_module.addImport("zeit", zeit);
shtml_docgen.root_module.addImport("ziggy", ziggy);
b.installArtifact(shtml_docgen);

const smd_docgen = b.addExecutable(.{
.name = "smd_docgen",
.root_source_file = b.path("supermd/src/docgen.zig"),
.target = target,
.optimize = .Debug,
});
smd_docgen.root_module.addImport("zeit", zeit);
smd_docgen.root_module.addImport("ziggy", ziggy);
smd_docgen.root_module.addImport("scripty", scripty);
b.installArtifact(smd_docgen);

// const md_renderer = b.addExecutable(.{
// .name = "markdown-renderer",
Expand Down
43 changes: 27 additions & 16 deletions frontmatter.ziggy-schema
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,49 @@ root = Frontmatter
@date = bytes,

struct Frontmatter {
/// The title of this page.
///The title of this page.
title: ?bytes,
/// A short description that the section page has access to.
///A short description that the section page has
///access to.
description: ?bytes,
/// The main author of this page.
///The main author of this page.
author: ?bytes,
date: ?@date,
tags: ?[bytes],
/// Alternative paths where this content will also be made available.
///Alternative paths where this content will also be
///made available.
aliases: ?[bytes],
/// When set to true this file will be ignored when bulding the website.
///When set to true this file will be ignored when
///bulding the website.
draft: ?bool,
/// Path to a layout file inside of the configured layouts directory.
///Path to a layout file inside of the configured
///layouts directory.
layout: bytes,
/// Alternative versions of this page, created by rendering the content
/// using a different layout. Useful for creating RSS feeds, for example.
///Alternative versions of this page, created by
///rendering the content using a different layout.
///Useful for creating RSS feeds, for example.
alternatives: ?[Alternative],
/// Ignore other markdown files in this directory and any sub-directory.
/// Can only be meaningfully set to true for 'index.md' pages.
///Ignore other markdown files in this directory and
///any sub-directory. Can only be meaningfully set to
///true for 'index.md' pages.
skip_subdirs: ?bool,
/// User-defined properties that you can then reference in templates.
///User-defined properties that you can then reference
///in templates.
custom: ?map[any],
}

struct Alternative {
/// Path to a layout file inside of the configured layouts directory.
///Path to a layout file inside of the configured
///layouts directory.
layout: bytes,
/// Output path, relative to the current directory.
/// Use an absolute path to refer to the website's root directory.
///Output path, relative to the current directory.
///Use an absolute path to refer to the website's root
///directory.
output: bytes,
/// Useful when generating `<link rel="alternate">` elements.
///Useful when generating `<link rel="alternate">`
///elements.
title: ?bytes,
/// Useful when generating `<link rel="alternate">` elements.
///Useful when generating `<link rel="alternate">`
///elements.
type: ?bytes,
}
Loading

0 comments on commit 2240f00

Please sign in to comment.