Skip to content

Commit 386d62b

Browse files
committed
some doc cleanup
1 parent 6cade7a commit 386d62b

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Why another Python HTML Parser?
2727
-------------------------------
2828

2929
There is no "HTML Parser" in the "Python" Standard Library.
30-
Actually, there is the html.parser.HTMLParser_ that simply "traverses the DOM tree" and allows me to be notified as
30+
Actually, there is the `html.parser.HTMLParser`_ that simply "traverses the DOM tree" and allows me to be notified as
3131
each tag is being parsed. Usually, when "parsing HTML" I want to query its elements and extract data from it.
3232

3333
There are a few third party "HTML parsers" available like "lxml", "html5lib" and "beautifulsoup".
@@ -41,7 +41,7 @@ The most simple way to do this is to use `XPath expressions`__.
4141
Python does support a simple (read limited) XPath engine inside its "ElementTree" module.
4242
A benefit of using "ElementTree" is that it can use a "C implementation" whenever available.
4343

44-
This "HTML Parser" extends html.parser.HTMLParser_ to build a tree of ElementTree.Element_ instances.
44+
This "HTML Parser" extends `html.parser.HTMLParser`_ to build a tree of `ElementTree.Element`_ instances.
4545
The returned "root element" natively supports the ElementTree API.
4646

4747

@@ -127,7 +127,7 @@ And the output is as follows: ::
127127
Milk
128128

129129
.. seealso::
130-
More examples can be found in examples.py_.
130+
More examples can be found in `examples.py`_.
131131

132132
Compatibility
133133
-------------
@@ -139,7 +139,7 @@ Compatibility
139139
* pypy
140140

141141
.. _html.parser.HTMLParser: https://docs.python.org/3.6/library/html.parser.html#html.parser.HTMLParser
142-
.. _ElementTree.Element : https://docs.python.org/3.6/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element
142+
.. _ElementTree.Element: https://docs.python.org/3.6/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element
143143
.. _examples.py: https://github.com/willforde/python-htmlement/blob/master/examples.py
144144
.. _Xpath: https://docs.python.org/3.6/library/xml.etree.elementtree.html#xpath-support
145145
__ XPath_

htmlement.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828

2929
def fromstring(text, tag="", attrs=None, encoding=""):
3030
"""
31-
Parse's "HTML" document from a string into an element_tree.
31+
Parse's "HTML" document from a string into an element tree.
3232
3333
:param text: The "HTML" document to parse.
34-
:type text: str, bytes
34+
:type text: str or bytes
3535
3636
:param str tag: (optional) see :class:`HTMLement` for details.
3737
:param dict attrs: (optional) see :class:`HTMLement` for details.
38-
:param str encoding: (optional) The encoding used for/in *text*
38+
:param str encoding: (optional) The encoding used for *text*
3939
4040
:return: The root element of the element tree.
4141
:rtype: xml.etree.ElementTree.Element
@@ -49,10 +49,10 @@ def fromstring(text, tag="", attrs=None, encoding=""):
4949

5050
def fromstringlist(sequence, tag="", attrs=None, encoding=""):
5151
"""
52-
Parses an HTML document from a sequence of "HTML sections" into an element tree.
52+
Parses an "HTML document" from a sequence of "HTML sections" into an element tree.
5353
5454
:param sequence: A sequence of "HTML sections" to parse.
55-
:type sequence: list[str,bytes]
55+
:type sequence: list(str or bytes)
5656
5757
:param str tag: (optional) see :class:`HTMLement` for details.
5858
:param dict attrs: (optional) see :class:`HTMLement` for details.
@@ -71,10 +71,10 @@ def fromstringlist(sequence, tag="", attrs=None, encoding=""):
7171

7272
def parse(source, tag="", attrs=None, encoding=""):
7373
"""
74-
Load an external HTML document into element tree.
74+
Load an external "HTML document" into an element tree.
7575
7676
:param source: A filename or file like object containing HTML data.
77-
:type source: str, io.TextIOBase
77+
:type source: str or io.TextIOBase
7878
7979
:param str tag: (optional) see :class:`HTMLement` for details.
8080
:param dict attrs: (optional) see :class:`HTMLement` for details.
@@ -123,15 +123,15 @@ class HTMLement(object):
123123
section is found, does the parser start parsing the "HTML document". The element that matches the search criteria
124124
will then become the new "root element".
125125
126-
Attributes are given as a dict of {'name': 'value'}. Value can be the string to match, or `True` or `False.`
126+
Attributes are given as a dict of {'name': 'value'}. Value can be the string to match, `True` or `False.`
127127
`True` will match any attribute with given name and any value.
128-
`False` will only give a match if given attribute does not exists in the element.
128+
`False` will only give a match if given attribute does not exist in the element.
129129
130-
:type tag: str
131130
:param str tag: (optional) Name of "tag / element" which is used to filter down "the tree" to a required section.
131+
:type tag: str
132132
133-
:type attrs: dict
134133
:param attrs: (optional) The attributes of the element, that will be used, when searchingfor the required section.
134+
:type attrs: dict(str, str)
135135
136136
:param encoding: (optional) Encoding used, when decoding the source data before feeding it to the parser.
137137
:type encoding: str
@@ -148,12 +148,12 @@ def feed(self, data):
148148
"""
149149
Feeds data to the parser.
150150
151-
If *data*, is of "type `bytes` and where no encoding was specified, then the encoding
152-
will be extracted from *data* using "meta tags" if available.
151+
If *data*, is of type :class:`bytes` and where no encoding was specified, then the encoding
152+
will be extracted from *data* using "meta tags", if available.
153153
Otherwise encoding will default to "ISO-8859-1"
154154
155155
:param data: HTML data
156-
:type data: str, bytes
156+
:type data: str or bytes
157157
158158
:raises UnicodeDecodeError: If decoding of *data* fails.
159159
"""
@@ -182,18 +182,18 @@ def close(self):
182182
:return: The "root element" of the "element tree".
183183
:rtype: xml.etree.ElementTree.Element
184184
185-
:raises RuntimeError: If no element, matching search criteria, was found when a filter is given.
185+
:raises RuntimeError: If no element matching search criteria was found.
186186
"""
187187
return self._parser.close()
188188

189189
def _make_unicode(self, data):
190190
"""
191-
Convert *data* from type `bytes` to type `str`.
191+
Convert *data* from type :class:`bytes` to type :class:`str`.
192192
193193
:param data: The html document.
194194
:type data: bytes
195195
196-
:return: HTML data decoded into str(unicode).
196+
:return: HTML data decoded.
197197
:rtype: str
198198
"""
199199
# Atemp to find the encoding from the html source

0 commit comments

Comments
 (0)