From 8af65bfe45f1044ba839cbaa1cf4e1bfb3512fd1 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 15 Nov 2008 11:53:28 +0000 Subject: [PATCH] Added tools for generating CHM files --- doc/makepanda/makechm.bat | 26 ++++ doc/makepanda/makechm.py | 277 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 303 insertions(+) create mode 100755 doc/makepanda/makechm.bat create mode 100755 doc/makepanda/makechm.py diff --git a/doc/makepanda/makechm.bat b/doc/makepanda/makechm.bat new file mode 100755 index 0000000000..05e3e62fcf --- /dev/null +++ b/doc/makepanda/makechm.bat @@ -0,0 +1,26 @@ +@echo off + +REM +REM Verify that we can find the 'makechm' python script +REM and the python interpreter. If we can find both, then +REM run 'makechm'. +REM + +if not exist makepanda\makechm.py goto :missing1 +if not exist thirdparty\win-python\python.exe goto :missing2 +thirdparty\win-python\python.exe makepanda\makechm.py %* +goto done + +:missing1 + echo You need to change directory to the root of the panda source tree + echo before invoking makechm. + goto done + +:missing2 + echo You seem to be missing the 'thirdparty' directory. You probably checked + echo the source code out from sourceforge. The sourceforge repository is + echo missing the 'thirdparty' directory. You will need to supplement the + echo code by downloading the 'thirdparty' directory from panda3d.etc.cmu.edu + goto done + +:done diff --git a/doc/makepanda/makechm.py b/doc/makepanda/makechm.py new file mode 100755 index 0000000000..89a2e4eb9c --- /dev/null +++ b/doc/makepanda/makechm.py @@ -0,0 +1,277 @@ +######################################################################## +## +## Win32 Usage: makepanda\makechm.bat +## Linux Usage: makepanda/makechm.py +## +## To use this script, you will need to have hhc.exe on your system. +## For verbose output, run with -v or --verbose option. +## To keep the temporary .hhc, .hhk, .hhp, .chw files use -k or --keep. +## +## You can also import this file as a python module. You will then have +## access to three functions: makeCHM, makeManualCHM, makeReferenceCHM. +## This is how you call them: +## makeCHM(outputfile, dirname, title) +## where outputfile is the filename where the .chm file will be written, +## and dirname is the directory containing the html files to include. +## Title will be the title of the CHM file. +## The functions makeManualCHM and makeReferenceCHM work exactly the +## same, except that they work with a structure resembling that of the +## Panda3D manual and reference, respectively. +## Note: outputfile should not contain spaces. +## +######################################################################## + +__all__ = ["makeCHM", "makeManualCHM", "makeReferenceCHM"] +import os, re +from sys import exit +import xml.dom.minidom +from xml.dom.minidom import Node + +VERBOSE = False +KEEPTEMP = False + +if __name__ == "__main__": + from sys import argv + VERBOSE = ("-v" in argv) or ("-vk" in argv) or ("-kv" in argv) or ("--verbose" in argv) + KEEPTEMP = ("-k" in argv) or ("-kv" in argv) or ("-vk" in argv) or ("--keep" in argv) + +OPTIONBLOCK = """ +Binary TOC=Yes +Compatibility=1.1 or later +Compiled file=%s +Contents file=%s.hhc +Default Font=Arial,10,0 +Default topic=%s +Display compile progress=VERBOSE +Full-text search=Yes +Index file=%s.hhk +Language=0x409 English (United States) +Title=%s""".replace("VERBOSE", VERBOSE and "Yes" or "No") + +HTMLBLOCK = """ + + + + + + + + + + +