Opened 3 weeks ago

Closed 3 weeks ago

#36753 closed Bug (duplicate)

Django docs GitHub source links use incorrect line numbers for version branches

Reported by: Youngkwang Yang Owned by: JekayinOluwa Olabemiwo
Component: Documentation Version: dev
Severity: Normal Keywords: documentation, function link
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django documentation uses Sphinx's .. function:: directive to generate source code links.
while these links correctly point to version-specific branches (e.g., stable/5.2.x),
the line numbers are calculated from the main branch, not the documented version.

reproduce:

  1. visit Django 5.2 documentation: https://docs.djangoproject.com/en/5.2/ref/models/instances/#django.db.models.Model
  2. click the "[source]" link
  3. note the line number in the URL

current behavior:

the source link might be:
(https://github.com/django/django/blob/stable/5.2.x/django/db/models/base.py#L498)

but in the stable/5.2.x branch, the function is actually at line 461, not 498.

expect behavior:

line number should match the actual location in the version-specific branch (e.g., L461 for stable/5.2.x).

the issue appears to be related to how line numbers are calculated during the documentation build process.
relevant code is in https://github.com/django/django/blob/main/docs/_ext/github_links.py#L78:
the links still work, but the inaccurate line numbers can be confusing.

Change History (4)

comment:1 by JekayinOluwa Olabemiwo, 3 weeks ago

Owner: set to JekayinOluwa Olabemiwo
Status: newassigned

comment:2 by JekayinOluwa Olabemiwo, 3 weeks ago

I’ve opened a PR for this: https://github.com/django/django/pull/20307.

Last edited 3 weeks ago by JekayinOluwa Olabemiwo (previous) (diff)

comment:3 by Jacob Walls, 3 weeks ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:4 by David Smith, 3 weeks ago

Resolution: duplicate
Status: assignedclosed

This appears to be a duplicate of #36450

Looking at this again I still think this is an issue at djangoproject.com (1) as the links generated at readthedocs are correct (2).

(1) https://github.com/django/djangoproject.com/issues/2091
(2) https://django.readthedocs.io/en/5.2.x/ref/models/instances.html

Note: See TracTickets for help on using tickets.
Back to Top