lib/options: deprecate docbook text and literalDocBook

deprecate literalDocBook by adding a warning (that will not fire yet) to
its uses and other docbook literal strings by adding optional warning
message to mergeJSON.
This commit is contained in:
pennae 2022-09-01 19:23:59 +02:00 committed by pennae
parent 8c309aa43a
commit 767485a0de
9 changed files with 118 additions and 45 deletions

View file

@ -34,6 +34,10 @@
# instead of printing warnings for eg options with missing descriptions (which may be lost
# by nix build unless -L is given), emit errors instead and fail the build
, warningsAreErrors ? true
# allow docbook option docs if `true`. only markdown documentation is allowed when set to
# `false`, and a different renderer may be used with different bugs and performance
# characteristics but (hopefully) indistinguishable output.
, allowDocBook ? true
}:
let
@ -127,26 +131,23 @@ in rec {
];
options = builtins.toFile "options.json"
(builtins.unsafeDiscardStringContext (builtins.toJSON optionsNix));
# merge with an empty set if baseOptionsJSON is null to run markdown
# processing on the input options
baseJSON =
if baseOptionsJSON == null
then builtins.toFile "base.json" "{}"
else baseOptionsJSON;
}
''
# Export list of options in different format.
dst=$out/share/doc/nixos
mkdir -p $dst
${
if baseOptionsJSON == null
then ''
# `cp $options $dst/options.json`, but with temporary
# markdown processing
python ${./mergeJSON.py} $options <(echo '{}') > $dst/options.json
''
else ''
python ${./mergeJSON.py} \
${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
${baseOptionsJSON} $options \
> $dst/options.json
''
}
python ${./mergeJSON.py} \
${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
${lib.optionalString (! allowDocBook) "--error-on-docbook"} \
$baseJSON $options \
> $dst/options.json
brotli -9 < $dst/options.json > $dst/options.json.br