diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-02-13 21:51:31 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-02-13 23:09:00 -0500 |
commit | a4e0b94d318e35b1441fc56f590668e80ff2e44e (patch) | |
tree | 1c1fdcf0587b2be55d326d149b12f0dfeeebdd15 /make-directive-index.py | |
parent | 895aeb27795c00f365ce3b30b1dca549b4f5468e (diff) |
man: add filenames to the index
Limiting the addition to filenames from <refsynopsis>
seems to give a good enough S/N ratio.
Diffstat (limited to 'make-directive-index.py')
-rwxr-xr-x | make-directive-index.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/make-directive-index.py b/make-directive-index.py index b06a54c1d5..15bd9b9341 100755 --- a/make-directive-index.py +++ b/make-directive-index.py @@ -147,6 +147,15 @@ TEMPLATE = '''\ </refsect1> <refsect1> + <title>Files and directories</title> + + <para>Paths and file names referred to in the + documentation.</para> + + <variablelist id='filenames' /> + </refsect1> + + <refsect1> <title>Colophon</title> <para id='colophon' /> </refsect1> @@ -162,10 +171,11 @@ def _extract_directives(directive_groups, formatting, page): t = tree.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'] - storopt = directive_groups['options'] # <option>s go in OPTIONS, unless class is specified for xpath, stor in (('./varlistentry/term/varname', storvar), ('./varlistentry/term/option', @@ -179,6 +189,26 @@ def _extract_directives(directive_groups, formatting, page): name.text = text formatting[text] = name + storfile = directive_groups['filenames'] + for xpath in ('.//refsynopsisdiv//filename', + './/refsynopsisdiv//command'): + for name in t.iterfind(xpath): + name.tail = '' + if name.text: + if not name.text.startswith('.'): + text = name.text.partition(' ')[0] + if text != name.text: + name.clear() + name.text = text + storfile[text].append((pagename, section)) + if text not in formatting: + # use element as formatted display + formatting[text] = name + else: + text = ' '.join(name.itertext()) + storfile[text].append((pagename, section)) + formatting[text] = name + def _make_section(template, name, directives, formatting): varlist = template.find(".//*[@id='{}']".format(name)) for varname, manpages in sorted(directives.items()): |