]>
git.ipfire.org Git - thirdparty/systemd.git/blob - make-directive-index.py
1 # -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
3 # This file is part of systemd.
5 # Copyright 2012-2013 Zbigniew Jędrzejewski-Szmek
7 # systemd is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # systemd is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 from xml_helper
import *
24 from copy
import deepcopy
27 <refentry id="systemd.directives" conditional="HAVE_PYTHON">
30 <title>systemd.directives</title>
31 <productname>systemd</productname>
35 <contrib>Developer</contrib>
36 <firstname>Zbigniew</firstname>
37 <surname>Jędrzejewski-Szmek</surname>
38 <email>zbyszek@in.waw.pl</email>
44 <refentrytitle>systemd.directives</refentrytitle>
45 <manvolnum>7</manvolnum>
49 <refname>systemd.directives</refname>
50 <refpurpose>Index of configuration directives</refpurpose>
54 <title>Unit directives</title>
56 <para>Directives for configuring units, used in unit
59 <variablelist id='unit-directives' />
63 <title>Options on the kernel command line</title>
65 <para>Kernel boot options for configuring the behaviour of the
66 systemd process.</para>
68 <variablelist id='kernel-commandline-options' />
72 <title>Environment variables</title>
74 <para>Environment variables understood by the systemd
75 manager and other programs.</para>
77 <variablelist id='environment-variables' />
81 <title>UDEV directives</title>
83 <para>Directives for configuring systemd units through the
86 <variablelist id='udev-directives' />
90 <title>Network directives</title>
92 <para>Directives for configuring network links through the
93 net-setup-link udev builtin and networks through
94 systemd-networkd.</para>
96 <variablelist id='network-directives' />
100 <title>Journal fields</title>
102 <para>Fields in the journal events with a well known meaning.</para>
104 <variablelist id='journal-directives' />
108 <title>PAM configuration directives</title>
110 <para>Directives for configuring PAM behaviour.</para>
112 <variablelist id='pam-directives' />
116 <title>crypttab options</title>
118 <para>Options which influence mounted filesystems and
119 encrypted volumes.</para>
121 <variablelist id='crypttab-options' />
125 <title>System manager directives</title>
127 <para>Directives for configuring the behaviour of the
128 systemd process.</para>
130 <variablelist id='systemd-directives' />
134 <title>bootchart.conf directives</title>
136 <para>Directives for configuring the behaviour of the
137 systemd-bootchart process.</para>
139 <variablelist id='bootchart-directives' />
143 <title>command-line options</title>
145 <para>Command-line options accepted by programs in the
146 systemd suite.</para>
148 <variablelist id='options' />
152 <title>Constants</title>
154 <para>Various constant used and/or defined by systemd.</para>
156 <variablelist id='constants' />
160 <title>Miscellaneous options and directives</title>
162 <para>Other configuration elements which don't fit in
163 any of the above groups.</para>
165 <variablelist id='miscellaneous' />
169 <title>Files and directories</title>
171 <para>Paths and file names referred to in the
172 documentation.</para>
174 <variablelist id='filenames' />
178 <title>Colophon</title>
179 <para id='colophon' />
185 This index contains {count} entries in {sections} sections,
186 referring to {pages} individual manual pages.
189 def _extract_directives(directive_groups
, formatting
, page
):
191 section
= t
.find('./refmeta/manvolnum').text
192 pagename
= t
.find('./refmeta/refentrytitle').text
194 storopt
= directive_groups
['options']
195 for variablelist
in t
.iterfind('.//variablelist'):
196 klass
= variablelist
.attrib
.get('class')
197 storvar
= directive_groups
[klass
or 'miscellaneous']
198 # <option>s go in OPTIONS, unless class is specified
199 for xpath
, stor
in (('./varlistentry/term/varname', storvar
),
200 ('./varlistentry/term/option',
201 storvar
if klass
else storopt
)):
202 for name
in variablelist
.iterfind(xpath
):
203 text
= re
.sub(r
'([= ]).*', r
'\1', name
.text
).rstrip()
204 stor
[text
].append((pagename
, section
))
205 if text
not in formatting
:
206 # use element as formatted display
207 if name
.text
[-1] in '= ':
212 formatting
[text
] = name
214 storfile
= directive_groups
['filenames']
215 for xpath
, absolute_only
in (('.//refsynopsisdiv//filename', False),
216 ('.//refsynopsisdiv//command', False),
217 ('.//filename', True)):
218 for name
in t
.iterfind(xpath
):
219 if absolute_only
and not (name
.text
and name
.text
.startswith('/')):
221 if name
.attrib
.get('noindex'):
225 if name
.text
.endswith('*'):
226 name
.text
= name
.text
[:-1]
227 if not name
.text
.startswith('.'):
228 text
= name
.text
.partition(' ')[0]
229 if text
!= name
.text
:
232 if text
.endswith('/'):
234 storfile
[text
].append((pagename
, section
))
235 if text
not in formatting
:
236 # use element as formatted display
237 formatting
[text
] = name
239 text
= ' '.join(name
.itertext())
240 storfile
[text
].append((pagename
, section
))
241 formatting
[text
] = name
243 storfile
= directive_groups
['constants']
244 for name
in t
.iterfind('.//constant'):
245 if name
.attrib
.get('noindex'):
248 if name
.text
.startswith('('): # a cast, strip it
249 name
.text
= name
.text
.partition(' ')[2]
250 storfile
[name
.text
].append((pagename
, section
))
251 formatting
[name
.text
] = name
253 def _make_section(template
, name
, directives
, formatting
):
254 varlist
= template
.find(".//*[@id='{}']".format(name
))
255 for varname
, manpages
in sorted(directives
.items()):
256 entry
= tree
.SubElement(varlist
, 'varlistentry')
257 term
= tree
.SubElement(entry
, 'term')
258 display
= deepcopy(formatting
[varname
])
261 para
= tree
.SubElement(tree
.SubElement(entry
, 'listitem'), 'para')
264 for manpage
, manvolume
in sorted(set(manpages
)):
267 b
= tree
.SubElement(para
, 'citerefentry')
268 c
= tree
.SubElement(b
, 'refentrytitle')
270 d
= tree
.SubElement(b
, 'manvolnum')
274 def _make_colophon(template
, groups
):
279 for pagelist
in group
.values():
280 pages |
= set(pagelist
)
282 para
= template
.find(".//para[@id='colophon']")
283 para
.text
= COLOPHON
.format(count
=count
,
284 sections
=len(groups
),
287 def _make_page(template
, directive_groups
, formatting
):
288 """Create an XML tree from directive_groups.
291 'class': {'variable': [('manpage', 'manvolume'), ...],
296 for name
, directives
in directive_groups
.items():
297 _make_section(template
, name
, directives
, formatting
)
299 _make_colophon(template
, directive_groups
.values())
303 def make_page(*xml_files
):
304 "Extract directives from xml_files and return XML index tree."
305 template
= tree
.fromstring(TEMPLATE
)
306 names
= [vl
.get('id') for vl
in template
.iterfind('.//variablelist')]
307 directive_groups
= {name
:collections
.defaultdict(list)
310 for page
in xml_files
:
312 _extract_directives(directive_groups
, formatting
, page
)
314 raise ValueError("failed to process " + page
)
316 return _make_page(template
, directive_groups
, formatting
)
318 if __name__
== '__main__':
319 with
open(sys
.argv
[1], 'wb') as f
:
320 f
.write(xml_print(make_page(*sys
.argv
[2:])))