~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/worksheet/rst.py

MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
1
2
#
2
3
# Natural Language Toolkit: Documentation generation script
3
4
#
17
18
      'pysrc-prompt', 'pysrc-keyword', 'pysrc-string', 'pysrc-comment',
18
19
      and 'pysrc-output'.
19
20
"""
20
 
import re, os.path, textwrap, sys, pickle, inspect
 
21
import re, os.path, textwrap, sys, pickle
21
22
from optparse import OptionParser
22
23
 
23
24
import docutils.core, docutils.nodes, docutils.io
1689
1690
def rst(input):
1690
1691
    try:
1691
1692
        CustomizedHTMLWriter.settings_defaults.update()
1692
 
        header = '.. include:: ' + os.path.join(
1693
 
            os.path.dirname(inspect.getfile(rst)), 'definitions.txt') + '\n' 
1694
 
        input = header + input
1695
1693
        output = docutils.core.publish_string(input,
1696
1694
            writer=CustomizedHTMLWriter(), reader=CustomizedReader())
1697
1695
        match = _OUTPUT_RE.search(output)
1698
1696
        if match:
1699
 
            return "<div>" + match.group(1) + "</div>"
 
1697
            return match.group(1)
1700
1698
        else:
1701
1699
            raise ValueError('Could not process exercise definition')
1702
1700