diff --git a/nixos/lib/make-options-doc/default.nix b/nixos/lib/make-options-doc/default.nix
index a3436caad8f9..f2bcbba69aec 100644
--- a/nixos/lib/make-options-doc/default.nix
+++ b/nixos/lib/make-options-doc/default.nix
@@ -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.
diff --git a/nixos/lib/make-options-doc/mergeJSON.py b/nixos/lib/make-options-doc/mergeJSON.py
index 750cd24fc653..070f2d6025a2 100644
--- a/nixos/lib/make-options-doc/mergeJSON.py
+++ b/nixos/lib/make-options-doc/mergeJSON.py
@@ -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"{escape(text)}"
def manpage(self, page, section):
+ man = f"{page}({section})"
title = f"{escape(page)}"
vol = f"{escape(section)}"
- return f"{title}{vol}"
+ ref = f"{title}{vol}"
+ if man in manpage_urls:
+ return self.link(manpage_urls[man], text=ref)
+ else:
+ return ref
def finalize(self, data):
return "".join(data)