You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The @fmt_docstring decorator is responsible for inserting common docstrings into placeholders. While it works well in general, it currently raises a KeyError when encountering an undefined placeholder. For example, in #3811, we're writing equations in ReST syntax:
:math:`mantissa * 10 ^ {exponent}`
and it reports KeyError: exponent because we don't have exponent defined in COMMON_STRINGS. This requires us to escape such placeholders by writing the equation like
:math:`mantissa * 10 ^ {{exponent}}`
which is inconvenient, and sometimes we may forget to do it and then see the KeyError exception surprisingly.
Current Behavior:
If {exponent} (or any other undefined placeholder) appears in a docstring, fmt_docstring raises a KeyError.
To work around this, users must write {{exponent}} to ensure the curly braces are preserved in the final docstring.
Expected Behavior:
{exponent} (or any other undefined placeholder) should be treated as a literal string unless it matches a defined common docstring key.
Users should not have to manually escape curly braces unless explicitly required.
Pros
No need to escape curly braces, especially for equations
The raw docstrings are more readable
Cons
If there are any typos in common placeholder (e.g., projection typed as projecti), then the literal string {projecti} is shown in the HTML documentation. It no longer raises a KeyError exception, and we may miss the typo.
Are you willing to help implement and maintain this feature?
Yes
The text was updated successfully, but these errors were encountered:
Description of the desired feature
The
@fmt_docstring
decorator is responsible for inserting common docstrings into placeholders. While it works well in general, it currently raises aKeyError
when encountering an undefined placeholder. For example, in #3811, we're writing equations in ReST syntax:and it reports
KeyError: exponent
because we don't haveexponent
defined inCOMMON_STRINGS
. This requires us to escape such placeholders by writing the equation likewhich is inconvenient, and sometimes we may forget to do it and then see the KeyError exception surprisingly.
Current Behavior:
{exponent}
(or any other undefined placeholder) appears in a docstring,fmt_docstring
raises a KeyError.{{exponent}}
to ensure the curly braces are preserved in the final docstring.Expected Behavior:
{exponent}
(or any other undefined placeholder) should be treated as a literal string unless it matches a defined common docstring key.Pros
Cons
If there are any typos in common placeholder (e.g.,
projection
typed asprojecti
), then the literal string{projecti}
is shown in the HTML documentation. It no longer raises a KeyError exception, and we may miss the typo.Are you willing to help implement and maintain this feature?
Yes
The text was updated successfully, but these errors were encountered: