Update preset.
[bertos.git] / doc / chm-builder.py
1 """
2 To be used on windows platform only to generate BeRTOS .chm documentation.
3 Requires doxygen.exe and hhc.exe to be in the system PATH.
4 """
5 from __future__ import with_statement
6 import os, sys
7
8 def move(old_path, new_path):
9     if os.path.exists(new_path):
10         os.unlink(new_path)
11     os.rename(old_path, new_path)
12
13
14 if sys.platform != 'win32':
15     print "This program can be run only on a Windows machine"
16     sys.exit(-1)
17
18 if len(sys.argv) < 2:
19     print "Usage: " + sys.argv[0] + " [custom_doxyfile]"
20     sys.exit(-1)
21
22 DOC_PATH = 'doc\\offline-reference\\html\\'
23 toc_modifier = r"doc\chm-toc-modifier.py"
24 toc_file = DOC_PATH + r"index.hhc"
25 bertos_toc = r"bertos-toc.hhc"
26
27
28 if os.system("doxygen " + sys.argv[1]):
29     print "doxygen error"
30 if os.system(toc_modifier + " " + toc_file + " " + bertos_toc):
31     print "toc-modifier error"
32 move(bertos_toc, toc_file)
33
34 # compile CHM
35 os.system(r"hhc " + DOC_PATH + "index.hhp")
36
37 chm_target = r"bertos\bertos-doc.chm"
38 move(DOC_PATH + r"bertos-doc.chm", chm_target)
39
40