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

#9413 Declare py namespace on document root to generate valid xml #9416

Closed
wants to merge 1 commit into from

Conversation

nemani
Copy link

@nemani nemani commented Jul 7, 2021

Subject: Declare py namespace in XML writer.

Feature or Bugfix

  • Bugfix

Purpose

  • Autodoc uses py:class, py:module, etc as attributes for nodes. This causes errors as the generated xml does not have a namespace for py declared. This PR fixes this by declaring a xmlns:py at the document level.

Relates

Please recommend what URI to use for the declaration of the py xml namespace

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

LGTM with nits.

@@ -71,6 +71,7 @@ def write_doc(self, docname: str, doctree: Node) -> None:
# work around multiple string % tuple issues in docutils;
# replace tuples in attribute values with lists
doctree = doctree.deepcopy()
doctree.document.attributes["xmlns:py"] = "https://github.com/sphinx-doc/sphinx/issues/9413"
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 not good to set the URL of #9413. I'd like to use a better one for this. What kind of URL should we use instead? document? project page (GitHub)?

Copy link
Author

Choose a reason for hiding this comment

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

Maybe we can point to the documentation of the domains?

Copy link
Member

Choose a reason for hiding this comment

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

We can point only the URL of the "bundled" domains: https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html
But this document does not contains the 3rd party domains. For example, sphinx-http-domain: https://pypi.org/project/sphinx-http-domain/.

Copy link
Author

Choose a reason for hiding this comment

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

Maybe we can keep it as an attribute in the domain class with default pointing to the "bundled" domains doc?

@@ -71,6 +71,7 @@ def write_doc(self, docname: str, doctree: Node) -> None:
# work around multiple string % tuple issues in docutils;
# replace tuples in attribute values with lists
doctree = doctree.deepcopy()
doctree.document.attributes["xmlns:py"] = "https://github.com/sphinx-doc/sphinx/issues/9413"
Copy link
Member

Choose a reason for hiding this comment

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

The "py" namespace comes from the domains mark-up.
https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html

And we have many kinds of domains (ex. C, C++, etc.). And developers can add them via API. So it would be better to add it with such code:

Suggested change
doctree.document.attributes["xmlns:py"] = "https://github.com/sphinx-doc/sphinx/issues/9413"
for domain in self.env.domains.values():
xmlns = "xmlns:" + domain.name
doctree.document.attributes[xmlns] = "https://URL/to/somewhere"

@tk0miya tk0miya added this to the 4.2.0 milestone Jul 8, 2021
@tk0miya tk0miya modified the milestones: 4.2.0, 4.3.0 Sep 12, 2021
@tk0miya tk0miya modified the milestones: 4.3.0, 4.4.0 Nov 8, 2021
@tk0miya
Copy link
Member

tk0miya commented Jan 15, 2022

Now I merged #10100 instead. Thank you for your contribution!

@tk0miya tk0miya closed this Jan 15, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants