From fb1663c8181639f49387234f8f4abd5df3d7cc5a Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 8 May 2012 12:03:21 +0200 Subject: Add scripts to generate hyperlinked source in HTML. --- scripts/tohtml.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 scripts/tohtml.py (limited to 'scripts/tohtml.py') diff --git a/scripts/tohtml.py b/scripts/tohtml.py new file mode 100644 index 00000000..6ad22ecd --- /dev/null +++ b/scripts/tohtml.py @@ -0,0 +1,66 @@ +import sys, os, re + +HEADER=""" + + +
"""
+
+FOOTER="""
""" + +prefixes = [ 'fz_', 'pdf_', 'xps_', 'cbz_', 'pdfapp_' ] + +def is_public(s): + for prefix in prefixes: + if s.startswith(prefix): + return True + return False + +def load_tags(): + tags = {} + for line in open("tags-xref").readlines(): + ident, type, line, file, text = line.split(None, 4) + if not is_public(ident): + continue + if type == 'function': + tags[ident] = '%s' % (os.path.basename(file), line, ident) + if type == 'typedef' or type == 'struct': + tags[ident] = '%s' % (os.path.basename(file), line, ident) + return tags + +tags = load_tags() + +def quote(s): + return s.replace('&','&').replace('<','<').replace('>','>') + +print HEADER + +N = 1 +for line in sys.stdin.readlines(): + # expand tabs, html-quote special characters and colorize comments + line = line.replace('\t', ' ').rstrip() + line = quote(line) + line = line.replace("/*", '/*') + line = line.replace("*/", '*/') + + line = re.sub('^#include "([a-z-]*\.h)"', '#include "\\1"', line) + + # find identifiers and hyperlink to their definitions + words = re.split("(\W+)", line) + line = "" + for word in words: + if word in tags: + word = tags[word] + line += word + + #print('%4d %s' % (N, N, line)) + print('%s' % (N, line)) + + N = N + 1 + +print FOOTER -- cgit v1.2.3