Skip to content
This repository
Browse code

Simplify docs massively.

  • Loading branch information...
commit 816207bb5a8d89a340a2266f090cb2bdfd6aceb2 1 parent bdf5608
Ben Kurtovic authored August 21, 2012
1  docs/api/mwparserfromhell.nodes.rst
Source Rendered
@@ -7,6 +7,7 @@ nodes Package
7 7
 .. automodule:: mwparserfromhell.nodes
8 8
 
9 9
 .. autoclass:: mwparserfromhell.nodes.Node
  10
+    :special-members:
10 11
 
11 12
 :mod:`heading` Module
12 13
 ---------------------
2  mwparserfromhell/__init__.py
@@ -37,4 +37,4 @@
37 37
 from . import nodes, parser, smart_list, string_mixin, wikicode
38 38
 
39 39
 parse = lambda text: parser.Parser(text).parse()
40  
-parse.__doc__ = "Short for ``mwparserfromhell.parser.Parser(text).parse()``."
  40
+parse.__doc__ = "Short for :py:meth:`.Parser.parse`."
32  mwparserfromhell/nodes/__init__.py
@@ -21,14 +21,12 @@
21 21
 # SOFTWARE.
22 22
 
23 23
 """
24  
-This package contains :py:class:`~mwparserfromhell.wikicode.Wikicode` "nodes",
25  
-which represent a single unit of wikitext, such as a Template, an HTML tag,
26  
-a Heading, or plain text. The node "tree" is far from flat, as most types can
27  
-contain additional :py:class:`~mwparserfromhell.wikicode.Wikicode` types within
28  
-them - and with that, more nodes. For example, the name of a
29  
-:py:class:`~mwparserfromhell.nodes.template.Template` is a
30  
-:py:class:`~mwparserfromhell.wikicode.Wikicode` object that can contain text or
31  
-more templates.
  24
+This package contains :py:class:`~.Wikicode` "nodes", which represent a single
  25
+unit of wikitext, such as a Template, an HTML tag, a Heading, or plain text.
  26
+The node "tree" is far from flat, as most types can contain additional
  27
+:py:class:`~.Wikicode` types within them - and with that, more nodes. For
  28
+example, the name of a :py:class:`~.Template` is a :py:class:`~.Wikicode`
  29
+object that can contain text or more templates.
32 30
 """
33 31
 
34 32
 from __future__ import unicode_literals
@@ -43,15 +41,15 @@ class Node(StringMixIn):
43 41
 
44 42
     :py:meth:`__unicode__` must be overridden. It should return a ``unicode``
45 43
     or (``str`` in py3k) representation of the node. If the node contains
46  
-    :py:class:`~mwparserfromhell.wikicode.Wikicode` objects inside of it,
47  
-    :py:meth:`__iternodes__` should be overridden to yield tuples of
48  
-    (``wikicode``, ``node_in_wikicode``) for each node in each wikicode, as
49  
-    well as the node itself (``None``, ``self``). If the node is printable,
50  
-    :py:meth:`__strip__` should be overridden to return the printable version
51  
-    of the node - it does not have to be a string, but something that can be
52  
-    converted to a string with ``str()``. Finally, :py:meth:`__showtree__` can
53  
-    be overridden to build a nice tree representation of the node, if desired,
54  
-    for :py:meth:`~mwparserfromhell.wikicode.Wikicode.get_tree`.
  44
+    :py:class:`~.Wikicode` objects inside of it, :py:meth:`__iternodes__`
  45
+    should be overridden to yield tuples of (``wikicode``,
  46
+    ``node_in_wikicode``) for each node in each wikicode, as well as the node
  47
+    itself (``None``, ``self``). If the node is printable, :py:meth:`__strip__`
  48
+    should be overridden to return the printable version of the node - it does
  49
+    not have to be a string, but something that can be converted to a string
  50
+    with ``str()``. Finally, :py:meth:`__showtree__` can be overridden to build
  51
+    a nice tree representation of the node, if desired, for
  52
+    :py:meth:`~.Wikicode.get_tree`.
55 53
     """
56 54
     def __unicode__(self):
57 55
         raise NotImplementedError()
4  mwparserfromhell/nodes/extras/__init__.py
@@ -22,8 +22,8 @@
22 22
 
23 23
 """
24 24
 This package contains objects used by
25  
-:py:class:`~mwparserfromhell.nodes.Node`\ s, but are not nodes themselves.
26  
-This includes the parameters of Templates or the attributes of HTML tags.
  25
