mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-28 21:37:28 -04:00
refactor(docs): switch to nixos-render-docs for nix options generation
- Use nixos-render-docs commonmark as the rendering engine - Add GitHub source links (Declared by) for each option - Fix installation.md links pointing to /docs/nix-module -> /docs/nix-options
This commit is contained in:
parent
0b39255831
commit
d7c5b603eb
5 changed files with 380 additions and 193 deletions
|
|
@ -6,6 +6,9 @@ self:
|
|||
optionPrefix,
|
||||
}:
|
||||
let
|
||||
# Absolute store path of the flake root, used to compute relative subpaths
|
||||
repoPath = toString self;
|
||||
|
||||
eval = lib.evalModules {
|
||||
modules = [
|
||||
(import module self)
|
||||
|
|
@ -14,6 +17,15 @@ let
|
|||
specialArgs = { inherit pkgs; };
|
||||
};
|
||||
|
||||
# Relative path of the module file within the repo (e.g. "nix/hm-modules.nix")
|
||||
moduleSubpath = lib.removePrefix "/" (lib.removePrefix repoPath (toString module));
|
||||
|
||||
# Declaration entry linking each option back to its source file on GitHub
|
||||
moduleDeclaration = {
|
||||
url = "https://github.com/mangowm/mango/blob/main/${moduleSubpath}";
|
||||
name = "<mango/${moduleSubpath}>";
|
||||
};
|
||||
|
||||
optionsDoc = pkgs.nixosOptionsDoc {
|
||||
options = eval.options;
|
||||
transformOptions =
|
||||
|
|
@ -21,7 +33,9 @@ let
|
|||
opt
|
||||
// {
|
||||
visible = opt.visible && !opt.internal;
|
||||
# Strip the option prefix so docs show "enable" instead of "programs.mango.enable"
|
||||
name = lib.removePrefix optionPrefix opt.name;
|
||||
declarations = [ moduleDeclaration ];
|
||||
};
|
||||
};
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue