Skip to content
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 support for line numbering in the viewcode extention #11204

Closed
wants to merge 7 commits into from

Conversation

12rambau
Copy link

@12rambau 12rambau commented Feb 19, 2023

add support for line numbering in the viewcode extention

Feature or Bugfix

Feature

Detail

  • I added a viewcode_show_lineos variale (default to False) to control wether or not line number shoud be added to the viewcode pages.
  • This change the highlighter behavior in collect_pages method.
  • The highliter will create a table with all the line number in one coloum and all the code in a second one. As viewcode is customizeing the first and last line of each tag, I created an offset variable that search for the second column tag and simply add it to point to correct lines when modifying the content.
  • The new variable is documented and a short test check for the existence of the table in the output file.
  • I decided not to change the display of the line numbers.
  • for testing I checked using an extra build if the items are still modified in the table the same way.

I have 1 questions:

  • what's the use this line:
    lines[0:1] = [before + '<pre>', after]
    It's 14 years old and when I check the output of line I only see 1 <pre> tag meaning that this is not changing anything.

Relates

Fix #10589

@12rambau 12rambau marked this pull request as draft February 19, 2023 17:51
legacy addition from my side, I should have used posargs
@12rambau 12rambau marked this pull request as ready for review February 19, 2023 19:08
@12rambau 12rambau mentioned this pull request Mar 24, 2023
4 tasks
@AA-Turner AA-Turner added this to the some future version milestone Apr 29, 2023
@AA-Turner
Copy link
Member

I believe everything in this PR was contained in the older #6319 -- if there are any additional tests or etc we should add, please re-open!

A

@AA-Turner AA-Turner closed this Jul 28, 2023
@12rambau 12rambau deleted the viewcode branch July 28, 2023 05:22
@12rambau
Copy link
Author

Ah sorry to have created a duplication. I checked before starting coding but didn't find out

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

display the line numbers using sphinx.ext.viewcode?
2 participants