# Inconsistent source links in the docs

**URL:** <https://forum.djangoproject.com/t/inconsistent-source-links-in-the-docs/43501>\
**Category:** Documentation\
**Created:** [November 17, 2025, 8:29pm UTC](https://forum.djangoproject.com/t/inconsistent-source-links-in-the-docs/43501 "2025-11-17T20:29:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuartmaxwell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/stuartmaxwell/32/1135_2.png) [@stuartmaxwell](https://forum.djangoproject.com/u/stuartmaxwell)\
**Post date:** [November 17, 2025, 8:29pm UTC](https://forum.djangoproject.com/t/inconsistent-source-links-in-the-docs/43501/1 "2025-11-17T20:29:24Z")

</div>

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:

- [https://docs.djangoproject.com/en/5.2/ref/templates/builtins/](https://docs.djangoproject.com/en/5.2/ref/templates/builtins/) has no links to the source code anywhere on this page
- [https://docs.djangoproject.com/en/5.2/ref/utils/#django.utils.text.format\_lazy](https://docs.djangoproject.com/en/5.2/ref/utils/#django.utils.text.format_lazy) no source code link
- [https://docs.djangoproject.com/en/5.2/ref/utils/#django.utils.text.slugify](https://docs.djangoproject.com/en/5.2/ref/utils/#django.utils.text.slugify) this does have a link to the source code, but the line number is slightly wrong (still gets you to the right place though)

---

<div class="post-metadata">

**Author:** ![stuartmaxwell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/stuartmaxwell/32/1135_2.png) [@stuartmaxwell](https://forum.djangoproject.com/u/stuartmaxwell)\
**Post date:** [November 17, 2025, 9:36pm UTC](https://forum.djangoproject.com/t/inconsistent-source-links-in-the-docs/43501/2 "2025-11-17T21:36:45Z")

</div>

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?

> <https://github.com/django/django/blob/3c005b5f79bf6d71f3f4c3692ed670e1722b0fb6/docs/conf.py#L453C1-L459C51>

> **[sphinx.ext.linkcode – Add external links to source code — Sphinx documentation](https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html)**

---

<div class="post-metadata">

**Author:** ![2ykwang](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/2ykwang/32/30619_2.png) [@2ykwang](https://forum.djangoproject.com/u/2ykwang)\
**Post date:** [November 23, 2025, 5:34pm UTC](https://forum.djangoproject.com/t/inconsistent-source-links-in-the-docs/43501/3 "2025-11-23T17:34:17Z")

</div>

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

See: [reStructuredText markup](https://devguide.python.org/documentation/markup/#directives)

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.
