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
|
||||
then builtins.toFile "base.json" "{}"
|
||||
else baseOptionsJSON;
|
||||
|
||||
MANPAGE_URLS = pkgs.path + "/doc/manpage-urls.json";
|
||||
}
|
||||
''
|
||||
# Export list of options in different format.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import collections
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from typing import Any, Dict, List
|
||||
|
||||
|
@ -46,6 +47,8 @@ def unpivot(options: Dict[Key, Option]) -> Dict[str, JSON]:
|
|||
result[opt.name] = opt.value
|
||||
return result
|
||||
|
||||
manpage_urls = json.load(open(os.getenv('MANPAGE_URLS')))
|
||||
|
||||
admonitions = {
|
||||
'.warning': 'warning',
|
||||
'.important': 'important',
|
||||
|
@ -119,9 +122,14 @@ class Renderer(mistune.renderers.BaseRenderer):
|
|||
def env(self, text):
|
||||
return f"<envar>{escape(text)}</envar>"
|
||||
def manpage(self, page, section):
|
||||
man = f"{page}({section})"
|
||||
title = f"<refentrytitle>{escape(page)}</refentrytitle>"
|
||||
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):
|
||||
return "".join(data)
|
||||
|
|
Loading…
Reference in a new issue