sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

display the line numbers using sphinx.ext.viewcode?

Open 12rambau opened this issue 3 years ago • 2 comments

I'm using the sphinx.ext.viewcode to document my API. Is it possible to display the line numbers on the produced code-block and if yes how ?

I've tried to find an html_option in the docs but I didn't find anything. As this question is on stale for a month on SO, I assumed it was not available in Sphinx so I'm moving it to a feature request.

12rambau avatar Jun 20 '22 06:06 12rambau

comment that could lead to a PR, I found this bit of code in the viewcode extention, https://github.com/sphinx-doc/sphinx/blob/93226ca91acdba7fdf0c7efde27ccc9c28cf7ece/sphinx/ext/viewcode.py#L251

If I understand how to create a new configuration parameter I could change its value and add line number as well.

12rambau avatar Jul 14 '22 14:07 12rambau

PR is welcome. Please use add_config_value() to add a new configuration variable.

tk0miya avatar Jul 16 '22 15:07 tk0miya

Closed by #6319.

A

AA-Turner avatar Jul 28 '23 04:07 AA-Turner