mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 12:15:34 +03:00
nixos/make-options-doc: link manpages
Add links to manpages without a link using the mapping defined in `doc/manpage-urls.json`, as is already done for the nixpkgs and NixOS manuals.
This commit is contained in:
parent
a8d4cf149c
commit
f61e538c43
2 changed files with 11 additions and 1 deletions
|
@ -130,6 +130,8 @@ in rec {
|
||||||
if baseOptionsJSON == null
|
if baseOptionsJSON == null
|
||||||
then builtins.toFile "base.json" "{}"
|
then builtins.toFile "base.json" "{}"
|
||||||
else baseOptionsJSON;
|
else baseOptionsJSON;
|
||||||
|
|
||||||
|
MANPAGE_URLS = pkgs.path + "/doc/manpage-urls.json";
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
# Export list of options in different format.
|
# Export list of options in different format.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import collections
|
import collections
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ def unpivot(options: Dict[Key, Option]) -> Dict[str, JSON]:
|
||||||
result[opt.name] = opt.value
|
result[opt.name] = opt.value
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
manpage_urls = json.load(open(os.getenv('MANPAGE_URLS')))
|
||||||
|
|
||||||
admonitions = {
|
admonitions = {
|
||||||
'.warning': 'warning',
|
'.warning': 'warning',
|
||||||
'.important': 'important',
|
'.important': 'important',
|
||||||
|
@ -119,9 +122,14 @@ class Renderer(mistune.renderers.BaseRenderer):
|
||||||
def env(self, text):
|
def env(self, text):
|
||||||
return f"<envar>{escape(text)}</envar>"
|
return f"<envar>{escape(text)}</envar>"
|
||||||
def manpage(self, page, section):
|
def manpage(self, page, section):
|
||||||
|
man = f"{page}({section})"
|
||||||
title = f"<refentrytitle>{escape(page)}</refentrytitle>"
|
title = f"<refentrytitle>{escape(page)}</refentrytitle>"
|
||||||
vol = f"<manvolnum>{escape(section)}</manvolnum>"
|
vol = f"<manvolnum>{escape(section)}</manvolnum>"
|
||||||
return f"<citerefentry>{title}{vol}</citerefentry>"
|
ref = f"<citerefentry>{title}{vol}</citerefentry>"
|
||||||
|
if man in manpage_urls:
|
||||||
|
return self.link(manpage_urls[man], text=ref)
|
||||||
|
else:
|
||||||
|
return ref
|
||||||
|
|
||||||
def finalize(self, data):
|
def finalize(self, data):
|
||||||
return "".join(data)
|
return "".join(data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue