~ubuntu-branches/ubuntu/jaunty/python-docutils/jaunty

« back to all changes in this revision

Viewing changes to docutils/parsers/rst/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Author: David Goodger
2
2
# Contact: goodger@users.sourceforge.net
3
 
# Revision: $Revision: 1.14 $
4
 
# Date: $Date: 2003/09/01 15:09:14 $
 
3
# Revision: $Revision: 3416 $
 
4
# Date: $Date: 2005-06-01 15:52:43 +0200 (Wed, 01 Jun 2005) $
5
5
# Copyright: This module has been placed in the public domain.
6
6
 
7
7
"""
88
88
    settings_spec = (
89
89
        'reStructuredText Parser Options',
90
90
        None,
91
 
        (('Recognize and link to PEP references (like "PEP 258").',
 
91
        (('Recognize and link to standalone PEP references (like "PEP 258").',
92
92
          ['--pep-references'],
93
93
          {'action': 'store_true', 'validator': frontend.validate_boolean}),
94
 
         ('Recognize and link to RFC references (like "RFC 822").',
 
94
         ('Base URL for PEP references '
 
95
          '(default "http://www.python.org/peps/").',
 
96
          ['--pep-base-url'],
 
97
          {'metavar': '<URL>', 'default': 'http://www.python.org/peps/',
 
98
           'validator': frontend.validate_url_trailing_slash}),
 
99
         ('Recognize and link to standalone RFC references (like "RFC 822").',
95
100
          ['--rfc-references'],
96
101
          {'action': 'store_true', 'validator': frontend.validate_boolean}),
 
102
         ('Base URL for RFC references (default "http://www.faqs.org/rfcs/").',
 
103
          ['--rfc-base-url'],
 
104
          {'metavar': '<URL>', 'default': 'http://www.faqs.org/rfcs/',
 
105
           'validator': frontend.validate_url_trailing_slash}),
97
106
         ('Set number of spaces for tab expansion (default 8).',
98
107
          ['--tab-width'],
99
 
          {'metavar': '<width>', 'type': 'int', 'default': 8}),
 
108
          {'metavar': '<width>', 'type': 'int', 'default': 8,
 
109
           'validator': frontend.validate_nonnegative_int}),
100
110
         ('Remove spaces before footnote references.',
101
111
          ['--trim-footnote-reference-space'],
102
 
          {'action': 'store_true', 'validator': frontend.validate_boolean}),))
 
112
          {'action': 'store_true', 'validator': frontend.validate_boolean}),
 
113
         ('Leave spaces before footnote references.',
 
114
          ['--leave-footnote-reference-space'],
 
115
          {'action': 'store_false', 'dest': 'trim_footnote_reference_space',
 
116
           'validator': frontend.validate_boolean}),
 
117
         ('Disable directives that insert the contents of external file '
 
118
          '("include" & "raw"); replaced with a "warning" system message.',
 
119
          ['--no-file-insertion'],
 
120
          {'action': 'store_false', 'default': 1,
 
121
           'dest': 'file_insertion_enabled'}),
 
122
         ('Enable directives that insert the contents of external file '
 
123
          '("include" & "raw").  Enabled by default.',
 
124
          ['--file-insertion-enabled'],
 
125
          {'action': 'store_true', 'dest': 'file_insertion_enabled'}),
 
126
         ('Disable the "raw" directives; replaced with a "warning" '
 
127
          'system message.',
 
128
          ['--no-raw'],
 
129
          {'action': 'store_false', 'default': 1, 'dest': 'raw_enabled'}),
 
130
         ('Enable the "raw" directive.  Enabled by default.',
 
131
          ['--raw-enabled'],
 
132
          {'action': 'store_true', 'dest': 'raw_enabled'}),))
103
133
 
104
134
    config_section = 'restructuredtext parser'
105
135
    config_section_dependencies = ('parsers',)
115
145
    def parse(self, inputstring, document):
116
146
        """Parse `inputstring` and populate `document`, a document tree."""
117
147
        self.setup_parse(inputstring, document)
118
 
        debug = document.reporter[''].debug
119
148
        self.statemachine = states.RSTStateMachine(
120
149
              state_classes=self.state_classes,
121
150
              initial_state=self.initial_state,
122
 
              debug=debug)
 
151
              debug=document.reporter.debug_flag)
123
152
        inputlines = docutils.statemachine.string2lines(
124
153
              inputstring, tab_width=document.settings.tab_width,
125
154
              convert_whitespace=1)