]>
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>Journal fields</title>
92 <para>Fields in the journal events with a well known meaning.</para>
94 <variablelist id='journal-directives' />
98 <title>PAM configuration directives</title>
100 <para>Directives for configuring PAM behaviour.</para>
102 <variablelist id='pam-directives' />
106 <title>crypttab options</title>
108 <para>Options which influence mounted filesystems and
109 encrypted volumes.</para>
111 <variablelist id='crypttab-options' />
115 <title>System manager directives</title>
117 <para>Directives for configuring the behaviour of the
118 systemd process.</para>
120 <variablelist id='systemd-directives' />
124 <title>bootchart.conf directives</title>
126 <para>Directives for configuring the behaviour of the
127 systemd-bootchart process.</para>
129 <variablelist id='bootchart-directives' />
133 <title>command-line options</title>
135 <para>Command-line options accepted by programs in the
136 systemd suite.</para>
138 <variablelist id='options' />
142 <title>Constants</title>
144 <para>Various constant used and/or defined by systemd.</para>
146 <variablelist id='constants' />
150 <title>Miscellaneous options and directives</title>
152 <para>Other configuration elements which don't fit in
153 any of the above groups.</para>
155 <variablelist id='miscellaneous' />
159 <title>Files and directories</title>
161 <para>Paths and file names referred to in the
162 documentation.</para>
164 <variablelist id='filenames' />
168 <title>Colophon</title>
169 <para id='colophon' />
175 This index contains {count} entries in {sections} sections,
176 referring to {pages} individual manual pages.
179 def _extract_directives(directive_groups
, formatting
, page
):
181 section
= t
.find('./refmeta/manvolnum').text
182 pagename
= t
.find('./refmeta/refentrytitle').text
184 storopt
= directive_groups
['options']
185 for variablelist
in t
.iterfind('.//variablelist'):
186 klass
= variablelist
.attrib
.get('class')
187 storvar
= directive_groups
[klass
or 'miscellaneous']
188 # <option>s go in OPTIONS, unless class is specified
189 for xpath
, stor
in (('./varlistentry/term/varname', storvar
),
190 ('./varlistentry/term/option',
191 storvar
if klass
else storopt
)):
192 for name
in variablelist
.iterfind(xpath
):
193 text
= re
.sub(r
'([= ]).*', r
'\1', name
.text
).rstrip()
194 stor
[text
].append((pagename
, section
))
195 if text
not in formatting
:
196 # use element as formatted display
197 if name
.text
[-1] in '= ':
202 formatting
[text
] = name
204 storfile
= directive_groups
['filenames']
205 for xpath
, absolute_only
in (('.//refsynopsisdiv//filename', False),
206 ('.//refsynopsisdiv//command', False),
207 ('.//filename', True)):
208 for name
in t
.iterfind(xpath
):
209 if absolute_only
and not (name
.text
and name
.text
.startswith('/')):
211 if name
.attrib
.get('noindex'):
215 if name
.text
.endswith('*'):
216 name
.text
= name
.text
[:-1]
217 if not name
.text
.startswith('.'):
218 text
= name
.text
.partition(' ')[0]
219 if text
!= name
.text
:
222 if text
.endswith('/'):
224 storfile
[text
].append((pagename
, section
))
225 if text
not in formatting
:
226 # use element as formatted display
227 formatting
[text
] = name
229 text
= ' '.join(name
.itertext())
230 storfile
[text
].append((pagename
, section
))
231 formatting
[text
] = name
233 storfile
= directive_groups
['constants']
234 for name
in t
.iterfind('.//constant'):
235 if name
.attrib
.get('noindex'):
238 if name
.text
.startswith('('): # a cast, strip it
239 name
.text
= name
.text
.partition(' ')[2]
240 storfile
[name
.text
].append((pagename
, section
))
241 formatting
[name
.text
] = name
243 def _make_section(template
, name
, directives
, formatting
):
244 varlist
= template
.find(".//*[@id='{}']".format(name
))
245 for varname
, manpages
in sorted(directives
.items()):
246 entry
= tree
.SubElement(varlist
, 'varlistentry')
247 term
= tree
.SubElement(entry
, 'term')
248 display
= deepcopy(formatting
[varname
])
251 para
= tree
.SubElement(tree
.SubElement(entry
, 'listitem'), 'para')
254 for manpage
, manvolume
in sorted(set(manpages
)):
257 b
= tree
.SubElement(para
, 'citerefentry')
258 c
= tree
.SubElement(b
, 'refentrytitle')
260 d
= tree
.SubElement(b
, 'manvolnum')
264 def _make_colophon(template
, groups
):
269 for pagelist
in group
.values():
270 pages |
= set(pagelist
)
272 para
= template
.find(".//para[@id='colophon']")
273 para
.text
= COLOPHON
.format(count
=count
,
274 sections
=len(groups
),
277 def _make_page(template
, directive_groups
, formatting
):
278 """Create an XML tree from directive_groups.
281 'class': {'variable': [('manpage', 'manvolume'), ...],
286 for name
, directives
in directive_groups
.items():
287 _make_section(template
, name
, directives
, formatting
)
289 _make_colophon(template
, directive_groups
.values())
293 def make_page(*xml_files
):
294 "Extract directives from xml_files and return XML index tree."
295 template
= tree
.fromstring(TEMPLATE
)
296 names
= [vl
.get('id') for vl
in template
.iterfind('.//variablelist')]
297 directive_groups
= {name
:collections
.defaultdict(list)
300 for page
in xml_files
:
302 _extract_directives(directive_groups
, formatting
, page
)
304 raise ValueError("failed to process " + page
)
306 return _make_page(template
, directive_groups
, formatting
)
308 if __name__
== '__main__':
309 with
open(sys
.argv
[1], 'wb') as f
:
310 f
.write(xml_print(make_page(*sys
.argv
[2:])))