diff options
author | Naïm Favier <n@monade.li> | 2023-01-09 11:57:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 11:57:01 +0100 |
commit | bff4bb554028cbf083bc0d1e0a6a251653e5056d (patch) | |
tree | e0fc4768d98a58e68076bf11e578ec3f0b53e843 /nixos | |
parent | 8cd3fc50f9f13a1dc93f237c97789fac3675d524 (diff) | |
parent | 4fb500d62937dcce11c84e7c36fcc0d5db354d5c (diff) |
Merge pull request #208762 from ncfavier/link-manpages-options-doc
Diffstat (limited to 'nixos')
-rwxr-xr-x | nixos/doc/manual/md-to-db.sh | 4 | ||||
-rw-r--r-- | nixos/lib/make-options-doc/default.nix | 2 | ||||
-rw-r--r-- | nixos/lib/make-options-doc/mergeJSON.py | 10 | ||||
-rw-r--r-- | nixos/lib/systemd-unit-options.nix | 4 | ||||
-rw-r--r-- | nixos/modules/services/backup/restic.nix | 2 | ||||
-rw-r--r-- | nixos/modules/services/networking/kresd.nix | 6 | ||||
-rw-r--r-- | nixos/modules/system/boot/systemd/user.nix | 2 |
7 files changed, 21 insertions, 9 deletions
diff --git a/nixos/doc/manual/md-to-db.sh b/nixos/doc/manual/md-to-db.sh index 6eca9f3b2c3d8..4698e94f508b3 100755 --- a/nixos/doc/manual/md-to-db.sh +++ b/nixos/doc/manual/md-to-db.sh @@ -8,6 +8,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" pushd "$DIR" +link_manpages_filter=$(nix-build --no-out-link "$DIR/../../../doc/build-aux/pandoc-filters/link-manpages.nix") + # NOTE: Keep in sync with Nixpkgs manual (/doc/Makefile). # TODO: Remove raw-attribute when we can get rid of DocBook altogether. pandoc_commonmark_enabled_extensions=+attributes+fenced_divs+footnotes+bracketed_spans+definition_lists+pipe_tables+raw_attribute @@ -17,7 +19,7 @@ pandoc_flags=( # - media extraction (was only required for diagram generator) # - docbook-reader/citerefentry-to-rst-role.lua (only relevant for DocBook → MarkDown/rST/MyST) "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/myst-reader/roles.lua" - "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/link-unix-man-references.lua" + "--lua-filter=$link_manpages_filter" "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua" "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/docbook-writer/html-elements.lua" "--lua-filter=$DIR/../../../doc/build-aux/pandoc-filters/docbook-writer/labelless-link-is-xref.lua" diff --git a/nixos/lib/make-options-doc/default.nix b/nixos/lib/make-options-doc/default.nix index ecd8350b959d6..e2ed7bb71885b 100644 --- a/nixos/lib/make-options-doc/default.nix +++ b/nixos/lib/make-options-doc/default.nix @@ -131,6 +131,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 7b14af40c313b..c4f490fc2ad87 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"<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) diff --git a/nixos/lib/systemd-unit-options.nix b/nixos/lib/systemd-unit-options.nix index 9c7cb34f14b57..6c53c5e0533d7 100644 --- a/nixos/lib/systemd-unit-options.nix +++ b/nixos/lib/systemd-unit-options.nix @@ -60,7 +60,7 @@ in rec { `asDropin` creates a drop-in file named `overrides.conf`. Mainly needed to define instances for systemd template units (e.g. `systemd-nspawn@mycontainer.service`). - See also systemd.unit(1). + See also {manpage}`systemd.unit(5)`. ''; }; @@ -86,7 +86,7 @@ in rec { This option creates a `.wants` symlink in the given target that exists statelessly without the need for running `systemctl enable`. - The in systemd.unit(5) manpage described `[Install]` section however is + The `[Install]` section described in {manpage}`systemd.unit(5)` however is not supported because it is a stateful process that does not fit well into the NixOS design. ''; diff --git a/nixos/modules/services/backup/restic.nix b/nixos/modules/services/backup/restic.nix index 869ed5d9976c3..0d21b1e8d66a8 100644 --- a/nixos/modules/services/backup/restic.nix +++ b/nixos/modules/services/backup/restic.nix @@ -132,7 +132,7 @@ in OnCalendar = "daily"; }; description = lib.mdDoc '' - When to run the backup. See man systemd.timer for details. + When to run the backup. See {manpage}`systemd.timer(5)` for details. ''; example = { OnCalendar = "00:05"; diff --git a/nixos/modules/services/networking/kresd.nix b/nixos/modules/services/networking/kresd.nix index 55af6abd5e010..3ad757133a606 100644 --- a/nixos/modules/services/networking/kresd.nix +++ b/nixos/modules/services/networking/kresd.nix @@ -79,7 +79,7 @@ in { example = [ "53" ]; description = lib.mdDoc '' What addresses and ports the server should listen on. - For detailed syntax see ListenStream in man systemd.socket. + For detailed syntax see ListenStream in {manpage}`systemd.socket(5)`. ''; }; listenTLS = mkOption { @@ -88,7 +88,7 @@ in { example = [ "198.51.100.1:853" "[2001:db8::1]:853" "853" ]; description = lib.mdDoc '' Addresses and ports on which kresd should provide DNS over TLS (see RFC 7858). - For detailed syntax see ListenStream in man systemd.socket. + For detailed syntax see ListenStream in {manpage}`systemd.socket(5)`. ''; }; listenDoH = mkOption { @@ -97,7 +97,7 @@ in { example = [ "198.51.100.1:443" "[2001:db8::1]:443" "443" ]; description = lib.mdDoc '' Addresses and ports on which kresd should provide DNS over HTTPS/2 (see RFC 8484). - For detailed syntax see ListenStream in man systemd.socket. + For detailed syntax see ListenStream in {manpage}`systemd.socket(5)`. ''; }; instances = mkOption { diff --git a/nixos/modules/system/boot/systemd/user.nix b/nixos/modules/system/boot/systemd/user.nix index 46d66fe4e688c..d14d0928c53e0 100644 --- a/nixos/modules/system/boot/systemd/user.nix +++ b/nixos/modules/system/boot/systemd/user.nix @@ -46,7 +46,7 @@ in { type = types.lines; example = "DefaultCPUAccounting=yes"; description = lib.mdDoc '' - Extra config options for systemd user instances. See man systemd-user.conf for + Extra config options for systemd user instances. See {manpage}`systemd-user.conf(5)` for available options. ''; }; |