Skip to content
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

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

srinivasreddy
Copy link
Contributor

@srinivasreddy srinivasreddy commented Jan 4, 2025

Initial version extracted from PR #24152, which also deleted and modified minidom tests.

Co-authored-by: Karl Dubost karl+github@la-grange.net

Lib/xml/dom/minidom.py Outdated Show resolved Hide resolved
@srinivasreddy srinivasreddy changed the title Update and Add docstrings for functions and methods in minidom.py module gh-63882: Update and Add docstrings for functions and methods in minidom.py module Jan 4, 2025
@terryjreedy terryjreedy changed the title gh-63882: Update and Add docstrings for functions and methods in minidom.py module gh-128508: Update and Add docstrings for functions and methods in minidom.py module Jan 5, 2025
@terryjreedy terryjreedy added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Jan 5, 2025
@terryjreedy terryjreedy changed the title gh-128508: Update and Add docstrings for functions and methods in minidom.py module gh-128508: Add some docstrings to xml.dom.minidom Jan 5, 2025
Copy link
Member

@terryjreedy terryjreedy left a 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 Show resolved Hide resolved
Lib/xml/dom/minidom.py Outdated Show resolved Hide resolved
Comment on lines 1923 to 1924
"""
Clone a node and give it the new owner document.
Returns a copy of node.
Copy link
Member

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.

@@ -204,6 +219,7 @@ def normalize(self):
self.childNodes[:] = L

def cloneNode(self, deep):
"""The Node.cloneNode() method returns a duplicate of the node."""
Copy link
Member

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.

@@ -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."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other cloneNode comment.

@@ -129,6 +138,7 @@ def appendChild(self, node):
return node

def replaceChild(self, newChild, oldChild):
"""Replace an existing node with a new node."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Replace an existing node with a new node."""
"""Replace child node *oldChild* with *newChild*."""

@bedevere-app
Copy link

bedevere-app bot commented Jan 5, 2025

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

srinivasreddy and others added 15 commits January 6, 2025 11:34
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>
Lib/xml/dom/minidom.py Outdated Show resolved Hide resolved
Lib/xml/dom/minidom.py Outdated Show resolved Hide resolved
Lib/xml/dom/minidom.py Outdated Show resolved Hide resolved
Lib/xml/dom/minidom.py Outdated Show resolved Hide resolved
srinivasreddy and others added 2 commits January 6, 2025 18:13
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
@@ -32,6 +32,7 @@


class Node(xml.dom.Node):
"""Define properties accessible on a DOM node."""
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in b97d812

Comment on lines 87 to 90
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.
Copy link
Member

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» ?!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in b97d812

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
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in b97d812

@srinivasreddy srinivasreddy requested a review from merwok January 16, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.