diff options
Diffstat (limited to 'docutils/tools')
| -rwxr-xr-x | docutils/tools/html.py | 31 | ||||
| -rwxr-xr-x | docutils/tools/publish.py | 27 | ||||
| -rwxr-xr-x | docutils/tools/quicktest.py | 185 | ||||
| -rw-r--r-- | docutils/tools/stylesheets/default.css | 157 |
4 files changed, 0 insertions, 400 deletions
diff --git a/docutils/tools/html.py b/docutils/tools/html.py deleted file mode 100755 index 66f029364..000000000 --- a/docutils/tools/html.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -""" -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - -A minimal front-end to the Docutils Publisher. - -This module takes advantage of the default values defined in `publish()`. -""" - -import sys -from docutils.core import publish -from docutils import utils - -reporter = utils.Reporter(2, 4) -#reporter.setconditions('nodes.Node.walkabout', 2, 4, debug=1) - -if len(sys.argv) == 2: - publish(writername='html', source=sys.argv[1], reporter=reporter) -elif len(sys.argv) == 3: - publish(writername='html', source=sys.argv[1], destination=sys.argv[2], - reporter=reporter) -elif len(sys.argv) > 3: - print >>sys.stderr, 'Maximum 2 arguments allowed.' - sys.exit(1) -else: - publish() diff --git a/docutils/tools/publish.py b/docutils/tools/publish.py deleted file mode 100755 index 539548911..000000000 --- a/docutils/tools/publish.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python - -""" -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - -A minimal front-end to the Docutils Publisher. - -This module takes advantage of the default values defined in `publish()`. -""" - -import sys -from docutils.core import publish - - -if len(sys.argv) == 2: - publish(source=sys.argv[1]) -elif len(sys.argv) == 3: - publish(source=sys.argv[1], destination=sys.argv[2]) -elif len(sys.argv) > 3: - print >>sys.stderr, 'Maximum 2 arguments allowed.' - sys.exit(1) -else: - publish() diff --git a/docutils/tools/quicktest.py b/docutils/tools/quicktest.py deleted file mode 100755 index df295f66a..000000000 --- a/docutils/tools/quicktest.py +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env python - -""" -:Author: Garth Kidd -:Contact: garth@deadlybloodyserious.com -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. -""" - -import sys, os, getopt -import docutils.utils -from docutils.parsers.rst import Parser - - -usage_header = """\ -quicktest.py: quickly test the restructuredtext parser. - -Usage:: - - quicktest.py [options] [filename] - -``filename`` is the name of the file to use as input (default is stdin). - -Options: -""" - -options = [('pretty', 'p', - 'output pretty pseudo-xml: no "&abc;" entities (default)'), - ('test', 't', 'output test-ready data (input & expected output, ' - 'ready to be copied to a parser test module)'), - ('rawxml', 'r', 'output raw XML'), - ('styledxml=', 's', 'output raw XML with XSL style sheet reference ' - '(filename supplied in the option argument)'), - ('xml', 'x', 'output pretty XML (indented)'), - ('debug', 'd', 'debug mode (lots of output)'), - ('help', 'h', 'show help text')] -"""See distutils.fancy_getopt.FancyGetopt.__init__ for a description of the -data structure: (long option, short option, description).""" - -def usage(): - print usage_header - for longopt, shortopt, description in options: - if longopt[-1:] == '=': - opts = '-%s arg, --%sarg' % (shortopt, longopt) - else: - opts = '-%s, --%s' % (shortopt, longopt), - print '%-15s' % opts, - if len(opts) > 14: - print '%-16s' % '\n', - while len(description) > 60: - limit = description.rindex(' ', 0, 60) - print description[:limit].strip() - description = description[limit + 1:] - print '%-15s' % ' ', - print description - -def _pretty(input, document, optargs): - return document.pformat() - -def _rawxml(input, document, optargs): - return document.asdom().toxml() - -def _styledxml(input, document, optargs): - docnode = document.asdom().childNodes[0] - return '%s\n%s\n%s' % ( - '<?xml version="1.0" encoding="ISO-8859-1"?>', - '<?xml-stylesheet type="text/xsl" href="%s"?>' % optargs['styledxml'], - docnode.toxml()) - -def _prettyxml(input, document, optargs): - return document.asdom().toprettyxml(' ', '\n') - -def _test(input, document, optargs): - tq = '"""' - output = document.pformat() # same as _pretty() - return """\ - totest['change_this_test_name'] = [ -[%s\\ -%s -%s, -%s\\ -%s -%s], -] -""" % ( tq, escape(input.rstrip()), tq, tq, escape(output.rstrip()), tq ) - -def escape(text): - """ - Return `text` in a form compatible with triple-double-quoted Python strings. - """ - text = text.replace('\\', '\\\\') # escape backslashes - text = text.replace('"""', '""\\"') # break up triple-double-quotes - text = text.replace(' \n', ' \\n\\\n') # protect trailing whitespace - return text - -_outputFormatters = { - 'rawxml': _rawxml, - 'styledxml': _styledxml, - 'xml': _prettyxml, - 'pretty' : _pretty, - 'test': _test - } - -def format(outputFormat, input, document, optargs): - formatter = _outputFormatters[outputFormat] - return formatter(input, document, optargs) - -def getArgs(): - if os.name == 'mac' and len(sys.argv) <= 1: - return macGetArgs() - else: - return posixGetArgs(sys.argv[1:]) - -def posixGetArgs(argv): - outputFormat = 'pretty' - # convert fancy_getopt style option list to getopt.getopt() arguments - shortopts = ''.join([option[1] + ':' * (option[0][-1:] == '=') - for option in options if option[1]]) - longopts = [option[0] for option in options if option[0]] - try: - opts, args = getopt.getopt(argv, shortopts, longopts) - except getopt.GetoptError: - usage() - sys.exit(2) - optargs = {'debug': 0} - for o, a in opts: - if o in ['-h', '--help']: - usage() - sys.exit() - elif o in ['-r', '--rawxml']: - outputFormat = 'rawxml' - elif o in ['-s', '--styledxml']: - outputFormat = 'styledxml' - optargs['styledxml'] = a - elif o in ['-x', '--xml']: - outputFormat = 'xml' - elif o in ['-p', '--pretty']: - outputFormat = 'pretty' - elif o in ['-t', '--test']: - outputFormat = 'test' - elif o in ['-d', '--debug']: - optargs['debug'] = 1 - else: - raise getopt.GetoptError, "getopt should have saved us!" - if len(args) > 1: - print "Only one file at a time, thanks." - usage() - sys.exit(1) - if len(args) == 1: - inputFile = open(args[0]) - else: - inputFile = sys.stdin - return inputFile, outputFormat, optargs - -def macGetArgs(): - import EasyDialogs - EasyDialogs.Message("""\ -In the following window, please: - -1. Choose an output format from the "Option" list. -2. Click "Add" (if you don't, the default format will - be "pretty"). -3. Click "Add existing file..." and choose an input file. -4. Click "OK".""") - optionlist = [(longopt, description) - for (longopt, shortopt, description) in options] - argv = EasyDialogs.GetArgv(optionlist=optionlist, addnewfile=0, addfolder=0) - return posixGetArgs(argv) - -def main(): - inputFile, outputFormat, optargs = getArgs() # process cmdline arguments - parser = Parser() - input = inputFile.read() - document = docutils.utils.newdocument(debug=optargs['debug']) - parser.parse(input, document) - output = format(outputFormat, input, document, optargs) - print output, - - -if __name__ == '__main__': - sys.stderr = sys.stdout - main() diff --git a/docutils/tools/stylesheets/default.css b/docutils/tools/stylesheets/default.css deleted file mode 100644 index 2db991782..000000000 --- a/docutils/tools/stylesheets/default.css +++ /dev/null @@ -1,157 +0,0 @@ -/* -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:date: $Date$ -:version: $Revision$ -:copyright: This stylesheet has been placed in the public domain. - -Default cascading style sheet for the HTML output of Docutils. -*/ - -a.footnote-reference { - font-size: smaller ; - vertical-align: super } - -a.target { - color: blue } - -code { - background-color: #eeeeee } - -div.abstract { - margin: 2em 5em } - -div.abstract p.topic-title { - font-weight: bold ; - text-align: center } - -div.attention, div.caution, div.danger, div.error, div.hint, -div.important, div.note, div.tip, div.warning { - margin: 2em ; - border: medium outset ; - padding: 1em } - -div.attention p.admonition-title, div.caution p.admonition-title, -div.danger p.admonition-title, div.error p.admonition-title, -div.warning p.admonition-title { - color: red ; - font-weight: bold ; - font-family: sans-serif } - -div.hint p.admonition-title, div.important p.admonition-title, -div.note p.admonition-title, div.tip p.admonition-title { - font-weight: bold ; - font-family: sans-serif } - -div.field-body { - margin-bottom: 1em } - -div.field-list { - margin-bottom: -1em } - -div.figure { - margin-left: 2em } - -div.system-messages { - margin: 5em } - -div.system-messages h1 { - color: red } - -div.system-message { - border: medium outset ; - padding: 1em } - -div.system-message p.system-message-title { - color: red ; - font-weight: bold } - -div.topic { - margin: 2em } - -dt { - margin-bottom: -1em } - -h1.title { - text-align: center } - -h2.subtitle { - text-align: center } - -hr { - width: 75% } - -ol.arabic { - list-style: decimal } - -ol.loweralpha { - list-style: lower-alpha } - -ol.upperalpha { - list-style: upper-alpha } - -ol.lowerroman { - list-style: lower-roman } - -ol.upperroman { - list-style: upper-roman } - -p.caption { - font-style: italic } - -p.credits { - font-style: italic ; - font-size: smaller } - -p.docinfo-name { - font-weight: bold ; - text-align: right } - -p.field-name { - font-weight: bold ; - margin-bottom: 1em } - -p.label { - white-space: nowrap } - -p.topic-title { - font-weight: bold } - -pre.literal-block, pre.doctest-block { - margin-left: 2em ; - margin-right: 2em ; - background-color: #eeeeee } - -span.classifier { - font-family: sans-serif ; - font-style: oblique } - -span.classifier-delimiter { - font-family: sans-serif ; - font-weight: bold } - -span.field-argument { - font-style: italic } - -span.interpreted { - font-family: sans-serif } - -span.option-argument { - font-style: italic } - -span.problematic { - color: red } - -table { - margin-top: 1em } - -table.citation { - border-left: solid thin gray ; - padding-left: 0.5ex } - -table.docinfo { - margin: 2em 4em } - -table.footnote { - border-left: solid thin black ; - padding-left: 0.5ex } |
