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