Skip to content

Close #5977: :var: field do not create a cross-reference … - #8638

Merged
tk0miya merged 2 commits into
sphinx-doc:masterfrom
tk0miya:5977_dont_link_var_field
Jan 5, 2021
Merged

tk0miya merged 2 commits into
sphinx-doc:masterfrom
tk0miya:5977_dont_link_var_field

Conversation

@tk0miya

@tk0miya tk0miya commented Jan 1, 2021

Copy link
Copy Markdown
Member

Feature or Bugfix

  • Feature
  • Bugfix

Purpose

  • Since its beginning, :var: field has created a cross-reference to the
    attribute having the same name. It is meaningful only if the attribute
    is documented by py:attribute directive. It means the :var: field
    and :attr: role are almost the same and conflicted. Additionally, the
    cross-reference points incorrect variable if the target is not
    documented.
  • Thus, the cross-reference feature of :var: field is disabled.
  • refs: Instance variables link to other variables of the same name in the project #5977

Since its beginning, `:var:` field has created a cross-reference to the
attribute having the same name.  It is meaningful only if the attribute
is documented by `py:attribute` directive.  It means the `:var:` field
and `:attr:` role are almost the same and conflicted.  Additionally,
the cross-reference points incorrect variable if the target is not
documented.

Thus, the cross-reference feature of `:var:` field is disabled.
@tk0miya tk0miya added type:bug type:enhancement enhance or introduce a new feature domains:py labels Jan 1, 2021
@tk0miya tk0miya added this to the 3.5.0 milestone Jan 1, 2021
@tk0miya
tk0miya requested a review from shimizukawa January 1, 2021 13:54
@tk0miya tk0miya modified the milestones: 3.5.0, 4.0.0 Jan 1, 2021
@tk0miya tk0miya changed the title @tk0miya Close #5977: :var: field do not create a cross-reference … Close #5977: :var: field do not create a cross-reference … Jan 1, 2021

@shimizukawa shimizukawa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tk0miya
tk0miya merged commit 5ba5602 into sphinx-doc:master Jan 5, 2021
@tk0miya
tk0miya deleted the 5977_dont_link_var_field branch January 5, 2021 16:00
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 18, 2021
piyushhhxyz added a commit to piyushhhxyz/sphinx that referenced this pull request Apr 10, 2026
Instance variables documented with :var:, :ivar:, or :cvar: had their names
automatically turned into cross-references (using rolename='obj'), which caused
them to link to unrelated variables with the same name elsewhere in the project.

The fix removes rolename='obj' from the 'variable' PyTypedField definition so
variable names are no longer wrapped in pending_xref nodes. The type annotations
(typerolename='class') are preserved, so variable types are still cross-referenced.

Fixes sphinx-doc#8638
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

domains:py type:bug type:enhancement enhance or introduce a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants