Skip to content

Many broken :meth: roles in the docs #91411

Closed as duplicate
Closed as duplicate

Description

@JelleZijlstra
BPO 47255
Nosy @JelleZijlstra, @Fidget-Spinner
PRs
  • bpo-47255: fix method references in functions.rst #32409
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2022-04-08.03:13:27.583>
    labels = ['3.11', '3.9', '3.10', 'docs']
    title = 'Many broken :meth: roles in the docs'
    updated_at = <Date 2022-04-08.15:41:25.420>
    user = 'https://github.com/JelleZijlstra'

    bugs.python.org fields:

    activity = <Date 2022-04-08.15:41:25.420>
    actor = 'kj'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2022-04-08.03:13:27.583>
    creator = 'JelleZijlstra'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 47255
    keywords = ['patch']
    message_count = 3.0
    messages = ['416956', '416957', '416992']
    nosy_count = 3.0
    nosy_names = ['docs@python', 'JelleZijlstra', 'kj']
    pr_nums = ['32409']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue47255'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. JelleZijlstra commented on Apr 8, 2022

      @JelleZijlstra
      MemberAuthor

      The docs for the hash() builtin use :meth:`__hash__`, but this doesn't actually link to the datamodel documentation for __hash__: it needs :meth:`~object.__hash__` instead.

      I'm fixing this in the builtin functions docs, but there are probably more places.

      Why don't we warn when a :meth: link doesn't actually create a link?

    2. JelleZijlstra commented on Apr 8, 2022

      @JelleZijlstra
      MemberAuthor

      There are a lot of places in the rest of the docs that have the same problem:

      Doc % git grep ':meth:`__' | grep -v whatsnew | wc -l
      610

      I wonder if we can make the :meth: role globally default to linking to object.__dunder__. Would that require a change to Sphinx?

    3. Fidget-Spinner commented on Apr 8, 2022

      @Fidget-Spinner
      Member

      It's 3.10 only. Presumably our sphinx version changed then and something broke. In 3.9 and earlier the links are all fine.

      See https://bugs.python.org/issue42182 for a similar issue I raised ages ago.

    4. transferred this issue fromon Apr 10, 2022
    5. StanFromIreland commented on Aug 18, 2025

      @StanFromIreland
      Member

      @AA-Turner / @picnixz Is there anyway to do this in Sphinx? I can not find anything in the docs. Otherwise, this can be closed as a duplicate of the larger effort, #101100.

    6. added
      pendingThe issue will be closed if no feedback is provided
      and removed
      3.11only security fixes
      on Aug 18, 2025
    7. picnixz commented on Aug 18, 2025

      @picnixz
      Member

      AFAIR, no. The meth role needs to be used in the context of a class, whether it's via currentclass (which I don't remember whether it's supported or an open PR on Sphinx' side) or if it's inside a .. class:: directive. We don't have a "global" class being object. What can be achieved is to create an extension that replaces those occurrences with the correct one (that can be easily achieved with RST pre-processing but this still requires the source to be processed so we might slow down a bit the docs).

      An alternative is to replace all :meth:`__dunder__` by |\_\_dunder\_\_| and define .. |__dunder__| replace:: :meth:`~object.__dunder__`. This is the same as writing the extension but the substitution phase always runs (I think we just do some huge str.replace()).

    8. StanFromIreland commented on Aug 18, 2025

      @StanFromIreland
      Member

      I guess we can close then, as replacing them all with something else is the same as fixing them properly (without the additional disadvantages).

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      docsDocumentation in the Doc dirpendingThe issue will be closed if no feedback is provided

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions