#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
import sys
import collections
import re
from xml_helper import xml_parse, xml_print, tree
from copy import deepcopy
TEMPLATE = '''\
systemd.directivessystemdsystemd.directives7systemd.directivesIndex of configuration directivesUnit directivesDirectives for configuring units, used in unit
files.Options on the kernel command lineKernel boot options for configuring the behaviour of the
systemd process.Environment variablesEnvironment variables understood by the systemd manager
and other programs and environment variable-compatible settings.UDEV directivesDirectives for configuring systemd units through the
udev database.Network directivesDirectives for configuring network links through the
net-setup-link udev builtin and networks through
systemd-networkd.Journal fieldsFields in the journal events with a well known meaning.PAM configuration directivesDirectives for configuring PAM behaviour./etc/crypttab and
/etc/fstab optionsOptions which influence mounted filesystems and
encrypted volumes.Program configuration optionsDirectives for configuring the behaviour of the
systemd process and other tools through configuration files.command line optionsCommand-line options accepted by programs in the
systemd suite.ConstantsVarious constant used and/or defined by systemd.Miscellaneous options and directivesOther configuration elements which don't fit in
any of the above groups.Files and directoriesPaths and file names referred to in the
documentation.Colophon
'''
COLOPHON = '''\
This index contains {count} entries in {sections} sections,
referring to {pages} individual manual pages.
'''
def _extract_directives(directive_groups, formatting, page):
t = xml_parse(page)
section = t.find('./refmeta/manvolnum').text
pagename = t.find('./refmeta/refentrytitle').text
storopt = directive_groups['options']
for variablelist in t.iterfind('.//variablelist'):
klass = variablelist.attrib.get('class')
storvar = directive_groups[klass or 'miscellaneous']
#