diff options
author | Thomas Haller <thaller@redhat.com> | 2014-06-25 11:45:16 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-25 12:35:45 +0200 |
commit | 940e5d5446a04d6228ea5fad2ac1f9ed4cf109a7 (patch) | |
tree | 868f29f2e02d0053935a2848168fddac970f4b7b /doc | |
parent | 853c045adaf03196e336a6f444242c986c39bb68 (diff) | |
download | libnl-940e5d5446a04d6228ea5fad2ac1f9ed4cf109a7.tar.gz |
doc: fix doxygen-link.py by skipping invalid entries in libnl.dict
Newer versions of doxygen (on Fedora20) treat the documentation
slightly different so that the following entires end up in
libnl.dict:
\=api/group__attr.html#ga769cc7bd882aab17c3740dd83329d7e6
»·······»·······NLA_PUT=api/group__attr.html#ga769cc7bd882aab17c3740dd83329d7e6
NLA_PUT=api/group__attr.html#ga769cc7bd882aab17c3740dd83329d7e6
Especially, replacing r'\' breaks the generated html documentation.
Extend doxygen-link.py to strip whitespaces from the name and
skip over r'\'.
Also, when replacing the words in the output file, match them
using word boundaries r'\b'.
Also, don't print an additional newline after each processed line.
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'doc')
-rwxr-xr-x | doc/doxygen-link.py | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/doc/doxygen-link.py b/doc/doxygen-link.py index a1596d6f..910b8f8d 100755 --- a/doc/doxygen-link.py +++ b/doc/doxygen-link.py @@ -1,20 +1,43 @@ #!/usr/bin/env python +from __future__ import print_function import fileinput import re import sys -links = {} -for line in open(sys.argv[1], 'r'): - m = re.match('^([^=]+)=([^\n]+)$', line); - if m: - link = "<a href=\"" + m.group(2) + "\" class=\"dg\">" + m.group(1) + "</a>" - links[m.group(1)] = link +rc_script = re.compile(r'\s*(.*\S)?\s*') + +def parse_dict(filename): + links = {} + for line in open(filename, 'r'): + m = re.match('^([^=]+)=([^\n]+)$', line); + if not m: + continue + name = m.group(1) + value = m.group(2) + + # strip leading and trailing whitespace + m = rc_script.match(name) + if m: + name = m.group(1) + + # skip special names + if name == '': + continue + if name == '\\': + continue + + links[name] = "<a href=\"" + value + "\" class=\"dg\">" + name + "</a>" + return links + +links = parse_dict(sys.argv[1]) def translate(match): - return links[match.group(0)] + return links[match.group(1)] + +# match for all names, with word boundaries \b +rc = re.compile(r'\b(' + '|'.join(map(re.escape, sorted(links, reverse=True))) + r')\b') -rc = re.compile('|'.join(map(re.escape, sorted(links, reverse=True)))) for line in open(sys.argv[2], 'r'): - print(rc.sub(translate, line)) + print(rc.sub(translate, line), end='') |