chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
service: allow KillMode=mixed in conjunction with PAMName=
[elogind.git]
/
make-man-rules.py
diff --git
a/make-man-rules.py
b/make-man-rules.py
index b88b43ac3d2a6b02f1e2222c834e7dec67aefde6..0d1ca244c467d0b8bba7fdd85d42bc0f9703eee9 100644
(file)
--- a/
make-man-rules.py
+++ b/
make-man-rules.py
@@
-18,9
+18,10
@@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
-import xml.etree.ElementTree as tree
import collections
import sys
import collections
import sys
+import os.path
+from xml_helper import *
SECTION = '''\
MANPAGES += \\
SECTION = '''\
MANPAGES += \\
@@
-28,6
+29,7
@@
MANPAGES += \\
MANPAGES_ALIAS += \\
{aliases}
{rules}
MANPAGES_ALIAS += \\
{aliases}
{rules}
+{htmlrules}
'''
CONDITIONAL = '''\
'''
CONDITIONAL = '''\
@@
-40,15
+42,29
@@
endif
HEADER = '''\
# Do not edit. Generated by make-man-rules.py.
HEADER = '''\
# Do not edit. Generated by make-man-rules.py.
-# Regenerate with 'make update-man-list'.
+# Regenerate with 'make
all
update-man-list'.
'''
'''
+HTML_ALIAS_RULE = '''\
+{}.html: {}.html
+ $(html-alias)
+'''
+
+FOOTER = '''\
+
+EXTRA_DIST += \\
+ {files}
+'''
+
def man(page, number):
return 'man/{}.{}'.format(page, number)
def man(page, number):
return 'man/{}.{}'.format(page, number)
+def xml(file):
+ return 'man/{}'.format(os.path.basename(file))
+
def add_rules(rules, name):
def add_rules(rules, name):
- xml =
tree.
parse(name)
+ xml =
xml_
parse(name)
# print('parsing {}'.format(name), file=sys.stderr)
conditional = xml.getroot().get('conditional') or ''
rulegroup = rules[conditional]
# print('parsing {}'.format(name), file=sys.stderr)
conditional = xml.getroot().get('conditional') or ''
rulegroup = rules[conditional]
@@
-66,7
+82,7
@@
def add_rules(rules, name):
rulegroup[alias] = target
# print('{} => {} [{}]'.format(alias, target, conditional), file=sys.stderr)
rulegroup[alias] = target
# print('{} => {} [{}]'.format(alias, target, conditional), file=sys.stderr)
-def create_rules(
*
xml_files):
+def create_rules(xml_files):
" {conditional => {alias-name => source-name}} "
rules = collections.defaultdict(dict)
for name in xml_files:
" {conditional => {alias-name => source-name}} "
rules = collections.defaultdict(dict)
for name in xml_files:
@@
-76,7
+92,7
@@
def create_rules(*xml_files):
def mjoin(files):
return ' \\\n\t'.join(sorted(files) or '#')
def mjoin(files):
return ' \\\n\t'.join(sorted(files) or '#')
-def make_makefile(rules):
+def make_makefile(rules
, files
):
return HEADER + '\n'.join(
(CONDITIONAL if conditional else SECTION).format(
manpages=mjoin(set(rulegroup.values())),
return HEADER + '\n'.join(
(CONDITIONAL if conditional else SECTION).format(
manpages=mjoin(set(rulegroup.values())),
@@
-84,9
+100,14
@@
def make_makefile(rules):
rules='\n'.join('{}: {}'.format(k,v)
for k,v in sorted(rulegroup.items())
if k != v),
rules='\n'.join('{}: {}'.format(k,v)
for k,v in sorted(rulegroup.items())
if k != v),
+ htmlrules='\n'.join(HTML_ALIAS_RULE.format(k[:-2],v[:-2])
+ for k,v in sorted(rulegroup.items())
+ if k != v),
conditional=conditional)
conditional=conditional)
- for conditional,rulegroup in sorted(rules.items()))
+ for conditional,rulegroup in sorted(rules.items())
+ ) + FOOTER.format(files=mjoin(sorted(files)))
if __name__ == '__main__':
if __name__ == '__main__':
- rules = create_rules(*sys.argv[1:])
- print(make_makefile(rules), end='')
+ rules = create_rules(sys.argv[1:])
+ files = (xml(file) for file in sys.argv[1:])
+ print(make_makefile(rules, files), end='')