mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
nixos/doc: remove docbook options compatibility
no longer needed or useful, and may even produce false positives now that markdown is the default language for option docs.
This commit is contained in:
parent
1418c986b0
commit
20152b4269
3 changed files with 23 additions and 122 deletions
|
@ -202,14 +202,8 @@ in rec {
|
||||||
|
|
||||||
# Generate the NixOS manual.
|
# Generate the NixOS manual.
|
||||||
manualHTML = runCommand "nixos-manual-html"
|
manualHTML = runCommand "nixos-manual-html"
|
||||||
{ nativeBuildInputs =
|
{ nativeBuildInputs = [ buildPackages.nixos-render-docs ];
|
||||||
if allowDocBook then [
|
inputs = lib.sourceFilesBySuffices ./. [ ".md" ];
|
||||||
buildPackages.libxml2.bin
|
|
||||||
buildPackages.libxslt.bin
|
|
||||||
] else [
|
|
||||||
buildPackages.nixos-render-docs
|
|
||||||
];
|
|
||||||
inputs = lib.optionals (! allowDocBook) (lib.sourceFilesBySuffices ./. [ ".md" ]);
|
|
||||||
meta.description = "The NixOS manual in HTML format";
|
meta.description = "The NixOS manual in HTML format";
|
||||||
allowedReferences = ["out"];
|
allowedReferences = ["out"];
|
||||||
}
|
}
|
||||||
|
@ -222,38 +216,23 @@ in rec {
|
||||||
cp ${../../../doc/overrides.css} $dst/overrides.css
|
cp ${../../../doc/overrides.css} $dst/overrides.css
|
||||||
cp -r ${pkgs.documentation-highlighter} $dst/highlightjs
|
cp -r ${pkgs.documentation-highlighter} $dst/highlightjs
|
||||||
|
|
||||||
${if allowDocBook then ''
|
${prepareManualFromMD}
|
||||||
xsltproc \
|
|
||||||
${manualXsltprocOptions} \
|
|
||||||
--stringparam id.warnings "1" \
|
|
||||||
--nonet --output $dst/ \
|
|
||||||
${docbook_xsl_ns}/xml/xsl/docbook/xhtml/chunktoc.xsl \
|
|
||||||
${manual-combined}/manual-combined.xml \
|
|
||||||
|& tee xsltproc.out
|
|
||||||
grep "^ID recommended on" xsltproc.out &>/dev/null && echo "error: some IDs are missing" && false
|
|
||||||
rm xsltproc.out
|
|
||||||
|
|
||||||
mkdir -p $dst/images/callouts
|
# TODO generator is set like this because the docbook/md manual compare workflow will
|
||||||
cp ${docbook_xsl_ns}/xml/xsl/docbook/images/callouts/*.svg $dst/images/callouts/
|
# trigger if it's different
|
||||||
'' else ''
|
nixos-render-docs -j $NIX_BUILD_CORES manual html \
|
||||||
${prepareManualFromMD}
|
--manpage-urls ${manpageUrls} \
|
||||||
|
--revision ${lib.escapeShellArg revision} \
|
||||||
# TODO generator is set like this because the docbook/md manual compare workflow will
|
--generator "DocBook XSL Stylesheets V${docbook_xsl_ns.version}" \
|
||||||
# trigger if it's different
|
--stylesheet style.css \
|
||||||
nixos-render-docs -j $NIX_BUILD_CORES manual html \
|
--stylesheet overrides.css \
|
||||||
--manpage-urls ${manpageUrls} \
|
--stylesheet highlightjs/mono-blue.css \
|
||||||
--revision ${lib.escapeShellArg revision} \
|
--script ./highlightjs/highlight.pack.js \
|
||||||
--generator "DocBook XSL Stylesheets V${docbook_xsl_ns.version}" \
|
--script ./highlightjs/loader.js \
|
||||||
--stylesheet style.css \
|
--toc-depth 1 \
|
||||||
--stylesheet overrides.css \
|
--chunk-toc-depth 1 \
|
||||||
--stylesheet highlightjs/mono-blue.css \
|
./manual.md \
|
||||||
--script ./highlightjs/highlight.pack.js \
|
$dst/index.html
|
||||||
--script ./highlightjs/loader.js \
|
|
||||||
--toc-depth 1 \
|
|
||||||
--chunk-toc-depth 1 \
|
|
||||||
./manual.md \
|
|
||||||
$dst/index.html
|
|
||||||
''}
|
|
||||||
|
|
||||||
mkdir -p $out/nix-support
|
mkdir -p $out/nix-support
|
||||||
echo "nix-build out $out" >> $out/nix-support/hydra-build-products
|
echo "nix-build out $out" >> $out/nix-support/hydra-build-products
|
||||||
|
@ -319,10 +298,6 @@ in rec {
|
||||||
manpages = runCommand "nixos-manpages"
|
manpages = runCommand "nixos-manpages"
|
||||||
{ nativeBuildInputs = [
|
{ nativeBuildInputs = [
|
||||||
buildPackages.installShellFiles
|
buildPackages.installShellFiles
|
||||||
] ++ lib.optionals allowDocBook [
|
|
||||||
buildPackages.libxml2.bin
|
|
||||||
buildPackages.libxslt.bin
|
|
||||||
] ++ lib.optionals (! allowDocBook) [
|
|
||||||
buildPackages.nixos-render-docs
|
buildPackages.nixos-render-docs
|
||||||
];
|
];
|
||||||
allowedReferences = ["out"];
|
allowedReferences = ["out"];
|
||||||
|
@ -331,24 +306,11 @@ in rec {
|
||||||
# Generate manpages.
|
# Generate manpages.
|
||||||
mkdir -p $out/share/man/man8
|
mkdir -p $out/share/man/man8
|
||||||
installManPage ${./manpages}/*
|
installManPage ${./manpages}/*
|
||||||
${if allowDocBook
|
mkdir -p $out/share/man/man5
|
||||||
then ''
|
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
|
||||||
xsltproc --nonet \
|
--revision ${lib.escapeShellArg revision} \
|
||||||
--maxdepth 6000 \
|
${optionsJSON}/share/doc/nixos/options.json \
|
||||||
--param man.output.in.separate.dir 1 \
|
$out/share/man/man5/configuration.nix.5
|
||||||
--param man.output.base.dir "'$out/share/man/'" \
|
|
||||||
--param man.endnotes.are.numbered 0 \
|
|
||||||
--param man.break.after.slash 1 \
|
|
||||||
${docbook_xsl_ns}/xml/xsl/docbook/manpages/docbook.xsl \
|
|
||||||
${manpages-combined}
|
|
||||||
''
|
|
||||||
else ''
|
|
||||||
mkdir -p $out/share/man/man5
|
|
||||||
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
|
|
||||||
--revision ${lib.escapeShellArg revision} \
|
|
||||||
${optionsJSON}/share/doc/nixos/options.json \
|
|
||||||
$out/share/man/man5/configuration.nix.5
|
|
||||||
''}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,6 @@ in rec {
|
||||||
TOUCH_IF_DB=$dst/.used-docbook \
|
TOUCH_IF_DB=$dst/.used-docbook \
|
||||||
python ${./mergeJSON.py} \
|
python ${./mergeJSON.py} \
|
||||||
${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
|
${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
|
||||||
${if allowDocBook then "--warn-on-docbook" else "--error-on-docbook"} \
|
|
||||||
$baseJSON $options \
|
$baseJSON $options \
|
||||||
> $dst/options.json
|
> $dst/options.json
|
||||||
|
|
||||||
|
|
|
@ -43,19 +43,11 @@ def unpivot(options: Dict[Key, Option]) -> Dict[str, JSON]:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
warningsAreErrors = False
|
warningsAreErrors = False
|
||||||
warnOnDocbook = False
|
|
||||||
errorOnDocbook = False
|
|
||||||
optOffset = 0
|
optOffset = 0
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if arg == "--warnings-are-errors":
|
if arg == "--warnings-are-errors":
|
||||||
optOffset += 1
|
optOffset += 1
|
||||||
warningsAreErrors = True
|
warningsAreErrors = True
|
||||||
if arg == "--warn-on-docbook":
|
|
||||||
optOffset += 1
|
|
||||||
warnOnDocbook = True
|
|
||||||
elif arg == "--error-on-docbook":
|
|
||||||
optOffset += 1
|
|
||||||
errorOnDocbook = True
|
|
||||||
|
|
||||||
options = pivot(json.load(open(sys.argv[1 + optOffset], 'r')))
|
options = pivot(json.load(open(sys.argv[1 + optOffset], 'r')))
|
||||||
overrides = pivot(json.load(open(sys.argv[2 + optOffset], 'r')))
|
overrides = pivot(json.load(open(sys.argv[2 + optOffset], 'r')))
|
||||||
|
@ -84,38 +76,10 @@ for (k, v) in overrides.items():
|
||||||
|
|
||||||
severity = "error" if warningsAreErrors else "warning"
|
severity = "error" if warningsAreErrors else "warning"
|
||||||
|
|
||||||
def is_docbook(o, key):
|
|
||||||
val = o.get(key, {})
|
|
||||||
if not isinstance(val, dict):
|
|
||||||
return False
|
|
||||||
return val.get('_type', '') == 'literalDocBook'
|
|
||||||
|
|
||||||
# check that every option has a description
|
# check that every option has a description
|
||||||
hasWarnings = False
|
hasWarnings = False
|
||||||
hasErrors = False
|
hasErrors = False
|
||||||
hasDocBook = False
|
|
||||||
for (k, v) in options.items():
|
for (k, v) in options.items():
|
||||||
if warnOnDocbook or errorOnDocbook:
|
|
||||||
kind = "error" if errorOnDocbook else "warning"
|
|
||||||
if isinstance(v.value.get('description', {}), str):
|
|
||||||
hasErrors |= errorOnDocbook
|
|
||||||
hasDocBook = True
|
|
||||||
print(
|
|
||||||
f"\x1b[1;31m{kind}: option {v.name} description uses DocBook\x1b[0m",
|
|
||||||
file=sys.stderr)
|
|
||||||
elif is_docbook(v.value, 'defaultText'):
|
|
||||||
hasErrors |= errorOnDocbook
|
|
||||||
hasDocBook = True
|
|
||||||
print(
|
|
||||||
f"\x1b[1;31m{kind}: option {v.name} default uses DocBook\x1b[0m",
|
|
||||||
file=sys.stderr)
|
|
||||||
elif is_docbook(v.value, 'example'):
|
|
||||||
hasErrors |= errorOnDocbook
|
|
||||||
hasDocBook = True
|
|
||||||
print(
|
|
||||||
f"\x1b[1;31m{kind}: option {v.name} example uses DocBook\x1b[0m",
|
|
||||||
file=sys.stderr)
|
|
||||||
|
|
||||||
if v.value.get('description', None) is None:
|
if v.value.get('description', None) is None:
|
||||||
hasWarnings = True
|
hasWarnings = True
|
||||||
print(f"\x1b[1;31m{severity}: option {v.name} has no description\x1b[0m", file=sys.stderr)
|
print(f"\x1b[1;31m{severity}: option {v.name} has no description\x1b[0m", file=sys.stderr)
|
||||||
|
@ -126,30 +90,6 @@ for (k, v) in options.items():
|
||||||
f"\x1b[1;31m{severity}: option {v.name} has no type. Please specify a valid type, see " +
|
f"\x1b[1;31m{severity}: option {v.name} has no type. Please specify a valid type, see " +
|
||||||
"https://nixos.org/manual/nixos/stable/index.html#sec-option-types\x1b[0m", file=sys.stderr)
|
"https://nixos.org/manual/nixos/stable/index.html#sec-option-types\x1b[0m", file=sys.stderr)
|
||||||
|
|
||||||
if hasDocBook:
|
|
||||||
(why, what) = (
|
|
||||||
("disallowed for in-tree modules", "contribution") if errorOnDocbook
|
|
||||||
else ("deprecated for option documentation", "module")
|
|
||||||
)
|
|
||||||
print("Explanation: The documentation contains descriptions, examples, or defaults written in DocBook. " +
|
|
||||||
"NixOS is in the process of migrating from DocBook to Markdown, and " +
|
|
||||||
f"DocBook is {why}. To change your {what} to "+
|
|
||||||
"use Markdown, apply mdDoc and literalMD and use the *MD variants of option creation " +
|
|
||||||
"functions where they are available. For example:\n" +
|
|
||||||
"\n" +
|
|
||||||
" example.foo = mkOption {\n" +
|
|
||||||
" description = lib.mdDoc ''your description'';\n" +
|
|
||||||
" defaultText = lib.literalMD ''your description of default'';\n" +
|
|
||||||
" };\n" +
|
|
||||||
"\n" +
|
|
||||||
" example.enable = mkEnableOption (lib.mdDoc ''your thing'');\n" +
|
|
||||||
" example.package = mkPackageOptionMD pkgs \"your-package\" {};\n" +
|
|
||||||
" imports = [ (mkAliasOptionModuleMD [ \"example\" \"args\" ] [ \"example\" \"settings\" ]) ];",
|
|
||||||
file = sys.stderr)
|
|
||||||
with open(os.getenv('TOUCH_IF_DB'), 'x'):
|
|
||||||
# just make sure it exists
|
|
||||||
pass
|
|
||||||
|
|
||||||
if hasErrors:
|
if hasErrors:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if hasWarnings and warningsAreErrors:
|
if hasWarnings and warningsAreErrors:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue