]>
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 *
26 <refentry id="systemd.directives" conditional="HAVE_PYTHON">
29 <title>systemd.directives</title>
30 <productname>systemd</productname>
34 <contrib>Developer</contrib>
35 <firstname>Zbigniew</firstname>
36 <surname>Jędrzejewski-Szmek</surname>
37 <email>zbyszek@in.waw.pl</email>
43 <refentrytitle>systemd.directives</refentrytitle>
44 <manvolnum>7</manvolnum>
48 <refname>systemd.directives</refname>
49 <refpurpose>Index of configuration directives</refpurpose>
53 <title>Unit directives</title>
55 <para>Directives for configuring units, used in unit
58 <variablelist id='unit-directives' />
62 <title>Options on the kernel command line</title>
64 <para>Kernel boot options for configuring the behaviour of the
65 systemd process.</para>
67 <variablelist id='kernel-commandline-options' />
71 <title>Environment variables</title>
73 <para>Environment variables understood by the systemd
74 manager and other programs.</para>
76 <variablelist id='environment-variables' />
80 <title>UDEV directives</title>
82 <para>Directives for configuring systemd units through the
85 <variablelist id='udev-directives' />
89 <title>Journal fields</title>
91 <para>Fields in the journal events with a well known meaning.</para>
93 <variablelist id='journal-directives' />
97 <title>PAM configuration directives</title>
99 <para>Directives for configuring PAM behaviour.</para>
101 <variablelist id='pam-directives' />
105 <title>crypttab options</title>
107 <para>Options which influence mounted filesystems and
108 encrypted volumes.</para>
110 <variablelist id='crypttab-options' />
114 <title>System manager directives</title>
116 <para>Directives for configuring the behaviour of the
117 systemd process.</para>
119 <variablelist id='systemd-directives' />
123 <title>bootchart.conf directives</title>
125 <para>Directives for configuring the behaviour of the
126 systemd-bootchart process.</para>
128 <variablelist id='bootchart-directives' />
132 <title>command-line options</title>
134 <para>Command-line options accepted by programs in the
135 systemd suite.</para>
137 <variablelist id='options' />
141 <title>Miscellaneous options and directives</title>
143 <para>Other configuration elements which don't fit in
144 any of the above groups.</para>
146 <variablelist id='miscellaneous' />
150 <title>Files and directories</title>
152 <para>Paths and file names referred to in the
153 documentation.</para>
155 <variablelist id='filenames' />
159 <title>Colophon</title>
160 <para id='colophon' />
166 This index contains {count} entries in {sections} sections,
167 referring to {pages} individual manual pages.
170 def _extract_directives(directive_groups
, formatting
, page
):
172 section
= t
.find('./refmeta/manvolnum').text
173 pagename
= t
.find('./refmeta/refentrytitle').text
175 storopt
= directive_groups
['options']
176 for variablelist
in t
.iterfind('.//variablelist'):
177 klass
= variablelist
.attrib
.get('class')
178 storvar
= directive_groups
[klass
or 'miscellaneous']
179 # <option>s go in OPTIONS, unless class is specified
180 for xpath
, stor
in (('./varlistentry/term/varname', storvar
),
181 ('./varlistentry/term/option',
182 storvar
if klass
else storopt
)):
183 for name
in variablelist
.iterfind(xpath
):
184 text
= re
.sub(r
'([= ]).*', r
'\1', name
.text
).rstrip()
185 stor
[text
].append((pagename
, section
))
186 if text
not in formatting
:
187 # use element as formatted display
188 if name
.text
[-1] in '= ':
193 formatting
[text
] = name
195 storfile
= directive_groups
['filenames']
196 for xpath
in ('.//refsynopsisdiv//filename',
197 './/refsynopsisdiv//command'):
198 for name
in t
.iterfind(xpath
):
201 if not name
.text
.startswith('.'):
202 text
= name
.text
.partition(' ')[0]
203 if text
!= name
.text
:
206 storfile
[text
].append((pagename
, section
))
207 if text
not in formatting
:
208 # use element as formatted display
209 formatting
[text
] = name
211 text
= ' '.join(name
.itertext())
212 storfile
[text
].append((pagename
, section
))
213 formatting
[text
] = name
215 def _make_section(template
, name
, directives
, formatting
):
216 varlist
= template
.find(".//*[@id='{}']".format(name
))
217 for varname
, manpages
in sorted(directives
.items()):
218 entry
= tree
.SubElement(varlist
, 'varlistentry')
219 term
= tree
.SubElement(entry
, 'term')
220 term
.append(formatting
[varname
])
222 para
= tree
.SubElement(tree
.SubElement(entry
, 'listitem'), 'para')
225 for manpage
, manvolume
in sorted(set(manpages
)):
228 b
= tree
.SubElement(para
, 'citerefentry')
229 c
= tree
.SubElement(b
, 'refentrytitle')
231 d
= tree
.SubElement(b
, 'manvolnum')
235 def _make_colophon(template
, groups
):
240 for pagelist
in group
.values():
241 pages |
= set(pagelist
)
243 para
= template
.find(".//para[@id='colophon']")
244 para
.text
= COLOPHON
.format(count
=count
,
245 sections
=len(groups
),
248 def _make_page(template
, directive_groups
, formatting
):
249 """Create an XML tree from directive_groups.
252 'class': {'variable': [('manpage', 'manvolume'), ...],
257 for name
, directives
in directive_groups
.items():
258 _make_section(template
, name
, directives
, formatting
)
260 _make_colophon(template
, directive_groups
.values())
264 def make_page(*xml_files
):
265 "Extract directives from xml_files and return XML index tree."
266 template
= tree
.fromstring(TEMPLATE
)
267 names
= [vl
.get('id') for vl
in template
.iterfind('.//variablelist')]
268 directive_groups
= {name
:collections
.defaultdict(list)
271 for page
in xml_files
:
273 _extract_directives(directive_groups
, formatting
, page
)
275 raise ValueError("failed to process " + page
)
277 return _make_page(template
, directive_groups
, formatting
)
279 if __name__
== '__main__':
280 with
open(sys
.argv
[1], 'wb') as f
:
281 f
.write(xml_print(make_page(*sys
.argv
[2:])))