Skip to content

Commit b590a07

Browse files
committed
Fix doc-strings.
1 parent 32c2801 commit b590a07

File tree

8 files changed

+51
-34
lines changed

8 files changed

+51
-34
lines changed

w3/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""A Python HTML Parser
2-
32
This is a personal project owned by Hepheir.
43
54
https://github.com/Hepheir/Python-HTML-Parser/

w3/dom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""API Module of DOM - Level 1
2-
"""
1+
"""API Module of DOM - Level 1"""
2+
33

44
# Bring in subpackages.
55
from w3.python.core import DOMException

w3/parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
"""A Parser module for building Document Object Model Structure parsed from text/html.
2-
"""
1+
"""A Parser module for building Document Object Model Structure parsed from text/html."""

w3/python/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
"""Imports core names of w3.
2+
3+
Interfaces are implemented under "./core/"
4+
"""
5+
16
from w3.python import core

w3/python/core/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Module that contains classes of interfaces and ect.
2-
"""
1+
"""Module that contains classes of interfaces and ect."""
32

43
from w3.python.core.fundamental_interface import DOMException
54
from w3.python.core.fundamental_interface import DOMImplementation

w3/python/core/fundamental_interface/DOMImplementation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class DOMImplementation:
77
"""Interface DOMImplementation
88
99
The `DOMImplementation` interface provides a number of methods for performing operations that are independent of any particular instance of the document object model.
10-
1110
The DOM Level 1 does not specify a way of creating a document instance, and hence document creation is an operation specific to an implementation. Future Levels of the DOM specification are expected to provide methods for creating documents directly.
1211
"""
1312

w3/python/core/fundamental_interface/Node.py

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,11 @@ def _check_modifiable(self) -> None:
103103

104104
@property
105105
def node_name(self) -> DOMString:
106-
"""Read only; The name of this node, depending on its type.
107-
"""
106+
"""Read only; The name of this node, depending on its type."""
108107
return self._node_name
109108

110109
def _set_node_name(self, name: DOMString) -> None:
111-
"""Indirect accessor to set the 'node_name' property.
112-
"""
110+
"""Indirect accessor to set the 'node_name' property."""
113111
self._node_name = DOMString(name)
114112

115113
@property
@@ -139,67 +137,76 @@ def _set_node_value(self, value: DOMString) -> None:
139137

140138
@property
141139
def node_type(self) -> NodeType:
142-
"""Read only; A code representing the type of the underlying object, as defined in `NodeType`.
143-
"""
140+
"""Read only; A code representing the type of the underlying object, as defined in `NodeType`."""
144141
return self._node_type
145142

146143
def _set_node_type(self, node_type: NodeType) -> None:
147-
"""Indirect accessor to set the 'node_type' property.
148-
"""
144+
"""Indirect accessor to set the 'node_type' property."""
149145
if node_type not in NodeType:
150146
raise ValueError(f'{node_type} is not a valid code '
151147
'for a node type.')
152148
self._node_type = node_type
153149

154150
@property
155151
def parent_node(self) -> Optional[_AnyNode]:
156-
"""The parent of this node. All nodes, except `Document`, `DocumentFragment`, and `Attr` may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is `None`.
152+
"""The parent of this node.
153+
154+
All nodes, except `Document`, `DocumentFragment`, and `Attr` may have a parent.
155+
However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is `None`.
157156
"""
158157
return self._parent_node
159158

160159
def _set_parent_node(self,
161160
parent_node: Optional[_AnyNode]) -> None:
162-
"""Indirect accessor to set the 'node_type' property.
163-
"""
161+
"""Indirect accessor to set the 'node_type' property."""
164162
if not parent_node:
165163
self._parent_node = None
166164
else:
167165
self._parent_node = parent_node
168166

169167
@property
170168
def child_nodes(self) -> NodeList:
171-
"""A `NodeList` that contains all children of this node. If there are no children, this is a `NodeList` containing no nodes. The content of the returned `NodeList` is "live" in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by the `NodeList` accessors; it is not a static snapshot of the content of the node. This is true for every `NodeList`, including the ones returned by the `getElementsByTagName` method.
169+
"""A `NodeList` that contains all children of this node.
170+
171+
If there are no children, this is a `NodeList` containing no nodes.
172+
The content of the returned `NodeList` is "live" in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by the `NodeList` accessors; it is not a static snapshot of the content of the node.
173+
This is true for every `NodeList`, including the ones returned by the `getElementsByTagName` method.
172174
"""
173175
return self._child_nodes
174176

175177
def _init_child_nodes(self,
176178
child_nodes: Optional[Iterable[_AnyNode]] = None) -> None:
177-
"""Accessor to set the 'child_nodes' property.
178-
"""
179+
"""Accessor to set the 'child_nodes' property."""
179180
if child_nodes is None:
180181
self._child_nodes = NodeList()
181182
else:
182183
self._child_nodes = NodeList(iter(child_nodes))
183184

184185
@property
185186
def first_child(self) -> Optional[_AnyNode]:
186-
"""The first child of this node. If there is no such node, this returns `None`.
187+
"""The first child of this node.
188+
189+
If there is no such node, this returns `None`.
187190
"""
188191
if not self.child_nodes:
189192
return None
190193
return self.child_nodes.item(0)
191194

192195
@property
193196
def last_child(self) -> Optional[_AnyNode]:
194-
"""The last child of this node. If there is no such node, this returns `None`.
197+
"""The last child of this node.
198+
199+
If there is no such node, this returns `None`.
195200
"""
196201
if not self.child_nodes:
197202
return None
198203
return self.child_nodes.item(self.child_nodes.length-1)
199204

200205
@property
201206
def previous_sibling(self) -> Optional[_AnyNode]:
202-
"""The node immediately preceding this node. If there is no such node, this returns `None`.
207+
"""The node immediately preceding this node.
208+
209+
If there is no such node, this returns `None`.
203210
"""
204211
if self.parent_node is None:
205212
return None
@@ -210,7 +217,9 @@ def previous_sibling(self) -> Optional[_AnyNode]:
210217

211218
@property
212219
def next_sibling(self) -> Optional[_AnyNode]:
213-
"""The node immediately following this node. If there is no such node, this returns `None`.
220+
"""The node immediately following this node.
221+
222+
If there is no such node, this returns `None`.
214223
"""
215224
if self.parent_node is None:
216225
return None
@@ -220,16 +229,17 @@ def next_sibling(self) -> Optional[_AnyNode]:
220229
return self.parent_node.child_nodes.item(nth_child+1)
221230

222231
def _nth_child_of_parent(self) -> Optional[int]:
223-
"""Accessor that indicates how many siblings are there preceding this node. if there is no such parent node, this returns `None`.
232+
"""Accessor that indicates how many siblings are there preceding this node.
233+
234+
If there is no such parent node, this returns `None`.
224235
"""
225236
if self.parent_node is None:
226237
return None
227238
return self.parent_node.child_nodes.index(self)
228239

229240
@property
230241
def attributes(self) -> _NamedNodeMap:
231-
"""A `NamedNodeMap` containing the attributes of this node (if it is an `Element`) or `None` otherwise.
232-
"""
242+
"""A `NamedNodeMap` containing the attributes of this node (if it is an `Element`) or `None` otherwise."""
233243
return self._attributes
234244

235245
def _init_attributes(self,
@@ -242,16 +252,18 @@ def _init_attributes(self,
242252

243253
@property
244254
def owner_document(self) -> Optional[_Document]:
245-
"""The `Document` object associated with this node. This is also the `Document` object used to create new nodes. When this node is a `Document` this is `None`.
255+
"""The `Document` object associated with this node.
256+
257+
This is also the `Document` object used to create new nodes.
258+
When this node is a `Document` this is `None`.
246259
"""
247260
if self.node_type == NodeType.DOCUMENT_NODE:
248261
return None
249262
return self._owner_document
250263

251264
def _set_owner_document(self,
252265
owner_document: Optional[_Document] = None) -> None:
253-
"""Indirect accessor to set the 'owner_document' property.
254-
"""
266+
"""Indirect accessor to set the 'owner_document' property."""
255267
self._owner_document = owner_document
256268

257269

w3/python/core/fundamental_interface/NodeList.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ class NodeList(list):
1212

1313
@property
1414
def length(self) -> int:
15-
"""The number of nodes in the list. The range of valid child node indices is 0 to `length`-1 inclusive.
15+
"""The number of nodes in the list.
16+
17+
The range of valid child node indices is 0 to `length`-1 inclusive.
1618
"""
1719
return len(self)
1820

1921

2022
def item(self, index: int) -> Optional[_AnyNode]:
21-
"""Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
23+
"""Returns the indexth item in the collection.
24+
25+
If index is greater than or equal to the number of nodes in the list, this returns null.
2226
2327
Args:
2428
index: Index into the collection.

0 commit comments

Comments
 (0)