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

Find parent doc string for relative crossrefs #6

Open
analog-cbarber opened this issue Sep 6, 2023 · 6 comments
Open

Find parent doc string for relative crossrefs #6

analog-cbarber opened this issue Sep 6, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@analog-cbarber
Copy link
Member

mkdocstrings does not currently support references to members not explicitly defined in subclass, so
instead of just being able to write something like [foo][.] you might have to write [foo][(m).ParentClass.]
or worse.

It would be nice if we could automatically handle this redirection.

@analog-cbarber analog-cbarber self-assigned this Sep 6, 2023
@analog-cbarber analog-cbarber added the enhancement New feature or request label Sep 6, 2023
@analog-cbarber
Copy link
Member Author

analog-cbarber commented Nov 19, 2023

I think that the mkdocstrings render method already handles the case where the target class does not directly define the method. What is not handled is when the target class overrides the method but does not provide a doc string. In that case, we would like to redirect to the closest ancestor that provides a doc-string.

Probably mkdocstrings should do that, so it may not be worthwhile trying to fix that in this extension.

@pawamoy
Copy link

pawamoy commented Nov 19, 2023

I recently released a Griffe extension to inherit docstrings, as part of the Insiders program.

@analog-cbarber
Copy link
Member Author

The griffe-inherited-docstrings extension is now in mkdocstrings-python 1.8. Maybe this will make this issue moot?

@pawamoy
Copy link

pawamoy commented Jan 18, 2024

The griffe-inherited-docstrings extension is now in mkdocstrings-python 1.8.

Correction: it's now free, and was released at the same time as mkdocstrings-python 1.8 🙂

Maybe this will make this issue moot?

I suppose so. It's not always easy to remember exactly what mkdocstrings-python and autorefs do, but I think they do this:

  • pkg.mod.Class.meth not found
  • ask Python handler aliases for this identifier
  • try each one to see if we have an URL for it
  • link to the first that has an URL

The last fix in mkdocstrings-python regarding this behavior is from august: https://mkdocstrings.github.io/griffe/changelog/#0351-2023-08-26, so I'm surprised it didn't work for you. But I might forget something. As I said, not easy to remember the exact flow 😄

@analog-cbarber
Copy link
Member Author

Ah right. I didn't read that closely enough. So you need to install the https://mkdocstrings.github.io/griffe-inherited-docstrings/?

Is there a reason that was not just bundled directly into griffe or mkdocstrings-python?

@pawamoy
Copy link

pawamoy commented Jan 18, 2024

Yep, you can read the relevant discussion here: mkdocstrings/griffe#96. In short: it would have been hacky in both mkdocstrings-python and Griffe. With current Griffe's architecture, inheriting docstrings is a permanent side-effect. Back and forth inheriting/un-inheriting docstring would not have been super elegant or efficient. So it was best implemented as an extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants