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

« back to all changes in this revision

Viewing changes to ivle/worksheet/rst.py

Warn that only committed changes will be submitted.

Show diffs side-by-side

added added

removed removed

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