summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-05-29 22:31:20 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-05-30 00:43:38 -0400
commit827f70eb764428baa397e9f3e295c470a1fd43e6 (patch)
treeb4e5221960a58e33fc79d4de38cf2548fafd4e14
parent310b59edcf0a98343425a47ea5835fc670c0cda3 (diff)
man: fix display of keys which appear in two sections in directive index
When an index key appeared in multiple sections (e.g. CPUAffinity= was present in both "SYSTEM MANAGER DIRECTIVES" and "UNIT DIRECTIVES"), when lxml was used, the key would be not be displayed in all but one of those sections, and only an empty <term/> element would be present. This happens because lxml allows only one parent for each node, and when the same formatted element was used in multiple places, it was actually moved between them. Fix this by making a copy of the element. The bug was present since lxml support was introduced. Also fix some indentation issues.
-rwxr-xr-xmake-directive-index.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/make-directive-index.py b/make-directive-index.py
index 396947b303..468d14da75 100755
--- a/make-directive-index.py
+++ b/make-directive-index.py
@@ -21,6 +21,7 @@ import sys
import collections
import re
from xml_helper import *
+from copy import deepcopy
TEMPLATE = '''\
<refentry id="systemd.directives" conditional="HAVE_PYTHON">
@@ -226,19 +227,20 @@ def _make_section(template, name, directives, formatting):
for varname, manpages in sorted(directives.items()):
entry = tree.SubElement(varlist, 'varlistentry')
term = tree.SubElement(entry, 'term')
- term.append(formatting[varname])
+ display = deepcopy(formatting[varname])
+ term.append(display)
para = tree.SubElement(tree.SubElement(entry, 'listitem'), 'para')
b = None
for manpage, manvolume in sorted(set(manpages)):
- if b is not None:
- b.tail = ', '
- b = tree.SubElement(para, 'citerefentry')
- c = tree.SubElement(b, 'refentrytitle')
- c.text = manpage
- d = tree.SubElement(b, 'manvolnum')
- d.text = manvolume
+ if b is not None:
+ b.tail = ', '
+ b = tree.SubElement(para, 'citerefentry')
+ c = tree.SubElement(b, 'refentrytitle')
+ c.text = manpage
+ d = tree.SubElement(b, 'manvolnum')
+ d.text = manvolume
entry.tail = '\n\n'
def _make_colophon(template, groups):
@@ -264,7 +266,7 @@ def _make_page(template, directive_groups, formatting):
}
"""
for name, directives in directive_groups.items():
- _make_section(template, name, directives, formatting)
+ _make_section(template, name, directives, formatting)
_make_colophon(template, directive_groups.values())