sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

Add `start_line` and `end_line` information in `linkcode`

Open u1735067 opened this issue 4 years ago • 0 comments

Subject: Add start_line and end_line information in linkcode

Feature or Bugfix

  • Feature

Purpose

  • Allow the linkcode extension to add a line anchor in the generated link

Detail

  • Add 2 info keys for linkcode_resolve: start_line and end_line (None by default)
  • Use the viewcode-find-source event first to find the lines informations (to be used with sphinx-autoapi for example)
    • If it failed, optionally (linkcode_line_try_import setting) use the same import method as in sphinx.ext.viewcode (sphinx.pycode.ModuleAnalyzer) to find the line informations (same warning)
  • Documentation updated (not sure this is correct though)

Relates

  • I think it might close https://github.com/sphinx-doc/sphinx/issues/1556

u1735067 avatar Sep 10 '21 23:09 u1735067