Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodoc: add :canonical: for all object types #9039

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

flying-sheep
Copy link
Contributor

@flying-sheep flying-sheep commented Mar 27, 2021

Feature or Bugfix

  • Feature

Purpose

cc @tk0miya

@flying-sheep
Copy link
Contributor Author

flying-sheep commented Mar 27, 2021

OK, one test fails, how should we fix it?

It happens in a newer Python (e.g. 3.9), in case of a TypeVar that’s a class attribute.

__qualname__ is not set, so the code falls back to __name__, which is wrong.

grafik

@tk0miya
Copy link
Member

tk0miya commented Apr 3, 2021

Could you let me know why do you add :canonical: options for everything? In my understanding, nobody refers the canonical functions, methods and others. I'd like to know the real usecase of this.

@flying-sheep
Copy link
Contributor Author

Everything can be initially defined in one module and be exported in another, not just classes.
As you can see in the test changes, it does happen!

Also I thought that one use case of this is that automatically generated reStructuredText code referring to f'{obj.__module__}.{obj.__qualname__}' works… Only inferring it for classes leaves it broken for functions and methods.

@flying-sheep
Copy link
Contributor Author

Hi @tk0miya what do you think?

@webknjaz
Copy link
Contributor

webknjaz commented Jan 4, 2023

@flying-sheep looks like this needs a rebase?

@tk0miya seems like this PR is awaiting your comment too...

# Conflicts:
#	sphinx/ext/autodoc/__init__.py
#	tests/test_extensions/test_ext_autodoc.py
#	tests/test_extensions/test_ext_autodoc_autoattribute.py
# Conflicts:
#	sphinx/ext/autodoc/__init__.py
@AA-Turner AA-Turner changed the title Close #5603: Autodoc: add :canonical: for everything Autodoc: add :canonical: for everything Oct 5, 2024
@AA-Turner AA-Turner added type:enhancement enhance or introduce a new feature extensions:autodoc labels Oct 5, 2024
@AA-Turner AA-Turner changed the title Autodoc: add :canonical: for everything Autodoc: add :canonical: for all object types Oct 5, 2024
@flying-sheep
Copy link
Contributor Author

Hi @AA-Turner, I’d be happy if you bring this over the finish line (and that’d be probably faster), but if you want, I could also try fixing the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extensions:autodoc type:enhancement enhance or introduce a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Help people using Intersphinx against objects imported from a package __init__.py
4 participants