Skip to content

gh-151943: Document the CharacterData interface and other DOM members - #155632

Open
serhiy-storchaka wants to merge 11 commits into
python:mainfrom
serhiy-storchaka:doc-characterdata
Open

gh-151943: Document the CharacterData interface and other DOM members#155632
serhiy-storchaka wants to merge 11 commits into
python:mainfrom
serhiy-storchaka:doc-characterdata

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 12, 2026

Copy link
Copy Markdown
Member

The CharacterData interface was not mentioned in the documentation at all, although Text, Comment and CDATASection inherit from it, so its length attribute and mutation methods were not documented.

Other implemented members which were omitted are documented too: Node.ownerDocument, Node.isSupported(), Node.getUserData(), Node.setUserData(), Document.doctype, Document.implementation, Document.documentURI, Document.strictErrorChecking, Document.createDocumentFragment(), Document.createCDATASection(), Document.importNode(), Document.renameNode(), Element.setIdAttribute(), Element.setIdAttributeNS(), Element.setIdAttributeNode(), Attr.isId, Attr.ownerElement, Text.wholeText, Text.splitText() and Text.replaceWholeText().

…embers

CharacterData was not mentioned at all, although Text, Comment and
CDATASection inherit from it.  Also document members which are
implemented, but were omitted: Node.ownerDocument, Node.isSupported(),
Node.getUserData(), Node.setUserData(), Document.doctype,
Document.implementation, Document.documentURI,
Document.strictErrorChecking, Document.createDocumentFragment(),
Document.createCDATASection(), Document.importNode(),
Document.renameNode(), Element.setIdAttribute(),
Element.setIdAttributeNS(), Element.setIdAttributeNode(), Attr.isId,
Attr.ownerElement, Text.wholeText, Text.splitText() and
Text.replaceWholeText().
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Aug 12, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Aug 12, 2026
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 12, 2026
@read-the-docs-community

read-the-docs-community Bot commented Aug 12, 2026

Copy link
Copy Markdown

…Map methods

Add class directives for all documented DOM classes, so that references
to them resolve.  They use :no-typesetting:, because the classes are not
instantiated directly and the sections already introduce them.

Add a section for DocumentFragment, which was referenced, but had no
section of its own, and document Document.getElementById() and the
getNamedItem(), setNamedItem() and removeNamedItem() families of
NamedNodeMap, which are implemented, but were omitted.

Silence references to the illustrative names in the IDL mapping example
and to the PYTHON_DOM environment variable.
…bers

The node type constants and the exception code constants were referenced,
but never documented.  Document them, including ENTITY_REFERENCE_NODE,
DOCUMENT_FRAGMENT_NODE and VALIDATION_ERR, which were not even mentioned,
and the ValidationErr exception.

Qualify references to attributes and methods with the class which defines
them, so that they resolve, and refer to xml.dom.minidom for unlink(),
which is not part of the DOM.
It no longer produces warnings in the Sphinx nit-picky mode.
….specified

Entity and Notation were not mentioned at all, although they are
implemented and DocumentType.entities and DocumentType.notations
contain such nodes.
@StanFromIreland StanFromIreland changed the title gh-155631: Document the CharacterData interface and other DOM members gh-151943: Document the CharacterData interface and other DOM members Aug 12, 2026
Comment thread Doc/library/xml.dom.rst Outdated
Comment thread Doc/library/xml.dom.rst Outdated
Comment thread Doc/library/xml.dom.rst Outdated
serhiy-storchaka and others added 5 commits August 28, 2026 09:27
Co-authored-by: dgelessus <dgelessus@users.noreply.github.com>
…Attr

CDATASection extends Text, as in the DOM Level 1 and Level 2 IDL.
NodeList.item() returns None for an index out of range, it does not
forbid such index.  Attribute nodes are not part of the document tree.
Reported in pythongh-156388:

* which node types can have children, and of which types;
* the values of nodeName and nodeValue for every node type;
* childNodes is a NodeList;
* NodeList does not inherit from Node;
* when DocumentType.publicId and systemId are None;
* "minidom" is the only well-known implementation name;
* which mapping methods minidom adds to a NamedNodeMap, and where
  they are not available.
It is a list subclass, not a replacement for NodeList, and nodes which
cannot have children use a tuple subclass.  Remove the note about
earlier versions of Python which did not support the official API.
The table above gives the value for every node type, and none of them
is None.
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Aug 28, 2026
…nd NEWS

Suggested by dgelessus in the review of pythonGH-155632, where the same
wording was used.
@serhiy-storchaka

Copy link
Copy Markdown
Member Author

I applied suggestions and addressed more points from #156388.

… docs

Each of the NodeList and NamedNodeMap interfaces has two implementations
in minidom, which support additional operations.  Move this and the
notes about strictErrorChecking and Attr.specified out of the
documentation of the generic DOM interface.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants