1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
# Standard library imports.
import glob, os, shutil, sys
# The stylesheet used in the generated HTML.
STYLESHEET = 'rest'
# A template for the command that runs 'rst2html'.
COMMAND_TEMPLATE = """
rst2html --stylesheet=%s.css "%s" > "html/%s.html"
"""
def make_reST_docs(stylesheet):
""" Make the reST documentation. """
# Put all the generated documents in here.
try:
os.mkdir('html')
except:
pass
shutil.copyfile('%s.css' % stylesheet, 'html/%s.css' % stylesheet)
# Convert all text files (actually, reST documents!) into HTML.
for filename in glob.glob('*.txt'):
name, ext = os.path.splitext(filename)
print 'Processing %s...' % filename,
os.system(COMMAND_TEMPLATE % (stylesheet, filename, name))
print 'Done.'
return
def make_api_docs():
""" Make the API documentation. """
try:
os.makedirs('html/api')
except:
pass
# Now make the API documentation.
print 'Making API documentation...',
os.system('endo --rst -d html/api -r %s' % os.path.join('..', 'enthought'))
print 'Done.'
return
def copy_images():
""" Copy any images into the 'html' directory. """
# Copy over any images.
if os.path.isdir('images'):
print 'Copying images...',
try:
os.mkdir('html/images')
except:
pass
for filename in os.listdir('images'):
if filename == '.svn':
continue
shutil.copyfile('images/%s' % filename,'html/images/%s' % filename)
print 'Done.'
return
def create_index(filename):
""" Create the index.html. """
shutil.copyfile(os.path.join('html', filename+'.html'), 'html/index.html')
return
def main(argv=sys.argv):
""" Application entry point. """
# If an additional argument is specified then use it as tghe stylesheet
# name.
if len(argv) > 1:
stylesheet = argv[1]
else:
stylesheet = STYLESHEET
make_reST_docs(stylesheet)
make_api_docs()
copy_images()
create_index('Introduction')
return
if __name__ == '__main__':
main()
#### EOF ######################################################################
|