Inconsistent source links in the docs

I find the “source” links in the docs really useful, but noticed that some pages in the docs have no source links, while in other places some functions will have source links and not others.

I can’t tell how the source links are added when the docs are generated, so I’m not sure how to fix this? Is it a manual process somewhere?

Some examples:

Some further digging… I think the source links are added by the linkcode_resolve function, which is a Sphinx-specific thing. Perhaps this logic could do with some investigating/tweaking?

source links are generated by Sphinx directives like .. function::, .. class::, or .. method:: in the RST files.

See: reStructuredText markup

you’re right that linkcode_resolve is what handles the GitHub link generation, but it looks like there’s a bug in how the line numbers are calculated.

as for the missing links (like format_lazy or the templates/builtins docs), they’re probably just not using those Sphinx directives, so the source link doesn’t get generated.