+:py:class:`~.Node`\ s, but are not nodes themselves. This includes the
  26
+parameters of Templates or the attributes of HTML tags.
27 27
 """
28 28
 
29 29
 from .attribute import Attribute
10  mwparserfromhell/nodes/extras/attribute.py
@@ -30,9 +30,9 @@
30 30
 class Attribute(StringMixIn):
31 31
     """Represents an attribute of an HTML tag.
32 32
 
33  
-    This is used by :py:class:`~mwparserfromhell.nodes.tag.Tag` objects. For
34  
-    example, the tag ``<ref name="foo">`` contains an Attribute whose name is
35  
-    ``"name"`` and whose value is ``"foo"``.
  33
+    This is used by :py:class:`~.Tag` objects. For example, the tag
  34
+    ``<ref name="foo">`` contains an Attribute whose name is ``"name"`` and
  35
+    whose value is ``"foo"``.
36 36
     """
37 37
 
38 38
     def __init__(self, name, value=None, quoted=True):
@@ -50,12 +50,12 @@ def __unicode__(self):
50 50
 
51 51
     @property
52 52
     def name(self):
53  
-        """The name of the attribute as a ``Wikicode`` object."""
  53
+        """The name of the attribute as a :py:class:`~.Wikicode` object."""
54 54
         return self._name
55 55
 
56 56
     @property
57 57
     def value(self):
58  
-        """The value of the attribute as a ``Wikicode`` object."""
  58
+        """The value of the attribute as a :py:class:`~.Wikicode` object."""
59 59
         return self._value
60 60
 
61 61
     @property
4  mwparserfromhell/nodes/extras/parameter.py
@@ -50,12 +50,12 @@ def __unicode__(self):
50 50
 
51 51
     @property
52 52
     def name(self):
53  
-        """The name of the parameter as a ``Wikicode`` object."""
  53
+        """The name of the parameter as a :py:class:`~.Wikicode` object."""
54 54
         return self._name
55 55
 
56 56
     @property
57 57
     def value(self):
58  
-        """The value of the parameter as a ``Wikicode`` object."""
  58
+        """The value of the parameter as a :py:class:`~.Wikicode` object."""
59 59
         return self._value
60 60
 
61 61
     @property
2  mwparserfromhell/nodes/heading.py
@@ -53,7 +53,7 @@ def __showtree__(self, write, get, mark):
53 53
 
54 54
     @property
55 55
     def title(self):
56  
-        """The title of the heading itself, as a ``Wikicode`` object."""
  56
+        """The title of the heading, as a :py:class:`~.Wikicode` object."""
57 57
         return self._title
58 58
 
59 59
     @property
7  mwparserfromhell/nodes/tag.py
@@ -172,20 +172,19 @@ def type(self):
172 172
 
173 173
     @property
174 174
     def tag(self):
175  
-        """The tag itself, as a ``Wikicode`` object."""
  175
+        """The tag itself, as a :py:class:`~.Wikicode` object."""
176 176
         return self._tag
177 177
 
178 178
     @property
179 179
     def contents(self):
180  
-        """The contents of the tag, as a ``Wikicode`` object."""
  180
+        """The contents of the tag, as a :py:class:`~.Wikicode` object."""
181 181
         return self._contents
182 182
 
183 183
     @property
184 184
     def attrs(self):
185 185
         """The list of attributes affecting the tag.
186 186
 
187  
-        Each attribute is an instance of
188  
-        :py:class:`~mwparserfromhell.nodes.extras.attribute.Attribute`.
  187
+        Each attribute is an instance of :py:class:`~.Attribute`.
189 188
         """
190 189
         return self._attrs
191 190
 
27  mwparserfromhell/nodes/template.py
@@ -152,7 +152,7 @@ def _remove_without_field(self, param, i, force_no_field):
152 152
 
153 153
     @property
154 154
     def name(self):
155  
-        """The name of the template, as a ``Wikicode`` object."""
  155
+        """The name of the template, as a :py:class:`~.Wikicode` object."""
156 156
         return self._name
157 157
 
158 158
     @property
@@ -184,11 +184,10 @@ def get(self, name):
184 184
         """Get the parameter whose name is *name*.
185 185
 
186 186
         The returned object is a
187  
-        :py:class:`~mwparserfromhell.nodes.extras.parameter.Parameter`
188  
-        instance. Raises :py:exc:`ValueError` if no parameter has this name.
189  
-        Since multiple parameters can have the same name, we'll return the last
190  
-        match, since the last parameter is the only one read by the MediaWiki
191  
-        parser.
  187
+        :py:class:`~.Parameter` instance. Raises :py:exc:`ValueError` if no
  188
+        parameter has this name. Since multiple parameters can have the same
  189
+        name, we'll return the last match, since the last parameter is the only
  190
+        one read by the MediaWiki parser.
192 191
         """
193 192
         name = name.strip() if isinstance(name, basestring) else str(name)
194 193
         for param in reversed(self.params):
@@ -200,14 +199,14 @@ def add(self, name, value, showkey=None, force_nonconformity=False):
200 199
         """Add a parameter to the template with a given *name* and *value*.
201 200
 
202 201
         *name* and *value* can be anything parasable by
203  
-        :py:func:`mwparserfromhell.utils.parse_anything`; pipes (and equal
204  
-        signs, if appropriate) are automatically escaped from *value* where
205  
-        applicable. If *showkey* is given, this will determine whether or not
206  
-        to show the parameter's name (e.g., ``{{foo|bar}}``'s parameter has a
207  
-        name of ``"1"`` but it is hidden); otherwise, we'll make a safe and
208  
-        intelligent guess. If *name* is already a parameter, we'll replace its
209  
-        value while keeping the same spacing rules unless *force_nonconformity*
210  
-        is ``True``. We will also try to guess the dominant spacing convention
  202
+        :py:func:`.utils.parse_anything`; pipes (and equal signs, if
  203
+        appropriate) are automatically escaped from *value* where applicable.
  204
+        If *showkey* is given, this will determine whether or not to show the
  205
+        parameter's name (e.g., ``{{foo|bar}}``'s parameter has a name of
  206
+        ``"1"`` but it is hidden); otherwise, we'll make a safe and intelligent
  207
+        guess. If *name* is already a parameter, we'll replace its value while
  208
+        keeping the same spacing rules unless *force_nonconformity* is
  209
+        ``True``. We will also try to guess the dominant spacing convention
211 210
         when adding a new parameter using :py:meth:`_get_spacing_conventions`
212 211
         unless *force_nonconformity* is ``True``.
213 212
         """
16  mwparserfromhell/parser/__init__.py
@@ -22,9 +22,8 @@
22 22
 
23 23
 """
24 24
 This package contains the actual wikicode parser, split up into two main
25  
-modules: the :py:mod:`~mwparserfromhell.parser.tokenizer` and the
26  
-:py:mod:`~mwparserfromhell.parser.builder`. This module joins them together
27  
-under one interface.
  25
+modules: the :py:mod:`~.tokenizer` and the :py:mod:`~.builder`. This module
  26
+joins them together under one interface.
28 27
 """
29 28
 
30 29
 try:
@@ -40,12 +39,9 @@ class Parser(object):
40 39
     """Represents a parser for wikicode.
41 40
 
42 41
     Actual parsing is a two-step process: first, the text is split up into a
43  
-    series of tokens by the
44  
-    :py:class:`~mwparserfromhell.parser.tokenizer.Tokenizer`, and then the
45  
-    tokens are converted into trees of
46  
-    :py:class:`~mwparserfromhell.wikicode.Wikicode` objects and
47  
-    :py:class:`~mwparserfromhell.nodes.Node`\ s by the
48  
-    :py:class:`~mwparserfromhell.parser.builder.Builder`.
  42
+    series of tokens by the :py:class:`~.Tokenizer`, and then the tokens are
  43
+    converted into trees of :py:class:`~.Wikicode` objects and
  44
+    :py:class:`~.Node`\ s by the :py:class:`~.Builder`.
49 45
     """
50 46
 
51 47
     def __init__(self, text):
@@ -54,7 +50,7 @@ def __init__(self, text):
54 50
         self._builder = Builder()
55 51
 
56 52
     def parse(self):
57  
-        """Return a string as a parsed ``Wikicode`` object tree."""
  53
+        """Return a string as a parsed :py:class:`~.Wikicode` object tree."""
58 54
         tokens = self._tokenizer.tokenize(self.text)
59 55
         code = self._builder.build(tokens)
60 56
         return code
7  mwparserfromhell/parser/builder.py
@@ -34,10 +34,9 @@
34 34
 class Builder(object):
35 35
     """Combines a sequence of tokens into a tree of ``Wikicode`` objects.
36 36
 
37  
-    To use, pass a list of :py:class:`~mwparserfromhell.parser.tokens.Token`\ s
38  
-    to the :py:meth:`build` method. The list will be exhausted as it is parsed
39  
-    and a :py:class:`~mwparserfromhell.wikicode.Wikicode` object will be
40  
-    returned.
  37
+    To use, pass a list of :py:class:`~.Token`\ s to the :py:meth:`build`
  38
+    method. The list will be exhausted as it is parsed and a
  39
+    :py:class:`~.Wikicode` object will be returned.
41 40
     """
42 41
 
43 42
     def __init__(self):
2  mwparserfromhell/parser/tokenizer.py
@@ -92,7 +92,7 @@ def _fail_route(self):
92 92
         """Fail the current tokenization route.
93 93
 
94 94
         Discards the current stack/context/textbuffer and raises
95  
-        :py:exc:`~mwparserfromhell.parser.tokenizer.BadRoute`.
  95
+        :py:exc:`~.BadRoute`.
96 96
         """
97 97
         self._pop()
98 98
         raise BadRoute()
6  mwparserfromhell/parser/tokens.py
@@ -24,10 +24,8 @@
24 24
 This module contains the token definitions that are used as an intermediate
25 25
 parsing data type - they are stored in a flat list, with each token being
26 26
 identified by its type and optional attributes. The token list is generated in
27  
-a syntactically valid form by the
28  
-:py:class:`~mwparserfromhell.parser.tokenizer.Tokenizer`, and then converted
29  
-into the :py:class`~mwparserfromhell.wikicode.Wikicode` tree by the
30  
-:py:class:`~mwparserfromhell.parser.builder.Builder`.
  27
+a syntactically valid form by the :py:class:`~.Tokenizer`, and then converted
  28
+into the :py:class`~.Wikicode` tree by the :py:class:`~.Builder`.
31 29
 """
32 30
 
33 31
 from __future__ import unicode_literals
26  mwparserfromhell/smart_list.py
@@ -21,10 +21,9 @@
21 21
 # SOFTWARE.
22 22
 
23 23
 """
24  
-This module contains the :py:class:`~mwparserfromhell.smart_list.SmartList`
25  
-type, as well as its :py:class:`~mwparserfromhell.smart_list._ListProxy` child,
26  
-which together implement a list whose sublists reflect changes made to the main
27  
-list, and vice-versa.
  24
+This module contains the :py:class:`~.SmartList` type, as well as its
  25
+:py:class:`~._ListProxy` child, which together implement a list whose sublists
  26
+reflect changes made to the main list, and vice-versa.
28 27
 """
29 28
 
30 29
 from __future__ import unicode_literals
@@ -36,9 +35,8 @@
36 35
 def inheritdoc(method):
37 36
     """Set __doc__ of *method* to __doc__ of *method* in its parent class.
38 37
 
39  
-    Since this is used on
40  
-    :py:class:`~mwparserfromhell.smart_list.SmartList`, the "parent class" used
41  
-    is ``list``. This function can be used as a decorator.
  38
+    Since this is used on :py:class:`~.SmartList`, the "parent class" used is
  39
+    ``list``. This function can be used as a decorator.
42 40
     """
43 41
     method.__doc__ = getattr(list, method.__name__).__doc__
44 42
     return method
@@ -51,10 +49,9 @@ class SmartList(list):
51 49
     list (such as the addition, removal, or replacement of elements) will be
52 50
     reflected in the sublist, or vice-versa, to the greatest degree possible.
53 51
     This is implemented by having sublists - instances of the
54  
-    :py:class:`~mwparserfromhell.smart_list._ListProxy` type - dynamically
55  
-    determine their elements by storing their slice info and retrieving that
56  
-    slice from the parent. Methods that change the size of the list also change
57  
-    the slice info. For example::
  52
+    :py:class:`~._ListProxy` type - dynamically determine their elements by
  53
+    storing their slice info and retrieving that slice from the parent. Methods
  54
+    that change the size of the list also change the slice info. For example::
58 55
 
59 56
         >>> parent = SmartList([0, 1, 2, 3])
60 57
         >>> parent
@@ -183,10 +180,9 @@ def sort(self, cmp=None, key=None, reverse=None):
183 180
 class _ListProxy(list):
184 181
     """Implement the ``list`` interface by getting elements from a parent.
185 182
 
186  
-    This is created by a :py:class:`~mwparserfromhell.smart_list.SmartList`
187  
-    object when slicing. It does not actually store the list at any time;
188  
-    instead, whenever the list is needed, it builds it dynamically using the
189  
-    :py:meth:`_render` method.
  183
+    This is created by a :py:class:`~.SmartList` object when slicing. It does
  184
+    not actually store the list at any time; instead, whenever the list is
  185
+    needed, it builds it dynamically using the :py:meth:`_render` method.
190 186
     """
191 187
 
192 188
     def __init__(self, parent, sliceinfo):
10  mwparserfromhell/string_mixin.py
@@ -21,9 +21,8 @@
21 21
 # SOFTWARE.
22 22
 
23 23
 """
24  
-This module contains the :py:class:`~mwparserfromhell.string_mixin.StringMixIn`
25  
-type, which implements the interface for the ``unicode`` type (``str`` on py3k)
26  
-in a dynamic manner.
  24
+This module contains the :py:class:`~.StringMixIn` type, which implements the
  25
+interface for the ``unicode`` type (``str`` on py3k) in a dynamic manner.
27 26
 """
28 27
 
29 28
 from __future__ import unicode_literals
@@ -35,9 +34,8 @@
35 34
 def inheritdoc(method):
36 35
     """Set __doc__ of *method* to __doc__ of *method* in its parent class.
37 36
 
38  
-    Since this is used on
39  
-    :py:class:`~mwparserfromhell.string_mixin.StringMixIn`, the "parent class"
40  
-    used is ``str``. This function can be used as a decorator.
  37
+    Since this is used on :py:class:`~.StringMixIn`, the "parent class" used is
  38
+    ``str``. This function can be used as a decorator.
41 39
     """
42 40
     method.__doc__ = getattr(str, method.__name__).__doc__
43 41
     return method
14  mwparserfromhell/utils.py
@@ -33,20 +33,16 @@
33 33
 from .smart_list import SmartList
34 34
 
35 35
 def parse_anything(value):
36  
-    """Return a :py:class:`~mwparserfromhell.wikicode.Wikicode` for *value*.
  36
+    """Return a :py:class:`~.Wikicode` for *value*, allowing multiple types.
37 37
 
38 38
     This differs from :py:func:`mwparserfromhell.parse` in that we accept more
39 39
     than just a string to be parsed. Unicode objects (strings in py3k), strings
40 40
     (bytes in py3k), integers (converted to strings), ``None``, existing
41  
-    :py:class:`~mwparserfromhell.nodes.Node` or
42  
-    :py:class:`~mwparserfromhell.wikicode.Wikicode` objects, as well as an
  41
+    :py:class:`~.Node` or :py:class:`~.Wikicode` objects, as well as an
43 42
     iterable of these types, are supported. This is used to parse input
44  
-    on-the-fly by various methods of
45  
-    :py:class:`~mwparserfromhell.wikicode.Wikicode` and others like
46  
-    :py:class:`~mwparserfromhell.nodes.template.Template`, such as
47  
-    :py:meth:`wikicode.insert() <mwparserfromhell.wikicode.Wikicode.insert>`
48  
-    or setting :py:meth:`template.name
49  
-    <mwparserfromhell.nodes.template.Template.name>`.
  43
+    on-the-fly by various methods of :py:class:`~.Wikicode` and others like
  44
+    :py:class:`~.Template`, such as :py:meth:`wikicode.insert()
  45
+    <.Wikicode.insert>` or setting :py:meth:`template.name <.Template.name>`.
50 46
     """
51 47
     wikicode = mwparserfromhell.wikicode.Wikicode
52 48
     if isinstance(value, wikicode):
123  mwparserfromhell/wikicode.py
@@ -158,10 +158,10 @@ def write(*args):
158 158
 
159 159
     @property
160 160
     def nodes(self):
161  
-        """A list of :py:class:`~mwparserfromhell.nodes.Node` objects.
  161
+        """A list of :py:class:`~.Node` objects.
162 162
 
163 163
         This is the internal data actually stored within a
164  
-        :py:class:`~mwparserfromhell.wikicode.Wikicode` object.
  164
+        :py:class:`~.Wikicode` object.
165 165
         """
166 166
         return self._nodes
167 167
 
@@ -178,9 +178,9 @@ def set(self, index, value):
178 178
 
179 179
         Raises :py:exc:`IndexError` if *index* is out of range, or
180 180
         :py:exc:`ValueError` if *value* cannot be coerced into one
181  
-        :py:class:`~mwparserfromhell.nodes.Node`. To insert multiple nodes at
182  
-        an index, use :py:meth:`get` with either :py:meth:`remove` and
183  
-        :py:meth:`insert` or :py:meth:`replace`.
  181
+        :py:class:`~.Node`. To insert multiple nodes at an index, use
  182
+        :py:meth:`get` with either :py:meth:`remove` and :py:meth:`insert` or
  183
+        :py:meth:`replace`.
184 184
         """
185 185
         nodes = parse_anything(value).nodes
186 186
         if len(nodes) > 1:
@@ -213,10 +213,9 @@ def index(self, obj, recursive=False):
213 213
     def insert(self, index, value):
214 214
         """Insert *value* at *index* in the list of nodes.
215 215
 
216  
-        *value* can be anything parasable by
217  
-        :py:func:`mwparserfromhell.utils.parse_anything`, which includes
218  
-        strings or other :py:class:`~mwparserfromhell.wikicode.Wikicode` or
219  
-        :py:class:`~mwparserfromhell.nodes.Node` objects.
  216
+        *value* can be anything parasable by :py:func:`.parse_anything`, which
  217
+        includes strings or other :py:class:`~.Wikicode` or :py:class:`~.Node`
  218
+        objects.
220 219
         """
221 220
         nodes = parse_anything(value).nodes
222 221
         for node in reversed(nodes):
@@ -225,13 +224,11 @@ def insert(self, index, value):
225 224
     def insert_before(self, obj, value, recursive=True):
226 225
         """Insert *value* immediately before *obj* in the list of nodes.
227 226
 
228  
-        *obj* can be either a string or a
229  
-        :py:class:`~mwparserfromhell.nodes.Node`. *value* can be anything
230  
-        parasable by :py:func:`mwparserfromhell.utils.parse_anything`. If
231  
-        *recursive* is ``True``, we will try to find *obj* within our child
232  
-        nodes even if it is not a direct descendant of this
233  
-        :py:class:`~mwparserfromhell.wikicode.Wikicode` object. If *obj* is not
234  
-        in the node list, :py:exc:`ValueError` is raised.
  227
+        *obj* can be either a string or a :py:class:`~.Node`. *value* can be
  228
+        anything parasable by :py:func:`.parse_anything`. If *recursive* is
  229
+        ``True``, we will try to find *obj* within our child nodes even if it
  230
+        is not a direct descendant of this :py:class:`~.Wikicode` object. If
  231
+        *obj* is not in the node list, :py:exc:`ValueError` is raised.
235 232
         """
236 233
         callback = lambda self, i, value: self.insert(i, value)
237 234
         self._do_search(obj, recursive, callback, self, value)
@@ -239,13 +236,11 @@ def insert_before(self, obj, value, recursive=True):
239 236
     def insert_after(self, obj, value, recursive=True):
240 237
         """Insert *value* immediately after *obj* in the list of nodes.
241 238
 
242  
-        *obj* can be either a string or a
243  
-        :py:class:`~mwparserfromhell.nodes.Node`. *value* can be anything
244  
-        parasable by :py:func:`mwparserfromhell.utils.parse_anything`. If
245  
-        *recursive* is ``True``, we will try to find *obj* within our child
246  
-        nodes even if it is not a direct descendant of this
247  
-        :py:class:`~mwparserfromhell.wikicode.Wikicode` object. If *obj* is not
248  
-        in the node list, :py:exc:`ValueError` is raised.
  239
+        *obj* can be either a string or a :py:class:`~.Node`. *value* can be
  240
+        anything parasable by :py:func:`.parse_anything`. If *recursive* is
  241
+        ``True``, we will try to find *obj* within our child nodes even if it
  242
+        is not a direct descendant of this :py:class:`~.Wikicode` object. If
  243
+        *obj* is not in the node list, :py:exc:`ValueError` is raised.
249 244
         """
250 245
         callback = lambda self, i, value: self.insert(i + 1, value)
251 246
         self._do_search(obj, recursive, callback, self, value)
@@ -253,13 +248,11 @@ def insert_after(self, obj, value, recursive=True):
253 248
     def replace(self, obj, value, recursive=True):
254 249
         """Replace *obj* with *value* in the list of nodes.
255 250
 
256  
-        *obj* can be either a string or a
257  
-        :py:class:`~mwparserfromhell.nodes.Node`. *value* can be anything
258  
-        parasable by :py:func:`mwparserfromhell.utils.parse_anything`. If
259  
-        *recursive* is ``True``, we will try to find *obj* within our child
260  
-        nodes even if it is not a direct descendant of this
261  
-        :py:class:`~mwparserfromhell.wikicode.Wikicode` object. If *obj* is not
262  
-        in the node list, :py:exc:`ValueError` is raised.
  251
+        *obj* can be either a string or a :py:class:`~.Node`. *value* can be
  252
+        anything parasable by :py:func:`.parse_anything`. If *recursive* is
  253
+        ``True``, we will try to find *obj* within our child nodes even if it
  254
+        is not a direct descendant of this :py:class:`~.Wikicode` object. If
  255
+        *obj* is not in the node list, :py:exc:`ValueError` is raised.
263 256
         """
264 257
         def callback(self, i, value):
265 258
             self.nodes.pop(i)
@@ -270,8 +263,7 @@ def callback(self, i, value):
270 263
     def append(self, value):
271 264
         """Insert *value* at the end of the list of nodes.
272 265
 
273  
-        *value* can be anything parasable by
274  
-        :py:func:`mwparserfromhell.utils.parse_anything`.
  266
+        *value* can be anything parasable by :py:func:`.parse_anything`.
275 267
         """
276 268
         nodes = parse_anything(value).nodes
277 269
         for node in nodes:
@@ -280,12 +272,10 @@ def append(self, value):
280 272
     def remove(self, obj, recursive=True):
281 273
         """Remove *obj* from the list of nodes.
282 274
 
283  
-        *obj* can be either a string or a
284  
-        :py:class:`~mwparserfromhell.nodes.Node`. If *recursive* is ``True``,
285  
-        we will try to find *obj* within our child nodes even if it is not a
286  
-        direct descendant of this
287  
-        :py:class:`~mwparserfromhell.wikicode.Wikicode` object. If *obj* is not
288  
-        in the node list, :py:exc:`ValueError` is raised.
  275
+        *obj* can be either a string or a :py:class:`~.Node`. If *recursive* is
  276
+        ``True``, we will try to find *obj* within our child nodes even if it
  277
+        is not a direct descendant of this :py:class:`~.Wikicode` object. If
  278
+        *obj* is not in the node list, :py:exc:`ValueError` is raised.
289 279
         """
290 280
         callback = lambda self, i: self.nodes.pop(i)
291 281
         self._do_search(obj, recursive, callback, self)
@@ -316,7 +306,7 @@ def ifilter_templates(self, recursive=False, matches=None, flags=FLAGS):
316 306
         """Iterate over template nodes.
317 307
 
318 308
         This is equivalent to :py:meth:`ifilter` with *forcetype* set to
319  
-        :py:class:`~mwparserfromhell.nodes.template.Template`.
  309
+        :py:class:`~.Template`.
320 310
         """
321 311
         return self.filter(recursive, matches, flags, forcetype=Template)
322 312
 
@@ -324,7 +314,7 @@ def ifilter_text(self, recursive=False, matches=None, flags=FLAGS):
324 314
         """Iterate over text nodes.
325 315
 
326 316
         This is equivalent to :py:meth:`ifilter` with *forcetype* set to
327  
-        :py:class:`~mwparserfromhell.nodes.text.Text`.
  317
+        :py:class:`~.Text`.
328 318
         """
329 319
         return self.filter(recursive, matches, flags, forcetype=Text)
330 320
 
@@ -332,7 +322,7 @@ def ifilter_tags(self, recursive=False, matches=None, flags=FLAGS):
332 322
         """Iterate over tag nodes.
333 323
 
334 324
         This is equivalent to :py:meth:`ifilter` with *forcetype* set to
335  
-        :py:class:`~mwparserfromhell.nodes.tag.Tag`.
  325
+        :py:class:`~.Tag`.
336 326
         """
337 327
         return self.ifilter(recursive, matches, flags, forcetype=Tag)
338 328
 
@@ -372,24 +362,20 @@ def get_sections(self, flat=True, matches=None, levels=None, flags=FLAGS,
372 362
                      include_headings=True):
373 363
         """Return a list of sections within the page.
374 364
 
