peps icon indicating copy to clipboard operation
peps copied to clipboard

Infra: Use an option instead of argument in banner directives

Open pradyunsg opened this issue 1 year ago • 2 comments

(context for PEP authors: This PR will not change how a specific PEP is presented or how it would be rendered -- if you're not interested in PEP infra changes, please feel welcome to unsubscribe)

This is an "infra" change, tweaking the specific reST syntax structures being used in the directives used to provide document-wide deprecations or other links. See also https://github.com/python/peps/issues/2719, which tracks the wider effort around this.

For the problem that motivated this change, see https://github.com/python/peps/pull/3682 and https://github.com/python/peps/pull/3756. See the commit message for the details of what the problem's cause was and how this change deals with that.


📚 Documentation preview 📚: https://pep-previews--3765.org.readthedocs.build/

pradyunsg avatar Apr 28 '24 18:04 pradyunsg

Sphinx presents a clear error message if you have any content without whitespace after these banner directive's options:

With this change added in...

--- a/peps/pep-0560.rst
+++ b/peps/pep-0560.rst
@@ -12,6 +12,7 @@ Resolution: https://mail.python.org/pipermail/python-dev/2017-December/151038.ht
 .. canonical-doc::
    :related: :external+python:meth:`object.__class_getitem__` and
              :external+python:meth:`object.__mro_entries__`
+   Content
 
 Abstract
 ========

Running a build results in:

Sphinx parallel build error:
docutils.utils.SystemMessage: /Users/pradyunsg/Developer/github/peps/peps/pep-0560.rst:12: (ERROR/3) Error in "canonical-doc" directive:
invalid option block.

.. canonical-doc::
   :related: :external+python:meth:`object.__class_getitem__` and
             :external+python:meth:`object.__mro_entries__`
   Content
Sphinx exited with exit code: 2

While this behaviour is mentioned in the commit message, I figured it'd be useful to have this error message mentioned here to provide additional context.

This is a good place to also mention a caveat(?) with this approach: If there's an additional space (i.e. indentation of Content is greater than that of :related:, it'll be considered a part of the option's value). I don't think it's an equivalent failure mode to what we have right now but also... I don't see any way to avoid this behaviour from docutils/reST.

pradyunsg avatar Apr 28 '24 18:04 pradyunsg