]>
git.ipfire.org Git - thirdparty/systemd.git/blob - tools/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><filename>/etc/crypttab</filename> and
117 <filename>/etc/fstab</filename> options</title>
119 <para>Options which influence mounted filesystems and
120 encrypted volumes.</para>
122 <variablelist id='fstab-options' />
126 <title>System manager directives</title>
128 <para>Directives for configuring the behaviour of the
129 systemd process.</para>
131 <variablelist id='systemd-directives' />
135 <title>command line options</title>
137 <para>Command-line options accepted by programs in the
138 systemd suite.</para>
140 <variablelist id='options' />
144 <title>Constants</title>
146 <para>Various constant used and/or defined by systemd.</para>
148 <variablelist id='constants' />
152 <title>Miscellaneous options and directives</title>
154 <para>Other configuration elements which don't fit in
155 any of the above groups.</para>
157 <variablelist id='miscellaneous' />
161 <title>Files and directories</title>
163 <para>Paths and file names referred to in the
164 documentation.</para>
166 <variablelist id='filenames' />
170 <title>Colophon</title>
171 <para id='colophon' />
177 This index contains {count} entries in {sections} sections,
178 referring to {pages} individual manual pages.
181 def _extract_directives(directive_groups
, formatting
, page
):
183 section
= t
.find('./refmeta/manvolnum').text
184 pagename
= t
.find('./refmeta/refentrytitle').text
186 storopt
= directive_groups
['options']
187 for variablelist
in t
.iterfind('.//variablelist'):
188 klass
= variablelist
.attrib
.get('class')
189 storvar
= directive_groups
[klass
or 'miscellaneous']
190 # <option>s go in OPTIONS, unless class is specified
191 for xpath
, stor
in (('./varlistentry/term/varname', storvar
),
192 ('./varlistentry/term/option',
193 storvar
if klass
else storopt
)):
194 for name
in variablelist
.iterfind(xpath
):
195 text
= re
.sub(r
'([= ]).*', r
'\1', name
.text
).rstrip()
196 stor
[text
].append((pagename
, section
))
197 if text
not in formatting
:
198 # use element as formatted display
199 if name
.text
[-1] in '= ':
204 formatting
[text
] = name
206 storfile
= directive_groups
['filenames']
207 for xpath
, absolute_only
in (('.//refsynopsisdiv//filename', False),
208 ('.//refsynopsisdiv//command', False),
209 ('.//filename', True)):
210 for name
in t
.iterfind(xpath
):
211 if absolute_only
and not (name
.text
and name
.text
.startswith('/')):
213 if name
.attrib
.get('noindex'):
217 if name
.text
.endswith('*'):
218 name
.text
= name
.text
[:-1]
219 if not name
.text
.startswith('.'):
220 text
= name
.text
.partition(' ')[0]
221 if text
!= name
.text
:
224 if text
.endswith('/'):
226 storfile
[text
].append((pagename
, section
))
227 if text
not in formatting
:
228 # use element as formatted display
229 formatting
[text
] = name
231 text
= ' '.join(name
.itertext())
232 storfile
[text
].append((pagename
, section
))
233 formatting
[text
] = name
235 storfile
= directive_groups
['constants']
236 for name
in t
.iterfind('.//constant'):
237 if name
.attrib
.get('noindex'):
240 if name
.text
.startswith('('): # a cast, strip it
241 name
.text
= name
.text
.partition(' ')[2]
242 storfile
[name
.text
].append((pagename
, section
))
243 formatting
[name
.text
] = name
245 def _make_section(template
, name
, directives
, formatting
):
246 varlist
= template
.find(".//*[@id='{}']".format(name
))
247 for varname
, manpages
in sorted(directives
.items()):
248 entry
= tree
.SubElement(varlist
, 'varlistentry')
249 term
= tree
.SubElement(entry
, 'term')
250 display
= deepcopy(formatting
[varname
])
253 para
= tree
.SubElement(tree
.SubElement(entry
, 'listitem'), 'para')
256 for manpage
, manvolume
in sorted(set(manpages
)):
259 b
= tree
.SubElement(para
, 'citerefentry')
260 c
= tree
.SubElement(b
, 'refentrytitle')
262 c
.attrib
['target'] = varname
263 d
= tree
.SubElement(b
, 'manvolnum')
267 def _make_colophon(template
, groups
):
272 for pagelist
in group
.values():
273 pages |
= set(pagelist
)
275 para
= template
.find(".//para[@id='colophon']")
276 para
.text
= COLOPHON
.format(count
=count
,
277 sections
=len(groups
),
280 def _make_page(template
, directive_groups
, formatting
):
281 """Create an XML tree from directive_groups.
284 'class': {'variable': [('manpage', 'manvolume'), ...],
289 for name
, directives
in directive_groups
.items():
290 _make_section(template
, name
, directives
, formatting
)
292 _make_colophon(template
, directive_groups
.values())
296 def make_page(*xml_files
):
297 "Extract directives from xml_files and return XML index tree."
298 template
= tree
.fromstring(TEMPLATE
)
299 names
= [vl
.get('id') for vl
in template
.iterfind('.//variablelist')]
300 directive_groups
= {name
:collections
.defaultdict(list)
303 for page
in xml_files
:
305 _extract_directives(directive_groups
, formatting
, page
)
307 raise ValueError("failed to process " + page
)
309 return _make_page(template
, directive_groups
, formatting
)
311 if __name__
== '__main__':
312 with
open(sys
.argv
[1], 'wb') as f
:
313 f
.write(xml_print(make_page(*sys
.argv
[2:])))