From 34bc08f544f7745e99bdb9197c390701bdee5e4b Mon Sep 17 00:00:00 2001 From: lottaviano Date: Mon, 29 Jun 2009 09:24:00 +0000 Subject: [PATCH] doc: Add script to modify chm TOC. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2718 38d2e660-2303-0410-9eaa-f027e97ec537 --- doc/chm-toc-modifier.py | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 doc/chm-toc-modifier.py diff --git a/doc/chm-toc-modifier.py b/doc/chm-toc-modifier.py new file mode 100644 index 00000000..f6239c8c --- /dev/null +++ b/doc/chm-toc-modifier.py @@ -0,0 +1,44 @@ +from __future__ import with_statement +import sys, re + +if len(sys.argv) < 1: + print "Usage: " + sys.argv[0] + " [hhc index file] [output file]" + sys.exit(-1) + +outfile = "out.hhc" +if len(sys.argv) == 3: + outfile = sys.argv[2] + +data_structures = [] + +section_start = re.compile(r"
  • .*? value=\"((File List)|(Data Structures)|(Main Page)|(Directory Hierarchy))\".*$") + +data_section = False +file_section = False + +with open(sys.argv[1], "r") as f: + with open(outfile, "w+") as out: + for line in f: + if re.search(section_start, line): + if line.find("Data Structures") != -1: + data_section = True + file_section = False + elif line.find("File List") != -1: + data_section = False + file_section = True + else: + data_section = False + file_section = False + + if data_section: + data_structures.append(line) + elif file_section: + pass + elif re.search(r"^<\/UL>$", line): + for i in data_structures: + out.write(i) + out.write(line) + else: + out.write(line) + + -- 2.25.1