diff options
author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2006-01-09 20:44:25 +0000 |
---|---|---|
committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2006-01-09 20:44:25 +0000 |
commit | d77fdfef70e08114f57cbef5d91707df8717ea9f (patch) | |
tree | 49444e3486c0c333cb7b33dfa721296c08ee4ece /sandbox/aahz/OO/OOdirectives.py | |
parent | 53cd16ca6ca5f638cbe5956988e88f9339e355cf (diff) | |
parent | 3993c4097756e9885bcfbd07cb1cc1e4e95e50e4 (diff) | |
download | docutils-0.4.tar.gz |
Release 0.4: tagging released revisiondocutils-0.4
git-svn-id: http://svn.code.sf.net/p/docutils/code/tags/docutils-0.4@4268 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/aahz/OO/OOdirectives.py')
-rw-r--r-- | sandbox/aahz/OO/OOdirectives.py | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/sandbox/aahz/OO/OOdirectives.py b/sandbox/aahz/OO/OOdirectives.py deleted file mode 100644 index e437f6fbf..000000000 --- a/sandbox/aahz/OO/OOdirectives.py +++ /dev/null @@ -1,72 +0,0 @@ -import sys -import os - -from docutils import nodes -from docutils.parsers.rst import directives -from docutils.parsers.rst.languages import en - -registry = directives._directive_registry -registry['index'] = ('OOdirectives', 'index_directive') -registry['include-code'] = ('OOdirectives', 'include_code') -registry['include-output'] = ('OOdirectives', 'include_output') - -en.directives['index'] = 'index' -en.directives['include-code'] = 'include-code' -en.directives['include-output'] = 'include-output' - - -class index_entry(nodes.General, nodes.Element): pass -class index_entry(nodes.Inline, nodes.TextElement): pass - -def index_directive(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): - #nodes = [] - #for entry in content: - # nodes.append(index_entry(entry, entry)) - #return nodes - entries = '\n'.join(content) - return [index_entry(entries,entries)] - -index_directive.content = 1 - - - -def include_code(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): - #obj = state_machine.document.attributes - #print >> sys.stderr, obj - #print >> sys.stderr, dir(obj) - document = state_machine.document - dirname = getDocDir(document) - fname = os.path.join(dirname, arguments[0]) - code = open(fname).read() - return [nodes.literal_block(code, code)] - -include_code.arguments = (0, 1, 0) - - - -def include_output(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): - document = state_machine.document - dirname = getDocDir(document) - fname = os.path.join(dirname, arguments[0]) - cmd = os.environ['PYTHON'] + ' ' + fname - f_input, f_output = os.popen4(cmd) - output = f_output.read() - f_output.close() - return [nodes.literal_block(output, output)] - -include_output.arguments = (0, 1, 0) - - -def getDocDir(document): - source = document.current_source - if source is None: - return os.getcwd() - else: - dirname = os.path.dirname(os.path.abspath(source)) - if dirname is None: - return os.getcwd() - else: - return dirname |