docs/nrd: move make_xml_id to manual_structure

since we don't want to break links and changing the id generation scheme
would Very Break links this id generation function is unfortunately
somewhat part of the manual structure now, so we may as well put it there.

pennae ec71d0da 02aff756

Changed files
+21 -17
pkgs
tools
nix
nixos-render-docs
-13
pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/docbook.py
···
from .md import Renderer
-
_xml_id_translate_table = {
-
ord('*'): ord('_'),
-
ord('<'): ord('_'),
-
ord(' '): ord('_'),
-
ord('>'): ord('_'),
-
ord('['): ord('_'),
-
ord(']'): ord('_'),
-
ord(':'): ord('_'),
-
ord('"'): ord('_'),
-
}
-
def make_xml_id(s: str) -> str:
-
return s.translate(_xml_id_translate_table)
-
class Deflist:
has_dd = False
+2 -2
pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual.py
···
from markdown_it.token import Token
from . import md, options
-
from .docbook import DocBookRenderer, Heading, make_xml_id
+
from .docbook import DocBookRenderer, Heading
from .html import HTMLRenderer, UnresolvedXrefError
-
from .manual_structure import check_structure, FragmentType, is_include, TocEntry, TocEntryType, XrefTarget
+
from .manual_structure import check_structure, FragmentType, is_include, make_xml_id, TocEntry, TocEntryType, XrefTarget
from .md import Converter, Renderer
class BaseConverter(Converter[md.TR], Generic[md.TR]):
+17
pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual_structure.py
···
while len(entries) > 1:
entries[-2][1].children.append(entries.pop()[1])
return (entries[0][1], examples, figures)
+
+
_xml_id_translate_table = {
+
ord('*'): ord('_'),
+
ord('<'): ord('_'),
+
ord(' '): ord('_'),
+
ord('>'): ord('_'),
+
ord('['): ord('_'),
+
ord(']'): ord('_'),
+
ord(':'): ord('_'),
+
ord('"'): ord('_'),
+
}
+
# this function is needed to generate option id attributes in the same format as
+
# the docbook toolchain did to not break existing links. we don't actually use
+
# xml any more, that's just the legacy we're dealing with and part of our structure
+
# now.
+
def make_xml_id(s: str) -> str:
+
return s.translate(_xml_id_translate_table)
+2 -2
pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/options.py
···
from . import parallel
from .asciidoc import AsciiDocRenderer, asciidoc_escape
from .commonmark import CommonMarkRenderer
-
from .docbook import DocBookRenderer, make_xml_id
+
from .docbook import DocBookRenderer
from .html import HTMLRenderer
from .manpage import ManpageRenderer, man_escape
-
from .manual_structure import XrefTarget
+
from .manual_structure import make_xml_id, XrefTarget
from .md import Converter, md_escape, md_make_code
from .types import OptionLoc, Option, RenderedOption