-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add content_offset
parameter to nested_parse_with_titles
#11147
Add content_offset
parameter to nested_parse_with_titles
#11147
Conversation
f69851a
to
3b30989
Compare
Previously, `nested_parse_with_titles` always passed `0` as the input offset when invoking `nested_parse`. When parsing the content of a directive, as is a common use case for `nested_parse_with_titles`, this leads to incorrect source file/line number information, as it does not take into account the directive's `content_offset`, which is always non-zero. This issue affects *all* object descriptions due to sphinx-doc#10887. It also affects the `ifconfig` extension. The `py:module` and `js:module` directives employed a workaround for this issue, by wrapping the calls to `nested_parse_with_title` with `switch_source_input`. That worked, but was more complicated (and likely less efficient) than necessary. This commit adds an optional `content_offset` parameter to `nested_parse_with_titles`, and fixes callers to pass the appropriate content offset when needed. This commit eliminates the now-unnecessary calls to `switch_source_input` and instead specifies the correct `content_offset`.
3b30989
to
7879ab1
Compare
Note: An alternative fix would be to modify |
…iptions This addresses the issue described at sphinx-doc/sphinx#11147.
…iptions This addresses the issue described at sphinx-doc/sphinx#11147.
merging latest master update into this, for CI checks |
After the merge, CI seems to pass. |
@jfbu It would be great if this fix can be merged soon. What do you think? |
@jbms it looks good to me but I am the LaTeX contractor here so pinging @AA-Turner |
Oh, I see. Unfortunately he said he was out until Easter: #11116 (comment) |
content_offset
parameter to nested_parse_with_titles
Feature or Bugfix
Purpose
Previously,
nested_parse_with_titles
always passed0
as the input offset when invokingnested_parse
. When parsing the content of a directive, as is a common use case fornested_parse_with_titles
, this leads to incorrect source file/line number information, as it does not take into account the directive'scontent_offset
, which is always non-zero.This issue affects all object descriptions due to #10887. It also affects the
ifconfig
extension.The
py:module
andjs:module
directives employed a workaround for this issue, by wrapping the calls tonested_parse_with_title
withswitch_source_input
. That worked, but was more complicated (and likely less efficient) than necessary.This commit adds an optional
content_offset
parameter tonested_parse_with_titles
, and fixes callers to pass the appropriate content offset when needed.This commit eliminates the now-unnecessary calls to
switch_source_input
and instead specifies the correctcontent_offset
.