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

« back to all changes in this revision

Viewing changes to ivle/webapp/tutorial/rst.py

  • Committer: Nick Chadwick
  • Date: 2009-02-25 16:39:59 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090225163959-3hsedlesu2pjm12e
Added a few extra files. I'm not sure if they're necessary, and I don't
have time to find out.

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
1555
1556
        self.body.append('<exercise weight="1" src="')
1556
1557
 
1557
1558
    def depart_exercise(self, node):
1558
 
        self.body.append('"/>\n')
 
1559
        self.body.append('"/>')
1559
1560
 
1560
1561
    def visit_challenge(self, node):
1561
1562
        self.body.append('<exercise weight="0" src="')
1562
1563
 
1563
1564
    def depart_challenge(self, node):
1564
 
        self.body.append('"/>\n')
 
1565
        self.body.append('"/>')
1565
1566
 
1566
1567
    def visit_literal(self, node):
1567
1568
        """Process text to prevent tokens from wrapping."""
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