Skip to content

Commit

Permalink
doc: add declaration entry
Browse files Browse the repository at this point in the history
  • Loading branch information
trueNAHO authored and danth committed Feb 19, 2025
1 parent eccb4ad commit 02f69d4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,26 @@ let
(pkgs.nixosOptionsDoc {
inherit (configuration) options;
transformOptions =
let
declarationPrefix = toString inputs.self;
in
option:
option
// {
declarations = map (
declaration:
let
declarationString = toString declaration;
declarationWithoutprefix = lib.removePrefix "${declarationPrefix}/" declarationString;
in
lib.throwIfNot (lib.hasPrefix declarationPrefix declarationString)
"declaration not in ${declarationPrefix}: ${declarationString}"
{
name = "<${declarationWithoutprefix}>";
url = "https://github.com/danth/stylix/blob/master/${declarationWithoutprefix}";
}
) option.declarations;

visible = option.visible && lib.any pathFilter option.declarations;
};
}).optionsCommonMark;
Expand Down Expand Up @@ -97,10 +114,6 @@ pkgs.stdenvNoCC.mkDerivation {
# so they can be nested under the sections for each module system.
REDUCE_HEADINGS='s/^## /### /'
# The "declared by" links point to a file which only exists when the docs
# are built locally. This removes the links.
REMOVE_DECLARED_BY='/*Declared by:*/,/^$/d'
function writeOptions() {
platformName="$1"
optionsFile="$2"
Expand All @@ -111,7 +124,6 @@ pkgs.stdenvNoCC.mkDerivation {
if [[ -s "$optionsFile" ]]; then
sed \
--expression "$REDUCE_HEADINGS" \
--expression "$REMOVE_DECLARED_BY" \
<"$optionsFile" \
>>"$outputFile"
else
Expand Down

0 comments on commit 02f69d4

Please sign in to comment.