-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use original line numbering when using pyobject include #11653
Comments
In your rst, you have the |
@picnixz Thank you. This worked perfectly. |
I'll assign myself to the issue so that I remember I need to update the docs. |
@picnixz A follow-up question. Is it possible to make |
I don't know. I can look at it at some point. |
Just adding cross-link, this was needed in open3d to reference filename with the python code. isl-org/Open3D#6321 (comment) |
Actually the docs says:
So nothing to do I think. For prepend/append, it appears that the lines are correctly inserted. What do you mean then by "it doesn't work"? Can you give me what are the options you are using? |
Ah ok, actually the option pair is just not supported (explicitly rejected). We could implement some support but then, what would be the line start if you prepend something? |
Yeah, I dont have a good answer for it. I have for example usecase of Open3D, but that is not generic enough for all sphinx users. It would be good to collect other opinions before going for a solution. P.S. For my usecase, prepend means prepend with some text. It should preferrably not have any line number. |
Unfortunately, not putting line numbers would be more tricky because the highlight is done by Pygments and not Sphinx. So maybe there are pygments options for that but otherwise, pretending lines would require the line numbers. Btw, can't you actually use |
Yes caption works but needs CSS update, but that should be easy now. Thank you so much. I am not sure if you still would like to make |
I can make it work, but lines won't be numbered as you would expect. But it'll be a low priority task imho. I'll ask the maintainer upon my return. |
So, I asked myself and I think I won't work on this one unless more people want it (and thus I'm unassigning myself from this issue). Also, from a personal PoV, I think that if someone wants to include non-numbered lines, then it should be outside the pyobject include directive. For me 'prepend' really means prepending something as if it were directly in the included portion of the code. For now, I will close this specific issue and if someone wants the feature of 'prepend without no lineno', a new issue should be opened. |
Describe the bug
This issue is similar to #1583 but when using pyobject.
I did a quick test with latest sphinx version, used a simply python file with main method at line 4-5. Instead of showing line number 4-5, sphinx shows line number 1,2.
I can add
:lineno-start: 4
to fix line number but that defeats the advantage pyobject brings, i.e. as long as function name and behaviour doesnt change, including whole method is the right thing to do in the docs and any changes in file before the method should automatically fix the line numbers.The result is
How to Reproduce
Index.rst
line_width.py
Environment Information
Sphinx extensions
Additional context
No response
The text was updated successfully, but these errors were encountered: