libnl/doc/resolve-asciidoc-refs.py
Thomas Graf 50074732af more documentation updates
- improved stylesheets for both doxygen and asciidoc
 - use of xml doxygen layout
 - python script to resolve <<foo>> asciidoc references to
   <<foo, title>> based on the target caption
 - graphics for netlink and netlink error headers
 - more link documentation
2011-07-21 16:24:31 +02:00

25 lines
521 B
Python
Executable file

#!/usr/bin/env python
import fileinput
import re
import sys
refs = {}
complete_file = ""
for line in open(sys.argv[1], 'r'):
complete_file += line
for m in re.findall('\[\[(.+)\]\]\n=+ ([^\n]+)', complete_file):
ref, title = m
refs["<<" + ref + ">>"] = "<<" + ref + ", " + title + ">>"
def translate(match):
try:
return refs[match.group(0)]
except KeyError:
return ""
rc = re.compile('|'.join(map(re.escape, sorted(refs, reverse=True))))
for line in open(sys.argv[1], 'r'):
print rc.sub(translate, line),