375  
-        Sections are returned as
376  
-        :py:class:`~mwparserfromhell.wikicode.Wikicode` objects with a shared
377  
-        node list (implemented using
378  
-        :py:class:`~mwparserfromhell.smart_list.SmartList`) so that changes to
379  
-        sections are reflected in the parent Wikicode object.
  365
+        Sections are returned as :py:class:`~.Wikicode` objects with a shared
  366
+        node list (implemented using :py:class:`~.SmartList`) so that changes
  367
+        to sections are reflected in the parent Wikicode object.
380 368
 
381 369
         With *flat* as ``True``, each returned section contains all of its
382  
-        subsections within the :py:class:`~mwparserfromhell.wikicode.Wikicode`;
383  
-        otherwise, the returned sections contain only the section up to the
384  
-        next heading, regardless of its size. If *matches* is given, it should
385  
-        be a regex to matched against the titles of section headings; only
386  
-        sections whose headings match the regex will be included. If *levels*
387  
-        is given, it should be a list of integers; only sections whose heading
388  
-        levels are within the list will be returned. If *include_headings* is
389  
-        ``True``, the section's literal
390  
-        :py:class:`~mwparserfromhell.nodes.heading.Heading` object will be
391  
-        included in returned :py:class:`~mwparserfromhell.wikicode.Wikicode`
392  
-        objects; otherwise, this is skipped.
  370
+        subsections within the :py:class:`~.Wikicode`; otherwise, the returned
  371
+        sections contain only the section up to the next heading, regardless of
  372
+        its size. If *matches* is given, it should be a regex to matched
  373
+        against the titles of section headings; only sections whose headings
  374
+        match the regex will be included. If *levels* is given, it should be a =
  375
+        list of integers; only sections whose heading levels are within the
  376
+        list will be returned. If *include_headings* is ``True``, the section's
  377
+        literal :py:class:`~.Heading` object will be included in returned
  378
+        :py:class:`~.Wikicode` objects; otherwise, this is skipped.
393 379
         """
394 380
         if matches:
395 381
             matches = r"^(=+?)\s*" + matches + r"\s*\1$"
@@ -421,16 +407,15 @@ def strip_code(self, normalize=True, collapse=True):
421 407
         """Return a rendered string without unprintable code such as templates.
422 408
 
423 409
         The way a node is stripped is handled by the
424  
-        :py:meth:`~mwparserfromhell.nodes.Node.__showtree__` method of
425  
-        :py:class:`~mwparserfromhell.nodes.Node` objects, which generally
426  
-        return a subset of their nodes or ``None``. For example, templates and
427  
-        tags are removed completely, links are stripped to just their display
428  
-        part, headings are stripped to just their title. If *normalize* is
429  
-        ``True``, various things may be done to strip code further, such as
430  
-        converting HTML entities like ``&Sigma;``, ``&#931;``, and ``&#x3a3;``
431  
-        to ``Σ``. If *collapse* is ``True``, we will try to remove excess
432  
-        whitespace as well (three or more newlines are converted to two, for
433  
-        example).
  410
+        :py:meth:`~.Node.__showtree__` method of :py:class:`~.Node` objects,
  411
+        which generally return a subset of their nodes or ``None``. For
  412
+        example, templates and tags are removed completely, links are stripped
  413
+        to just their display part, headings are stripped to just their title.
  414
+        If *normalize* is ``True``, various things may be done to strip code
  415
+        further, such as converting HTML entities like ``&Sigma;``, ``&#931;``,
  416
+        and ``&#x3a3;`` to ``Σ``. If *collapse* is ``True``, we will try to
  417
+        remove excess whitespace as well (three or more newlines are converted
  418
+        to two, for example).
434 419
         """
435 420
         nodes = []
436 421
         for node in self.nodes:
@@ -451,8 +436,8 @@ def get_tree(self):
451 436
 
452 437
         The representation is a string makes the most sense printed. It is
453 438
         built by calling :py:meth:`_get_tree` on the
454  
-        :py:class:`~mwparserfromhell.wikicode.Wikicode` object and its children
455  
-        recursively. The end result may look something like the following::
  439
+        :py:class:`~.Wikicode` object and its children recursively. The end
  440
+        result may look something like the following::
456 441
 
457 442
             >>> text = "Lorem ipsum {{foo|bar|{{baz}}|spam=eggs}}"
458 443
             >>> print mwparserfromhell.parse(text).get_tree()

0 notes on commit 816207b

Please sign in to comment.
Something went wrong with that request. Please try again.