]>
git.ipfire.org Git - thirdparty/systemd.git/blob - tools/make-directive-index.py
51f1d514fcc4435d43adb7d3099d82676a62714a
2 # SPDX-License-Identifier: LGPL-2.1+
7 from xml_helper
import xml_parse
, xml_print
, tree
8 from copy
import deepcopy
11 <refentry id="systemd.directives" conditional="HAVE_PYTHON">
14 <title>systemd.directives</title>
15 <productname>systemd</productname>
19 <refentrytitle>systemd.directives</refentrytitle>
20 <manvolnum>7</manvolnum>
24 <refname>systemd.directives</refname>
25 <refpurpose>Index of configuration directives</refpurpose>
29 <title>Unit directives</title>
31 <para>Directives for configuring units, used in unit
34 <variablelist id='unit-directives' />
38 <title>Options on the kernel command line</title>
40 <para>Kernel boot options for configuring the behaviour of the
41 systemd process.</para>
43 <variablelist id='kernel-commandline-options' />
47 <title>Environment variables</title>
49 <para>Environment variables understood by the systemd manager
50 and other programs and environment variable-compatible settings.</para>
52 <variablelist id='environment-variables' />
56 <title>UDEV directives</title>
58 <para>Directives for configuring systemd units through the
61 <variablelist id='udev-directives' />
65 <title>Network directives</title>
67 <para>Directives for configuring network links through the
68 net-setup-link udev builtin and networks through
69 systemd-networkd.</para>
71 <variablelist id='network-directives' />
75 <title>Journal fields</title>
77 <para>Fields in the journal events with a well known meaning.</para>
79 <variablelist id='journal-directives' />
83 <title>PAM configuration directives</title>
85 <para>Directives for configuring PAM behaviour.</para>
87 <variablelist id='pam-directives' />
91 <title><filename>/etc/crypttab</filename> and
92 <filename>/etc/fstab</filename> options</title>
94 <para>Options which influence mounted filesystems and
95 encrypted volumes.</para>
97 <variablelist id='fstab-options' />
101 <title><citerefentry><refentrytitle>systemd.nspawn</refentrytitle><manvolnum>5</manvolnum></citerefentry>
104 <para>Directives for configuring systemd-nspawn containers.</para>
106 <variablelist id='nspawn-directives' />
110 <title>Program configuration options</title>
112 <para>Directives for configuring the behaviour of the
113 systemd process and other tools through configuration files.</para>
115 <variablelist id='config-directives' />
119 <title>Command line options</title>
121 <para>Command-line options accepted by programs in the
122 systemd suite.</para>
124 <variablelist id='options' />
128 <title>Constants</title>
130 <para>Various constant used and/or defined by systemd.</para>
132 <variablelist id='constants' />
136 <title>Miscellaneous options and directives</title>
138 <para>Other configuration elements which don't fit in
139 any of the above groups.</para>
141 <variablelist id='miscellaneous' />
145 <title>Files and directories</title>
147 <para>Paths and file names referred to in the
148 documentation.</para>
150 <variablelist id='filenames' />
154 <title>Colophon</title>
155 <para id='colophon' />
161 This index contains {count} entries in {sections} sections,
162 referring to {pages} individual manual pages.
165 def _extract_directives(directive_groups
, formatting
, page
):
167 section
= t
.find('./refmeta/manvolnum').text
168 pagename
= t
.find('./refmeta/refentrytitle').text
170 storopt
= directive_groups
['options']
171 for variablelist
in t
.iterfind('.//variablelist'):
172 klass
= variablelist
.attrib
.get('class')
173 storvar
= directive_groups
[klass
or 'miscellaneous']
174 # <option>s go in OPTIONS, unless class is specified
175 for xpath
, stor
in (('./varlistentry/term/varname', storvar
),
176 ('./varlistentry/term/option',
177 storvar
if klass
else storopt
)):
178 for name
in variablelist
.iterfind(xpath
):
179 text
= re
.sub(r
'([= ]).*', r
'\1', name
.text
).rstrip()
180 stor
[text
].append((pagename
, section
))
181 if text
not in formatting
:
182 # use element as formatted display
183 if name
.text
[-1] in '= ':
188 formatting
[text
] = name
190 storfile
= directive_groups
['filenames']
191 for xpath
, absolute_only
in (('.//refsynopsisdiv//filename', False),
192 ('.//refsynopsisdiv//command', False),
193 ('.//filename', True)):
194 for name
in t
.iterfind(xpath
):
195 if absolute_only
and not (name
.text
and name
.text
.startswith('/')):
197 if name
.attrib
.get('noindex'):
201 if name
.text
.endswith('*'):
202 name
.text
= name
.text
[:-1]
203 if not name
.text
.startswith('.'):
204 text
= name
.text
.partition(' ')[0]
205 if text
!= name
.text
:
208 if text
.endswith('/'):
210 storfile
[text
].append((pagename
, section
))
211 if text
not in formatting
:
212 # use element as formatted display
213 formatting
[text
] = name
215 text
= ' '.join(name
.itertext())
216 storfile
[text
].append((pagename
, section
))
217 formatting
[text
] = name
219 storfile
= directive_groups
['constants']
220 for name
in t
.iterfind('.//constant'):
221 if name
.attrib
.get('noindex'):
224 if name
.text
.startswith('('): # a cast, strip it
225 name
.text
= name
.text
.partition(' ')[2]
226 storfile
[name
.text
].append((pagename
, section
))
227 formatting
[name
.text
] = name
229 def _make_section(template
, name
, directives
, formatting
):
230 varlist
= template
.find(".//*[@id='{}']".format(name
))
231 for varname
, manpages
in sorted(directives
.items()):
232 entry
= tree
.SubElement(varlist
, 'varlistentry')
233 term
= tree
.SubElement(entry
, 'term')
234 display
= deepcopy(formatting
[varname
])
237 para
= tree
.SubElement(tree
.SubElement(entry
, 'listitem'), 'para')
240 for manpage
, manvolume
in sorted(set(manpages
)):
243 b
= tree
.SubElement(para
, 'citerefentry')
244 c
= tree
.SubElement(b
, 'refentrytitle')
246 c
.attrib
['target'] = varname
247 d
= tree
.SubElement(b
, 'manvolnum')
251 def _make_colophon(template
, groups
):
256 for pagelist
in group
.values():
257 pages |
= set(pagelist
)
259 para
= template
.find(".//para[@id='colophon']")
260 para
.text
= COLOPHON
.format(count
=count
,
261 sections
=len(groups
),
264 def _make_page(template
, directive_groups
, formatting
):
265 """Create an XML tree from directive_groups.
268 'class': {'variable': [('manpage', 'manvolume'), ...],
273 for name
, directives
in directive_groups
.items():
274 _make_section(template
, name
, directives
, formatting
)
276 _make_colophon(template
, directive_groups
.values())
280 def make_page(*xml_files
):
281 "Extract directives from xml_files and return XML index tree."
282 template
= tree
.fromstring(TEMPLATE
)
283 names
= [vl
.get('id') for vl
in template
.iterfind('.//variablelist')]
284 directive_groups
= {name
:collections
.defaultdict(list)
287 for page
in xml_files
:
289 _extract_directives(directive_groups
, formatting
, page
)
291 raise ValueError("failed to process " + page
)
293 return _make_page(template
, directive_groups
, formatting
)
295 if __name__
== '__main__':
296 with
open(sys
.argv
[1], 'wb') as f
:
297 f
.write(xml_print(make_page(*sys
.argv
[2:])))