Skip to content

Use roles :data: and :const: for module-level variables and constants #106892

Closed

Description

@serhiy-storchaka

Role :data: is purposed for marking a module-level variable. [1] But role :attr: is often used instead in cases like sys.modules. While technically any module-level variable is accessible as an attribute, I think that it would be better to use more special role :data:.

[1] https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#role-py-data

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    docsDocumentation in the Doc dir
    3.11only security fixes
    3.12only security fixes
    3.13only security fixes
    on Jul 19, 2023
  2. changed the title [-]Use role :data: for module-level variables[/-] [+]Use roles :data: and :const: for module-level variables and constants[/+] on Jul 19, 2023
  3. added 2 commits that reference this issue on Jul 19, 2023
  4. erlend-aasland commented on Jul 20, 2023

    @erlend-aasland
    Contributor

    I agree that :data: is better than :attr:. Why not :py:data:?

  5. serhiy-storchaka commented on Jul 20, 2023

    @serhiy-storchaka
    MemberAuthor

    Because it is the default domain. It can make some sense in the C API documentation to distinguish with the C domain (which is not default), but in the rest of documentation we do not add the py: prefix.

  6. erlend-aasland commented on Jul 20, 2023

    @erlend-aasland
    Contributor

    Yes, I know that this was the general guideline before, and I'm fine with using the default (py) domain. I saw some discussion about this recently, but I cannot find it. Perhaps @CAM-Gerlach or @hugovk remembers?

  7. hugovk commented on Jul 21, 2023

    @hugovk
    Member

    Nope, I don't recall...

  8. added 5 commits that reference this issue on Jul 21, 2023
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

    3.11only security fixes3.12only security fixes3.13only security fixesdocsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions