From 708bee59e1b06ca8b82b43510847377fbd8fa40a Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 2 Mar 2019 21:50:27 -0500 Subject: [PATCH] Minor cleanup --- docs/changelog.rst | 2 +- mwparserfromhell/nodes/__init__.py | 1 + mwparserfromhell/nodes/extras/__init__.py | 4 ++-- mwparserfromhell/parser/__init__.py | 6 +++--- mwparserfromhell/parser/tokenizer.py | 2 +- mwparserfromhell/wikicode.py | 4 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index d6280dd..e12f74e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,7 +8,7 @@ Unreleased (`changes `__): - Fixed manual construction of Node objects, previously unsupported. -(`#214 `_) + (`#214 `_) - Fixed :class:`.Wikicode` transformation methods (:meth:`.Wikicode.replace`, :meth:`.Wikicode.remove`, etc.) when passed an empty section as an argument. (`#212 `_) diff --git a/mwparserfromhell/nodes/__init__.py b/mwparserfromhell/nodes/__init__.py index 17ad3c3..9418199 100644 --- a/mwparserfromhell/nodes/__init__.py +++ b/mwparserfromhell/nodes/__init__.py @@ -56,6 +56,7 @@ class Node(StringMixIn): def __children__(self): return + # pylint: disable=unreachable yield # pragma: no cover (this is a generator that yields nothing) def __strip__(self, **kwargs): diff --git a/mwparserfromhell/nodes/extras/__init__.py b/mwparserfromhell/nodes/extras/__init__.py index 2d90b4e..9347c61 100644 --- a/mwparserfromhell/nodes/extras/__init__.py +++ b/mwparserfromhell/nodes/extras/__init__.py @@ -21,8 +21,8 @@ # SOFTWARE. """ -This package contains objects used by :class:`.Node`\ s, but that are not nodes -themselves. This includes template parameters and HTML tag attributes. +This package contains objects used by :class:`.Node`\\ s, but that are not +nodes themselves. This includes template parameters and HTML tag attributes. """ from .attribute import Attribute diff --git a/mwparserfromhell/parser/__init__.py b/mwparserfromhell/parser/__init__.py index de60226..dc769a2 100644 --- a/mwparserfromhell/parser/__init__.py +++ b/mwparserfromhell/parser/__init__.py @@ -55,8 +55,8 @@ class Parser(object): Actual parsing is a two-step process: first, the text is split up into a series of tokens by the :class:`.Tokenizer`, and then the tokens are - converted into trees of :class:`.Wikicode` objects and :class:`.Node`\ s by - the :class:`.Builder`. + converted into trees of :class:`.Wikicode` objects and :class:`.Node`\\ s + by the :class:`.Builder`. Instances of this class or its dependents (:class:`.Tokenizer` and :class:`.Builder`) should not be shared between threads. :meth:`parse` can @@ -79,7 +79,7 @@ class Parser(object): If given, *context* will be passed as a starting context to the parser. This is helpful when this function is used inside node attribute - setters. For example, :class:`.ExternalLink`\ 's + setters. For example, :class:`.ExternalLink`\\ 's :attr:`~.ExternalLink.url` setter sets *context* to :mod:`contexts.EXT_LINK_URI <.contexts>` to prevent the URL itself from becoming an :class:`.ExternalLink`. diff --git a/mwparserfromhell/parser/tokenizer.py b/mwparserfromhell/parser/tokenizer.py index 1bfbc8d..a9a02cc 100644 --- a/mwparserfromhell/parser/tokenizer.py +++ b/mwparserfromhell/parser/tokenizer.py @@ -455,7 +455,7 @@ class Tokenizer(object): else: self._parse_free_uri_scheme() invalid = ("\n", " ", "[", "]") - punct = tuple(",;\.:!?)") + punct = tuple(",;\\.:!?)") if self._read() is self.END or self._read()[0] in invalid: self._fail_route() tail = "" diff --git a/mwparserfromhell/wikicode.py b/mwparserfromhell/wikicode.py index 9f57a71..0cc7276 100644 --- a/mwparserfromhell/wikicode.py +++ b/mwparserfromhell/wikicode.py @@ -56,7 +56,7 @@ class Wikicode(StringMixIn): @staticmethod def _get_children(node, contexts=False, restrict=None, parent=None): - """Iterate over all child :class:`.Node`\ s of a given *node*.""" + """Iterate over all child :class:`.Node`\\ s of a given *node*.""" yield (parent, node) if contexts else node if restrict and isinstance(node, restrict): return @@ -276,7 +276,7 @@ class Wikicode(StringMixIn): self._nodes = value def get(self, index): - """Return the *index*\ th node within the list of nodes.""" + """Return the *index*\\ th node within the list of nodes.""" return self.nodes[index] def set(self, index, value):