question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Display line numbers when viewing source code

See original GitHub issue

Problem Description

Two related enhancement proposals:

  1. Are there any chances to (optionally) display source code line numbers in html documentation?
  2. Are there any chances to link to specific source code line numbers in html documentation?

Proposal

  1. When you click view-source at the right side of a function definition (or Class, or whatever), source code lines are shown. Is it possible that these lines come with the line number shown on the left side? (as an option, like many text editors offer)
  2. I noticed that each line of source code is rendered as a single <span class="sd">source code</span> If each span is preceded with a <a name="lnXXXX"> tag, then that line (number XXXX) would be linkable using module.html#lnXXXX

Alternatives

  1. For showing line numbers:
  • Offer this as an option in pdoc.render.configure(show_line_numbers: bool)
  • Offer this as a clickable option in html output, next to view-source on the right side
  • Offer both options
  1. For introducing linking anchors:
  • Offer this as an option in pdoc.render.configure(create_line_anchors: bool) Probably this would imply that view-source should be active by default in rendered html output as well, not needing to click anywhere (otherwise, module.html#lnXXXX links to specific span tag anchors won’t do anything if those span tags are not already visible when module.html is loaded).

Additional context

https://pdoc.dev/docs/pdoc/render.html#configure https://pdoc.dev/docs/pdoc/doc.html#Doc.source_lines Useful to complement use case described in #325 and specially in #327

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mhilscommented, Jan 7, 2022

I think line numbers should be generally useful for everyone, no need to make it an option. There are line numbers on GitHub as well and you cannot configure it. 😃

I’ve implemented the necessary changes in https://github.com/mitmproxy/pdoc/compare/main...mhils:linenumbers, but we first need to wait for a pygments fix to ship in https://github.com/pygments/pygments/pull/2026.

1reaction
abubelinhacommented, Feb 5, 2022

I’m afraid you got me wrong. I wasn’t trying to force any pdoc changes with my comments in #343 I only wanted to share the solution I had found for my problem (originally stated above in this issue). So other newbies like me could find it useful. Please acept my apologies, it wasn’t necesary to answer me any further or locking conversation (there were no pending questions, actually).

Sorry again

Read more comments on GitHub >

github_iconTop Results From Across the Web

html: How to add line numbers to a source code block
Without using float , there is a simple solution so text isn't wrapped under the line numbers. The trick is setting a margin...
Read more >
Display line numbers for code - Visual Studio (Windows)
You can show or hide line numbers in your code. Here's how. On the menu bar, choose Tools > Options. Expand the Text...
Read more >
visualstudio-docs/how-to-display-line-numbers-in-the-editor ...
You can show or hide line numbers in your code. Here's how. On the menu bar, choose Tools > Options. Expand the Text...
Read more >
Firefox: Find Line Numbers in View Source
To find line numbers: From the Firefox menu, select View > Page Source. Firefox opens the page source in a new window. Type...
Read more >
Source code line numbers and JavaScript - All this - Dr. Drang
The purpose of “toggleLN” is to go through the <code> element associated with the clicked button and turn off the display of all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found