makedocs.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ########################################################################
  2. ##
  3. ## Win32 Usage: makepanda\makedocs.bat
  4. ## Linux Usage: makepanda/makedocs.py
  5. ##
  6. ########################################################################
  7. import sys,os,re
  8. sys.path = ["direct/src/directscripts"] + sys.path
  9. import gendocs
  10. ########################################################################
  11. ##
  12. ## Some handy utility functions.
  13. ##
  14. ########################################################################
  15. def MakeDirectory(path):
  16. if os.path.isdir(path): return 0
  17. os.mkdir(path)
  18. ########################################################################
  19. ##
  20. ## Read the version number from built/include/pandaVersion.h
  21. ##
  22. ########################################################################
  23. VERSION="0.0.0"
  24. try:
  25. f = file("built/include/pandaVersion.h","r")
  26. pattern = re.compile('^\s*[#]\s*define\s+PANDA_VERSION_STR\s+["]([0-9.]+)["]')
  27. for line in f:
  28. match = pattern.match(line,0)
  29. if (match):
  30. VERSION = match.group(1)
  31. break
  32. f.close()
  33. except: sys.exit("Cannot read version number from built/include/pandaVersion.h")
  34. print "Generating docs for "+VERSION
  35. ########################################################################
  36. ##
  37. ## Make sure panda has been built.
  38. ##
  39. ########################################################################
  40. if (os.path.isfile("built/pandac/input/libpgraph.in")==0) or (os.path.isfile("built/pandac/input/libputil.in")==0):
  41. sys.exit("Cannot read the interrogate-output files in built/pandac/input")
  42. ########################################################################
  43. ##
  44. ## Generate the PHP version.
  45. ##
  46. ## The manual is in the form of a bunch of HTML files that can be
  47. ## included by a PHP script called "/apiref.php".
  48. ##
  49. ########################################################################
  50. MakeDirectory("referphp")
  51. gendocs.generate(VERSION, "built/pandac/input", "direct", "referphp", "", "", "/apiref.php?page=", "")
  52. ########################################################################
  53. ##
  54. ## Generate the HTML version.
  55. ##
  56. ## The manual is in the form of a bunch of standalone HTML files
  57. ## that contain links to each other.
  58. ##
  59. ########################################################################
  60. HEADER = "<html><head></head><body>\n"
  61. FOOTER = "</body></html>\n"
  62. MakeDirectory("reference")
  63. gendocs.generate(VERSION, "built/pandac/input", "direct", "reference", HEADER, FOOTER, "", ".html")