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

« back to all changes in this revision

Viewing changes to docutils/__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
 
# Contact: goodger@users.sourceforge.net
3
 
# Revision: $Revision: 1.32 $
4
 
# Date: $Date: 2004/05/09 16:23:54 $
 
2
# Contact: goodger@python.org
 
3
# Revision: $Revision: 4260 $
 
4
# Date: $Date: 2006-01-09 19:28:09 +0100 (Mon, 09 Jan 2006) $
5
5
# Copyright: This module has been placed in the public domain.
6
6
 
7
7
"""
13
13
Modules:
14
14
 
15
15
- __init__.py: Contains component base classes, exception classes, and
16
 
  Docutils `__version__`.
 
16
  Docutils version information.
17
17
 
18
18
- core.py: Contains the ``Publisher`` class and ``publish_*()`` convenience
19
19
  functions.
51
51
 
52
52
__docformat__ = 'reStructuredText'
53
53
 
54
 
__version__ = '0.3.3'
55
 
"""``major.minor.micro`` version number.  The micro number is bumped
56
 
any time there's a change in the API incompatible with one of the
57
 
front ends or significant new functionality, and at any alpha or beta
58
 
release.  The minor number is bumped whenever there is a stable
59
 
project release.  The major number will be bumped when the project is
60
 
feature-complete, and perhaps if there is a major change in the
61
 
design."""
 
54
__version__ = '0.4'
 
55
"""``major.minor.micro`` version number.  The micro number is bumped for API
 
56
changes, for new functionality, and for interim project releases.  The minor
 
57
number is bumped whenever there is a significant project release.  The major
 
58
number will be bumped when the project is feature-complete, and perhaps if
 
59
there is a major change in the design."""
62
60
 
 
61
__version_details__ = 'release'
 
62
"""Extra version details (e.g. 'snapshot 2005-05-29, r3410', 'repository',
 
63
'release'), modified automatically & manually."""
63
64
 
64
65
class ApplicationError(StandardError): pass
65
66
class DataError(ApplicationError): pass
76
77
    settings_spec = ()
77
78
    """Runtime settings specification.  Override in subclasses.
78
79
 
79
 
    Specifies runtime settings and associated command-line options, as used by
80
 
    `docutils.frontend.OptionParser`.  This tuple contains one or more sets of
81
 
    option group title, description, and a list/tuple of tuples: ``('help
82
 
    text', [list of option strings], {keyword arguments})``.  Group title
83
 
    and/or description may be `None`; a group title of `None` implies no
84
 
    group, just a list of single options.  The "keyword arguments" dictionary
85
 
    contains arguments to the OptionParser/OptionGroup ``add_option`` method,
86
 
    with the addition of a "validator" keyword (see the
87
 
    `docutils.frontend.OptionParser.validators` instance attribute).  Runtime
88
 
    settings names are derived implicitly from long option names
89
 
    ("--a-setting" becomes ``settings.a_setting``) or explicitly from the
90
 
    "dest" keyword argument."""
 
80
    Defines runtime settings and associated command-line options, as used by
 
81
    `docutils.frontend.OptionParser`.  This is a tuple of:
 
82
 
 
83
    - Option group title (string or `None` which implies no group, just a list
 
84
      of single options).
 
85
    
 
86
    - Description (string or `None`).
 
87
    
 
88
    - A sequence of option tuples.  Each consists of:
 
89
 
 
90
      - Help text (string)
 
91
      
 
92
      - List of option strings (e.g. ``['-Q', '--quux']``).
 
93
      
 
94
      - Dictionary of keyword arguments.  It contains arguments to the
 
95
        OptionParser/OptionGroup ``add_option`` method, possibly with the
 
96
        addition of a 'validator' keyword (see the
 
97
        `docutils.frontend.OptionParser.validators` instance attribute).  Runtime
 
98
        settings names are derived implicitly from long option names
 
99
        ('--a-setting' becomes ``settings.a_setting``) or explicitly from the
 
100
        'dest' keyword argument.  See optparse docs for more details.
 
101
 
 
102
    - More triples of group title, description, options, as many times as
 
103
      needed.  Thus, `settings_spec` tuples can be simply concatenated.
 
104
    """
91
105
 
92
106
    settings_defaults = None
93
 
    """A dictionary of defaults for internal or inaccessible (by command-line
94
 
    or config file) settings.  Override in subclasses."""
 
107
    """A dictionary of defaults for settings not in `settings_spec` (internal
 
108
    settings, intended to be inaccessible by command-line and config file).
 
109
    Override in subclasses."""
95
110
 
96
111
    settings_default_overrides = None
97
112
    """A dictionary of auxiliary defaults, to override defaults for settings
122
137
    TransformSpec subclass objects used by `docutils.transforms.Transformer`.
123
138
    """
124
139
 
 
140
    def get_transforms(self):
 
141
        """Transforms required by this class.  Override in subclasses."""
 
142
        if self.default_transforms != ():
 
143
            import warnings
 
144
            warnings.warn('default_transforms attribute deprecated.\n'
 
145
                          'Use get_transforms() method instead.',
 
146
                          DeprecationWarning)
 
147
            return list(self.default_transforms)
 
148
        return []
 
149
 
 
150
    # Deprecated; for compatibility.
125
151
    default_transforms = ()
126
 
    """Transforms required by this class.  Override in subclasses."""
127
 
    
 
152
 
128
153
    unknown_reference_resolvers = ()
129
 
    """List of functions to try to resolve unknown references.  Called when
130
 
    FinalCheckVisitor is unable to find a correct target.  The list should
131
 
    contain functions which will try to resolve unknown references, with the
132
 
    following signature::
 
154
    """List of functions to try to resolve unknown references.  Unknown
 
155
    references have a 'refname' attribute which doesn't correspond to any
 
156
    target in the document.  Called when FinalCheckVisitor is unable to find a
 
157
    correct target.  The list should contain functions which will try to
 
158
    resolve unknown references, with the following signature::
133
159
 
134
160
        def reference_resolver(node):
135
161
            '''Returns boolean: true if resolved, false if not.'''
136
162
 
 
163
    If the function is able to resolve the reference, it should also remove
 
164
    the 'refname' attribute and mark the node as resolved::
 
165
 
 
166
        del node['refname']
 
167
        node.resolved = 1
 
168
 
137
169
    Each function must have a "priority" attribute which will affect the order
138
170
    the unknown_reference_resolvers are run::
139
171