mirror of
https://github.com/tale/headplane.git
synced 2026-07-26 07:48:14 +00:00
feat: nix: docs: improve NixOS docs generations
This commit is contained in:
committed by
Aarnav Tale
parent
9192013bfe
commit
c98dc5ed1d
+192
-695
File diff suppressed because it is too large
Load Diff
+37
@@ -0,0 +1,37 @@
|
||||
import fs from "node:fs";
|
||||
|
||||
function renderOptions(options) {
|
||||
const blocks = Object.keys(options).map((key) => {
|
||||
const opt = options[key];
|
||||
const name = key.split(".").slice(2).join(".");
|
||||
const lines = [];
|
||||
lines.push(`## ${name}`);
|
||||
lines.push(`*Description:* ${opt.description}\n`);
|
||||
lines.push(`*Type:* ${opt.type}\n`);
|
||||
if (opt.default) {
|
||||
lines.push(`*Default:* \`${opt.default.text}\`\n`);
|
||||
}
|
||||
if (opt.example) {
|
||||
lines.push(`*Example:* \`${opt.example.text}\`\n`);
|
||||
}
|
||||
return lines.join("\n");
|
||||
});
|
||||
|
||||
return [
|
||||
`# NixOS module options
|
||||
|
|
||||
|All options must be under \`services.headplane\`.
|
||||
|
|
||||
|For example: \`settings.headscale.config_path\` becomes \`services.headplane.settings.headscale.config_path\`.`
|
||||
.split("|")
|
||||
.map((s) => s.replace(/\n\s+/g, ""))
|
||||
.join("\n"),
|
||||
]
|
||||
.concat(blocks)
|
||||
.join("\n\n");
|
||||
}
|
||||
|
||||
const filename = process.argv[2];
|
||||
const file = fs.readFileSync(filename);
|
||||
const json = JSON.parse(file);
|
||||
console.log(renderOptions(json));
|
||||
+4
-1
@@ -2,6 +2,7 @@
|
||||
lib,
|
||||
nixosOptionsDoc,
|
||||
runCommand,
|
||||
nodejs,
|
||||
...
|
||||
}: let
|
||||
eval = lib.evalModules {
|
||||
@@ -21,4 +22,6 @@
|
||||
inherit transformOptions;
|
||||
};
|
||||
in
|
||||
runCommand "headplane-nixos-docs.md" {} "cat ${optionsDoc.optionsCommonMark} > $out"
|
||||
runCommand "headplane-nixos-docs.json" {} ''
|
||||
${nodejs}/bin/node ${./docs.js} ${optionsDoc.optionsJSON}/share/doc/nixos/options.json > $out
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user