-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-128508: Add some docstrings to xml.dom.minidom #128477
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not worked on docstrings, especially not for anything other that IDLE, for years. The best reference I know is the Multiline String section of https://peps.python.org/pep-0257/, though the thoroughness described there may be rare. Still, these need more work. The xml.dom and xml.dom.minidom docs should be a basis for corresponding docstrings. Usefully summarizing behavior can be hard.
I think a blurb should be added, but this can wait.
Lib/xml/dom/minidom.py
Outdated
""" | ||
Clone a node and give it the new owner document. | ||
Returns a copy of node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove \n after """. Add after this line. But this revision seems wrong as it omits mention of newOwnerDocument. I would have to read code to suggest improvement.
Lib/xml/dom/minidom.py
Outdated
@@ -204,6 +219,7 @@ def normalize(self): | |||
self.childNodes[:] = L | |||
|
|||
def cloneNode(self, deep): | |||
"""The Node.cloneNode() method returns a duplicate of the node.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "Return a duplicate ...", but needs to explain 'deep' (I suspect it is a boolean.) Docstrings are for quick reminders when coding, and 'deep' is not obvious.
Lib/xml/dom/minidom.py
Outdated
@@ -1341,6 +1357,7 @@ def _get_internalSubset(self): | |||
return self.internalSubset | |||
|
|||
def cloneNode(self, deep): | |||
"""The Node.cloneNode() method returns a duplicate of the node.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other cloneNode comment.
Lib/xml/dom/minidom.py
Outdated
@@ -129,6 +138,7 @@ def appendChild(self, node): | |||
return node | |||
|
|||
def replaceChild(self, newChild, oldChild): | |||
"""Replace an existing node with a new node.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Replace an existing node with a new node.""" | |
"""Replace child node *oldChild* with *newChild*.""" |
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
…o()` (python#128337) These methods combine `_delete()` and `copy()`, but `_delete()` isn't part of the public interface, and it's unlikely to be added until the pathlib ABCs are made official, or perhaps even later.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
…er test (python#128338) In the tests for `pathlib.Path.walk()`, avoid using the path class under test (`self.cls`) in test setup. Instead we use `os` functions in `test_pathlib`, and direct manipulation of `DummyPath` internal data in `test_pathlib_abc`.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
pythongh-128455) Add `BOLT_COMMON_FLAGS` with `-update-debug-sections` Co-authored-by: Gregory Szorc <gregory.szorc@gmail.com>
…he atomic operation (pythongh-128196)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Lib/xml/dom/minidom.py
Outdated
@@ -32,6 +32,7 @@ | |||
|
|||
|
|||
class Node(xml.dom.Node): | |||
"""Define properties accessible on a DOM node.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s strange to have a class docstring start with a verb; it makes sense for a method (that does something), but a class usually represents a thing (noun), it does not do something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in b97d812
Lib/xml/dom/minidom.py
Outdated
https://dom.spec.whatwg.org/#dom-node-insertbefore | ||
The insertBefore(node, child) method, when invoked, | ||
must return the result of pre-inserting node into | ||
this before child. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the docstring should document what the method does, not quote parts of a spec.
I would suggest simpler wording, but I don’t understand the existing one («the result of pre-inserting node into this before child» ?!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in b97d812
Lib/xml/dom/minidom.py
Outdated
The insertBefore(node, child) method, when invoked, | ||
must return the result of pre-inserting node into | ||
this before child. | ||
See also https://dom.spec.whatwg.org/#concept-node-pre-insert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have links like this in the reST docs, not docstrings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in b97d812
Initial version extracted from PR #24152, which also deleted and modified minidom tests.
Co-authored-by: Karl Dubost karl+github@la-grange.net