gh-148961 : Use parsed-literal for the slot column legend in c-api/typeobj.rst#148962
gh-148961 : Use parsed-literal for the slot column legend in c-api/typeobj.rst#148962Chang-LeHung wants to merge 1 commit intopython:mainfrom
Conversation
| **"D"**: default (if slot is set to ``NULL``) | ||
|
|
||
| .. code-block:: none | ||
| .. parsed-literal:: |
There was a problem hiding this comment.
Thanks for the pointer to #135828.
If we want to drop parsed-literal from this PR, I see two reasonable replacements:
Option A — keep code-block:: none, just remove the stray emphasis markers
In the original second block, *PyType_Ready* and *NULL* are wrapped in asterisks, but code-block:: renders them verbatim, so they show up as literal * in the output. The first block doesn't have them. The minimal fix is just to remove those asterisks so the second block is consistent with the first:
.. code-block:: none
- X - type slot is inherited via *PyType_Ready* if defined with a *NULL* value
+ X - type slot is inherited via PyType_Ready if defined with a NULL value
% - the slots of the sub-struct are inherited individually
G - inherited, but only in combination with other slots; see the slot's description
? - it's complicated; see the slot's descriptionThe visual layout stays exactly as it is today; we give up the cross-reference / inline-literal improvements.
Option B — switch to a line block (|)
A plain reST line block: no parsed-literal, no syntax-highlighting code path, translation-safe, and inline :c:func: / NULL still work. Visually it's a compact multi-line paragraph (no bullets, no extra spacing) — close to the original block-style legend, just without the gray code-block background:
**"D"**: default (if slot is set to ``NULL``)
| ``X`` -- :c:func:`PyType_Ready` sets this value if it is ``NULL``
| ``~`` -- :c:func:`PyType_Ready` always sets this value (it should be ``NULL``)
| ``?`` -- :c:func:`PyType_Ready` may set this value depending on other slots
Also see the inheritance column ("I").
**"I"**: inheritance
| ``X`` -- type slot is inherited via :c:func:`PyType_Ready` if defined with a ``NULL`` value
| ``%`` -- the slots of the sub-struct are inherited individually
| ``G`` -- inherited, but only in combination with other slots; see the slot's description
| ``?`` -- it's complicated; see the slot's descriptionmake html with --fail-on-warning passes locally on both options.
A keeps the diff minimal; B preserves the original motivation of the PR (PyType_Ready as a cross-reference, NULL as an inline literal).
The two small legends under the
PyTypeObject"Quick Reference" table inDoc/c-api/typeobj.rstexplain what each character in the"D"(default)and
"I"(inheritance) columns means. They were wrapped in.. code-block:: none, so reST inline markup inside them was renderedverbatim:
*PyType_Ready*and*NULL*showed literal asterisks.PyType_Readywas plain text instead of a cross-reference link.NULLwas plain text instead of theNULLinline literal usedthroughout the rest of the page.
Before:
After:
c-api/typeobj.rstlegend is not rendered because of.. code-block:: none#148961📚 Documentation preview 📚: https://cpython-previews--148962.org.readthedocs.build/