Skip to content

Commit 1905456

Browse files
committed
Final fixes and cleanup before release.
1 parent 3531221 commit 1905456

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mwparserfromhell
2-
========================
2+
================
33

44
**mwparserfromhell** (the *MediaWiki Parser from Hell*) is a Python package
55
that provides an easy-to-use and outrageously powerful parser for MediaWiki_

mwparserfromhell/smart_list.py

+4
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,21 @@ def __iadd__(self, other):
289289

290290
@property
291291
def _start(self):
292+
"""The starting index of this list, inclusive."""
292293
return self._sliceinfo[0]
293294

294295
@property
295296
def _stop(self):
297+
"""The ending index of this list, exclusive."""
296298
return self._sliceinfo[1]
297299

298300
@property
299301
def _step(self):
302+
"""The number to increase the index by between items."""
300303
return self._sliceinfo[2]
301304

302305
def _render(self):
306+
"""Return the actual list from the stored start/stop/step."""
303307
return list(self._parent)[self._start:self._stop:self._step]
304308

305309
@inheritdoc

mwparserfromhell/utils.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
from __future__ import unicode_literals
2929

30-
import mwparserfromhell
3130
from .compat import bytes, str
3231
from .nodes import Node
3332
from .smart_list import SmartList
@@ -44,24 +43,26 @@ def parse_anything(value):
4443
:py:class:`~.Template`, such as :py:meth:`wikicode.insert()
4544
<.Wikicode.insert>` or setting :py:meth:`template.name <.Template.name>`.
4645
"""
47-
wikicode = mwparserfromhell.wikicode.Wikicode
48-
if isinstance(value, wikicode):
46+
from . import parse
47+
from .wikicode import Wikicode
48+
49+
if isinstance(value, Wikicode):
4950
return value
5051
elif isinstance(value, Node):
51-
return wikicode(SmartList([value]))
52+
return Wikicode(SmartList([value]))
5253
elif isinstance(value, str):
53-
return mwparserfromhell.parse(value)
54+
return parse(value)
5455
elif isinstance(value, bytes):
55-
return mwparserfromhell.parse(value.decode("utf8"))
56+
return parse(value.decode("utf8"))
5657
elif isinstance(value, int):
57-
return mwparserfromhell.parse(str(value))
58+
return parse(str(value))
5859
elif value is None:
59-
return wikicode(SmartList())
60+
return Wikicode(SmartList())
6061
try:
6162
nodelist = SmartList()
6263
for item in value:
6364
nodelist += parse_anything(item).nodes
6465
except TypeError:
6566
error = "Needs string, Node, Wikicode, int, None, or iterable of these, but got {0}: {1}"
6667
raise ValueError(error.format(type(value).__name__, value))
67-
return wikicode(nodelist)
68+
return Wikicode(nodelist)

mwparserfromhell/wikicode.py

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def _get_tree(self, code, lines, marker, indent):
143143
the starting indentation.
144144
"""
145145
def write(*args):
146+
"""Write a new line following the proper indentation rules."""
146147
if lines and lines[-1] is marker: # Continue from the last line
147148
lines.pop() # Remove the marker
148149
last = lines.pop()

0 commit comments

Comments
 (0)