Skip to content

Conversation

@stefanor
Copy link
Contributor

@stefanor stefanor commented Oct 13, 2025

Escape things that look like Roman numerals. Docutils 0.22 includes a new roman-numeral interpreter that falls over some of our content. Escape anything that causes trouble.

Python itself isn't using docutils 0.22 yet for its doc generation, but some Linux distributions have updated to it.

An alternative to GH-139258


📚 Documentation preview 📚: https://cpython-previews--140031.org.readthedocs.build/

Escape things that look like Roman numerals. Docutils 0.22 includes a
new roman-numeral interpreter that falls over some of our content.
Escape anything that causes trouble.

Python itself isn't using docutils 0.22 yet for its doc generation, but
some Linux distributions have updated to it.
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Well, if this change is actually sufficient it's good. But that means that we need to be careful when adding roman-like text. What I find annoying is the Q/A modifications, but I don't know how we could do otherwise.

@picnixz picnixz changed the title gh-139257: docutils 0.22 support gh-139257: escape roman-like words to support docutils 0.22 Oct 13, 2025
@picnixz picnixz changed the title gh-139257: escape roman-like words to support docutils 0.22 gh-139257: escape enumerator-like letters to support docutils 0.22 Oct 13, 2025
@AA-Turner
Copy link
Member

This feels like a Docutils bug if it requires this much escaping?

A

@stefanor stefanor requested a review from hugovk as a code owner October 13, 2025 11:02
@picnixz
Copy link
Member

picnixz commented Oct 13, 2025

This feels like a Docutils bug if it requires this much escaping?

That's because we have no way of disabling roman numeral handling in docutils >= 0.22, unless we specify compatible enumerator-like objects (that are implementation details in docutils and only in >= 0.22). See the issue for the commit that changed this.

@picnixz
Copy link
Member

picnixz commented Oct 13, 2025

Note: what would be ideal is for docutils to check first the return value of a converter, and if it is None, then assume that the conversion is disabled. That would be the cleanest way to do it (and our monkey patch would be compatible with older docutils versions)

@stefanor
Copy link
Contributor Author

This feels like a Docutils bug if it requires this much escaping?

Presumably that's what @birkenfeld thought when implementing the monkey-patch in #48813.

The alternative here is to re-instate #139258 and update the monkey-patch.

@stefanor
Copy link
Contributor Author

I added a second commit to remove the monkey-patch entirely. But instead of doing that, we could make it raise an explicit exception, to avoid accidentally introducing Roman-numbered lists.

@hugovk
Copy link
Member

hugovk commented Oct 13, 2025

What I find annoying is the Q/A modifications, but I don't know how we could do otherwise.

Other FAQs use headings for the questions, which also makes them linkable:

@picnixz
Copy link
Member

picnixz commented Oct 13, 2025

Other FAQs use headings for the questions, which also makes them linkable:

That would indeed be better. I think we have two distinct issues:

  • Transform Q/A into headers (independent of docutils support, this is indeed better and more helpful for users and for us if we want to link them).
  • Either patch our current docs to avoid the enumerator conversion, or patch docutils directly so that we can provide a "noop" enumerator.

We don't have a single clean method to disable roman lists across
docutils versions, but we can blow up the bulid cleanly...
Docutils 0.22 does not allow referencing a link that was implicitly
named earlier in the document, it complains:

  ERROR: Duplicate target name, cannot be used as a unique reference:
  "basic authentication".
Docutils 0.22 doesn't allow the contents directive to be used within an
only directive, it complains:

  ERROR: The "contents" directive may not be used within topics or body
  elements.
@stefanor
Copy link
Contributor Author

But instead of doing that, we could make it raise an explicit exception, to avoid accidentally introducing Roman-numbered lists.

Changed to that.

Also, added a couple of additional commits for other docutils 0.22 issues.

@hugovk
Copy link
Member

hugovk commented Nov 29, 2025

See PR #142056 for an alternative.

@AA-Turner AA-Turner closed this Nov 29, 2025
@stefanor stefanor deleted the docutils-0.22 branch November 29, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants