make-man-rules.py revision e4f42f9d1eb609a515ad1434512d5ad3d96c9b72
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# Copyright 2013 Zbigniew Jędrzejewski-Szmek
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# along with systemd; If not, see <http://www.gnu.org/licenses/>.
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom GundersenMANPAGES_ALIAS += \\
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenif {conditional}
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# Do not edit. Generated by make-man-rules.py.
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering# To regenerate:
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering# 1. Create, update, or remove source .xml files in man/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# 2. Run 'make update-man-list'
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering# 3. Run 'make man' to generate manpages
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# To make a man page conditional on a configure switch add
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering# attribute conditional="ENABLE_WHAT" or conditional="WITH_WHAT"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering# to <refentry> element.
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering{}.html: {}.html
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering# Really, do not edit this file.
eed857b71702f8551b46b66b31fa0d08583cf23cLennart PoetteringEXTRA_DIST += \\
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poettering return 'man/{}'.format(os.path.basename(file))
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering # print('parsing {}'.format(name), file=sys.stderr)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering conditional = xml.getroot().get('conditional') or ''
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering title = refmeta.find('./refentrytitle').text
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering number = refmeta.find('./manvolnum').text
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering refnames = xml.findall('./refnamediv/refname')
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering raise ValueError('refmeta and refnamediv disagree: ' + name)
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering for group in rules.values()), "duplicate page name"
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering # print('{} => {} [{}]'.format(alias, target, conditional), file=sys.stderr)
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering " {conditional => {alias-name => source-name}} "
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering print("Failed to process", name, file=sys.stderr)
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering return ' \\\n\t'.join(sorted(files) or '#')
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering (CONDITIONAL if conditional else SECTION).format(
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering aliases=mjoin(k for k,v in rulegroup.items() if k != v),
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering htmlrules='\n'.join(HTML_ALIAS_RULE.format(k[:-2],v[:-2])
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering for conditional,rulegroup in sorted(rules.items())
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen ) + FOOTER.format(dist_files=mjoin(sorted(dist_files)))
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen dist_files = (xml(file) for file in sys.argv[1:]