mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 14:10:33 +03:00
nixosOptionsDoc: Add markdownByDefault parameter
This commit is contained in:
parent
d1fc8fa8b4
commit
429ba6c714
2 changed files with 10 additions and 0 deletions
|
@ -40,6 +40,8 @@
|
||||||
# `false`, and a different renderer may be used with different bugs and performance
|
# `false`, and a different renderer may be used with different bugs and performance
|
||||||
# characteristics but (hopefully) indistinguishable output.
|
# characteristics but (hopefully) indistinguishable output.
|
||||||
, allowDocBook ? true
|
, allowDocBook ? true
|
||||||
|
# whether lib.mdDoc is required for descriptions to be read as markdown.
|
||||||
|
, markdownByDefault ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -152,6 +154,7 @@ in rec {
|
||||||
python ${./mergeJSON.py} \
|
python ${./mergeJSON.py} \
|
||||||
${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
|
${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
|
||||||
${lib.optionalString (! allowDocBook) "--error-on-docbook"} \
|
${lib.optionalString (! allowDocBook) "--error-on-docbook"} \
|
||||||
|
${lib.optionalString markdownByDefault "--markdown-by-default"} \
|
||||||
$baseJSON $options \
|
$baseJSON $options \
|
||||||
> $dst/options.json
|
> $dst/options.json
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,9 @@ def convertMD(options: Dict[str, Any]) -> str:
|
||||||
for (name, option) in options.items():
|
for (name, option) in options.items():
|
||||||
if optionIs(option, 'description', 'mdDoc'):
|
if optionIs(option, 'description', 'mdDoc'):
|
||||||
option['description'] = convertString(name, option['description']['text'])
|
option['description'] = convertString(name, option['description']['text'])
|
||||||
|
elif markdownByDefault:
|
||||||
|
option['description'] = convertString(name, option['description'])
|
||||||
|
|
||||||
if optionIs(option, 'example', 'literalMD'):
|
if optionIs(option, 'example', 'literalMD'):
|
||||||
docbook = convertString(name, option['example']['text'])
|
docbook = convertString(name, option['example']['text'])
|
||||||
option['example'] = { '_type': 'literalDocBook', 'text': docbook }
|
option['example'] = { '_type': 'literalDocBook', 'text': docbook }
|
||||||
|
@ -214,6 +217,7 @@ def convertMD(options: Dict[str, Any]) -> str:
|
||||||
|
|
||||||
warningsAreErrors = False
|
warningsAreErrors = False
|
||||||
errorOnDocbook = False
|
errorOnDocbook = False
|
||||||
|
markdownByDefault = 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":
|
||||||
|
@ -222,6 +226,9 @@ for arg in sys.argv[1:]:
|
||||||
if arg == "--error-on-docbook":
|
if arg == "--error-on-docbook":
|
||||||
optOffset += 1
|
optOffset += 1
|
||||||
errorOnDocbook = True
|
errorOnDocbook = True
|
||||||
|
if arg == "--markdown-by-default":
|
||||||
|
optOffset += 1
|
||||||
|
markdownByDefault = 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')))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue