]>
git.ipfire.org Git - thirdparty/systemd.git/blob - make-directive-index.py
1 # -*- coding: utf-8 -*-
4 import xml
.etree
.ElementTree
as tree
7 <refentry id="systemd.directives">
10 <title>systemd.directives</title>
11 <productname>systemd</productname>
15 <contrib>Developer</contrib>
16 <firstname>Zbigniew</firstname>
17 <surname>Jędrzejewski-Szmek</surname>
18 <email>zbyszek@in.waw.pl</email>
24 <refentrytitle>systemd.directives</refentrytitle>
25 <manvolnum>5</manvolnum>
29 <refname>systemd.directives</refname>
30 <refpurpose>Index of configuration directives</refpurpose>
34 <title>Unit directives</title>
36 <para>Directives for configuring units, used in unit
39 <variablelist id='unit-directives' />
43 <title>System manager directives</title>
45 <para>Directives for configuring the behaviour of the
46 systemd process.</para>
48 <variablelist id='systemd-directives' />
52 <title>UDEV directives</title>
54 <para>Directives for configuring systemd units through the
57 <variablelist id='udev-directives' />
61 <title>Journal directives</title>
63 <para>Directives for configuring the behaviour of the
64 journald process.</para>
66 <variablelist id='journal-directives' />
71 def _extract_directives(directive_groups
, page
):
73 section
= t
.find('./refmeta/manvolnum').text
74 pagename
= t
.find('./refmeta/refentrytitle').text
75 for variablelist
in t
.iterfind('.//variablelist'):
76 klass
= variablelist
.attrib
.get('class') or 'unit-directives'
77 stor
= directive_groups
[klass
]
78 for varname
in variablelist
.iterfind('./varlistentry/term/varname'):
79 text
= ''.join(varname
.text
.partition('=')[:2])
80 stor
[text
].append((pagename
, section
))
82 def _make_section(refentry
, name
, directives
):
83 varlist
= refentry
.find(".//*[@id='{}']".format(name
))
84 for varname
, manpages
in sorted(directives
.items()):
85 entry
= tree
.SubElement(varlist
, 'varlistentry')
86 a
= tree
.SubElement(tree
.SubElement(entry
, 'term'), 'varname')
88 para
= tree
.SubElement(tree
.SubElement(entry
, 'listitem'), 'para')
91 for manpage
, manvolume
in sorted(manpages
):
94 b
= tree
.SubElement(para
, 'citerefentry')
95 c
= tree
.SubElement(b
, 'refentrytitle')
97 d
= tree
.SubElement(b
, 'manvolnum')
101 def _make_page(directive_groups
):
102 """Create an XML tree from directive_groups.
105 'class': {'variable': [('manpage', 'manvolume'), ...],
110 refentry
= tree
.fromstring(TEMPLATE
)
112 for name
, directives
in directive_groups
.items():
113 _make_section(refentry
, name
, directives
)
117 def make_page(xml_files
):
118 "Extract directives from xml_files and return XML index tree."
119 directive_groups
= {name
:collections
.defaultdict(list)
120 for name
in ['unit-directives',
122 'systemd-directives',
123 'journal-directives',
125 for page
in xml_files
:
126 _extract_directives(directive_groups
, page
)
128 return _make_page(directive_groups
)
130 if __name__
== '__main__':
131 tree
.dump(make_page(sys
.argv
[1:]))