X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=make-man-rules.py;h=ad601f874f220015b7dad8af72a6df994577cb3c;hp=5415984d88e3f4c88e849d5954c76041a5f21bac;hb=d808ca6414cd29d56507bed78fce2d26c6b00f15;hpb=185c3be03cec26023acc11b49553753aa7330a1d diff --git a/make-man-rules.py b/make-man-rules.py index 5415984d8..ad601f874 100644 --- a/make-man-rules.py +++ b/make-man-rules.py @@ -18,10 +18,9 @@ # along with systemd; If not, see . from __future__ import print_function -import xml.etree.ElementTree as tree import collections import sys -import os +from xml_helper import * SECTION = '''\ MANPAGES += \\ @@ -29,6 +28,7 @@ MANPAGES += \\ MANPAGES_ALIAS += \\ {aliases} {rules} +{htmlrules} ''' CONDITIONAL = '''\ @@ -45,17 +45,16 @@ HEADER = '''\ ''' -CLEANFILES = '''\ - -CLEANFILES += \\ - {cleanfiles} +HTML_ALIAS_RULE = '''\ +{}.html: {}.html + $(html-alias) ''' def man(page, number): return 'man/{}.{}'.format(page, number) 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] @@ -83,7 +82,7 @@ def create_rules(*xml_files): def mjoin(files): return ' \\\n\t'.join(sorted(files) or '#') -def make_makefile(rules, cleanfiles): +def make_makefile(rules): return HEADER + '\n'.join( (CONDITIONAL if conditional else SECTION).format( manpages=mjoin(set(rulegroup.values())), @@ -91,14 +90,12 @@ def make_makefile(rules, cleanfiles): 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) - for conditional,rulegroup in sorted(rules.items())) + \ - CLEANFILES.format(cleanfiles=mjoin(cleanfiles)) + for conditional,rulegroup in sorted(rules.items())) if __name__ == '__main__': - sources = set(sys.argv[1:]) - basenames = [os.path.basename(source) for source in sources] - spares = set([source for source in sources - if os.path.basename(source) + '.in' in basenames]) - rules = create_rules(*(sources - spares)) - print(make_makefile(rules, spares), end='') + rules = create_rules(*sys.argv[1:]) + print(make_makefile(rules), end='')