| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
usageHelp = r"""generate-docutils-output.py --file-base=<FILEBASE> [options] |
| 4 |
|
| 5 |
Create output files for DocUtils reStructuredText. |
| 6 |
|
| 7 |
This simple script can be used to generate HTML, Latex, and PDF output for a |
| 8 |
given <outputFileBase>.rst file. What output is generated is controlled by |
| 9 |
the options --generate-html, --generate-latex, and --generate-pdf. This |
| 10 |
requires that the Docutils commands be installed on the system as well as |
| 11 |
latex (if generating PDF output). |
| 12 |
|
| 13 |
NOTE: The right default programs for --generate-html, --generate-latex, and |
| 14 |
--generate-pdf will try to be chosen for given system automatically. |
| 15 |
""" |
| 16 |
|
| 17 |
import sys |
| 18 |
import os |
| 19 |
from optparse import OptionParser |
| 20 |
|
| 21 |
# |
| 22 |
# A) Set up basic paths and import modules |
| 23 |
# |
| 24 |
|
| 25 |
thisFilePath = __file__ |
| 26 |
thisFileRealAbsBasePath = \ |
| 27 |
os.path.dirname(os.path.abspath(os.path.realpath(thisFilePath))) |
| 28 |
#print("thisFileRealAbsBasePath = '" + thisFileRealAbsBasePath + "'") |
| 29 |
|
| 30 |
tribitsBaseDir = os.path.abspath(os.path.join(thisFileRealAbsBasePath, '..')) |
| 31 |
|
| 32 |
sys.path.append(os.path.join(tribitsBaseDir, 'python')) |
| 33 |
#print("sys.path = " + str(sys.path)) |
| 34 |
|
| 35 |
|
| 36 |
from GenerateDocUtilsOutput import * |
| 37 |
|
| 38 |
# |
| 39 |
# B) Read in the commandline options |
| 40 |
# |
| 41 |
|
| 42 |
clp = OptionParser(usage=usageHelp) |
| 43 |
|
| 44 |
addCmndLineOptions(clp) |
| 45 |
|
| 46 |
(options, args) = clp.parse_args(sys.argv) |
| 47 |
|
| 48 |
if not options.fileBase: |
| 49 |
print("Error, --file-base=<fileBase> must be specified!") |
| 50 |
sys.exit(1) |
| 51 |
|
| 52 |
# |
| 53 |
# C) Generate the output files |
| 54 |
# |
| 55 |
|
| 56 |
generateDocutilsOuputFiles(options) |