summary refs log tree commit diff
path: root/pkgs/tools/nix/nixos-render-docs
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2023-02-19 15:56:52 +0100
committerpennae <github@quasiparticle.net>2023-02-21 18:26:40 +0100
commit5b8be28e66a31ba4683d0fc337f67a46d5db8f9a (patch)
treeb0cd4e4153e20125416982e94114d4589342e0df /pkgs/tools/nix/nixos-render-docs
parent068916ae8fccebf137ffe68b511bff26f1069ef8 (diff)
downloadnixpkgs-5b8be28e66a31ba4683d0fc337f67a46d5db8f9a.tar
nixpkgs-5b8be28e66a31ba4683d0fc337f67a46d5db8f9a.tar.gz
nixpkgs-5b8be28e66a31ba4683d0fc337f67a46d5db8f9a.tar.bz2
nixpkgs-5b8be28e66a31ba4683d0fc337f67a46d5db8f9a.tar.lz
nixpkgs-5b8be28e66a31ba4683d0fc337f67a46d5db8f9a.tar.xz
nixpkgs-5b8be28e66a31ba4683d0fc337f67a46d5db8f9a.tar.zst
nixpkgs-5b8be28e66a31ba4683d0fc337f67a46d5db8f9a.zip
nixos-render-docs: don't render options during manual parsing
we should really be rendering options at *rendering* time, not at parse
time. currently this is just an academic exercise, but the html renderer
will have to inspect the options.json data after the entire document has
been parsed, but before anything gets rendered.
Diffstat (limited to 'pkgs/tools/nix/nixos-render-docs')
-rw-r--r--pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual.py b/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual.py
index 78bf7659451..780a5f38c32 100644
--- a/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual.py
+++ b/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual.py
@@ -97,7 +97,10 @@ class ManualDocBookRenderer(DocBookRenderer):
                 raise RuntimeError(f"rendering {path}") from e
         return "".join(result)
     def included_options(self, token: Token, tokens: Sequence[Token], i: int) -> str:
-        return cast(str, token.meta['rendered-options'])
+        conv = options.DocBookConverter(self._manpage_urls, self._revision, False, 'fragment',
+                                        token.meta['list-id'], token.meta['id-prefix'])
+        conv.add_options(token.meta['source'])
+        return conv.finalize(fragment=True)
 
     # TODO minimize docbook diffs with existing conversions. remove soon.
     def paragraph_open(self, token: Token, tokens: Sequence[Token], i: int) -> str:
@@ -181,11 +184,10 @@ class DocBookConverter(Converter[ManualDocBookRenderer]):
                 " ".join(items.keys()))
 
         try:
-            conv = options.DocBookConverter(
-                self._renderer._manpage_urls, self._renderer._revision, False, 'fragment', varlist_id, id_prefix)
             with open(self._base_paths[-1].parent / source, 'r') as f:
-                conv.add_options(json.load(f))
-            token.meta['rendered-options'] = conv.finalize(fragment=True)
+                token.meta['id-prefix'] = id_prefix
+                token.meta['list-id'] = varlist_id
+                token.meta['source'] = json.load(f)
         except Exception as e:
             raise RuntimeError(f"processing options block in line {token.map[0] + 1}") from e