chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
man: fix some typos
[elogind.git]
/
make-man-index.py
diff --git
a/make-man-index.py
b/make-man-index.py
index 2dbc2da995bf9d5ece4f1ff234be5ff189dc42eb..d9ab5cc7525f35222de6e0c0f4f7f004b465dfc0 100755
(executable)
--- a/
make-man-index.py
+++ b/
make-man-index.py
@@
-19,12
+19,18
@@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
import collections
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
import collections
-import xml.etree.ElementTree as tree
+try:
+ from lxml import etree as tree
+ PRETTY = dict(pretty_print=True)
+except ImportError:
+ import xml.etree.ElementTree as tree
+ PRETTY = {}
import sys
import sys
+import re
MDASH = ' — ' if sys.version_info.major >= 3 else ' -- '
TEMPLATE = '''\
MDASH = ' — ' if sys.version_info.major >= 3 else ' -- '
TEMPLATE = '''\
-<refentry id="systemd.index">
+<refentry id="systemd.index"
conditional="HAVE_PYTHON"
>
<refentryinfo>
<title>systemd.index</title>
<refentryinfo>
<title>systemd.index</title>
@@
-66,10
+72,16
@@
SUMMARY = '''\
COUNTS = '\
This index contains {count} entries, referring to {pages} individual manual pages.'
COUNTS = '\
This index contains {count} entries, referring to {pages} individual manual pages.'
+def check_id(page, t):
+ id = t.getroot().get('id')
+ if not re.search('/' + id + '[.]', page):
+ raise ValueError("id='{}' is not the same as page name '{}'".format(id, page))
+
def make_index(pages):
index = collections.defaultdict(list)
for p in pages:
t = tree.parse(p)
def make_index(pages):
index = collections.defaultdict(list)
for p in pages:
t = tree.parse(p)
+ check_id(p, t)
section = t.find('./refmeta/manvolnum').text
refname = t.find('./refnamediv/refname').text
purpose = ' '.join(t.find('./refnamediv/refpurpose').text.split())
section = t.find('./refmeta/manvolnum').text
refname = t.find('./refnamediv/refname').text
purpose = ' '.join(t.find('./refnamediv/refpurpose').text.split())
@@
-123,4
+135,4
@@
def make_page(xml_files):
return template
if __name__ == '__main__':
return template
if __name__ == '__main__':
- tree.dump(make_page(sys.argv[1:]))
+ tree.dump(make_page(sys.argv[1:])
, **PRETTY
)