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
Autosummary with custom documenters #7908
Comments
Sorry. I still don't understand your problem and solution. I think it is hard to look up documented from the chosen template. Why your custom documentor is chosen by autosummary? I need to know your problem first. |
the problem is this: without the hack (or the feature I'm requesting) What I'd like If that's something you'd rather not provide directly, I'd like to have a way to implement that without rewriting |
AFAIK, Sphinx chooses a documenter for the object from the registry. So your documenter will be chosen automatically if it matches to the object via |
it is not chosen because I set the priority lower than For more background: For methods and attributes on the accessor, it doesn't matter if the standard documenters are used: the signature and summary stay the same, regardless of the path ( .. autosummary::
:template: accessor_callable.rst
Example.test With the templates, I can get I'm not sure if I can write a |
Thank you for your explanation. Is your problem resolved if autosummary gives correct |
if there's a way to change the displayed name in the summary table, then yes, probably, although that would mean I'd have to use The other way this could be solved would be to (additionally?) allow overriding |
AFAIK, |
unfortunately, that's not the case: the signature is just the part between the parentheses. This line: sphinx/sphinx/ext/autosummary/__init__.py Line 364 in 44ee514
where sphinx/sphinx/ext/autosummary/__init__.py Lines 297 to 300 in 44ee514
real_name from here: sphinx/sphinx/ext/autosummary/__init__.py Lines 303 to 304 in 44ee514
|
Oops, it's my bad. You're right. Indeed there are no way to change the name of get_items. |
then either adding template support to |
I think a template and documenter is not related at all. So I'll never choose the way. On the other hand, it's not so hard to choose to allow overriding |
just to be clear, I only need to override |
I think I don't understand the real problem yet. Why do you rewrite these names on autosummary directive? I feel it would be better to give correct name to the directive on the reST source. Why don't you use |
that's what I do, and that already works. However, these namespace objects may also be callable, so I need to make sure .. autosummary::
:template: autosummary/accessor_callable.rst
DataFrame.plot should document {{ fullname }}
{{ underline }}
.. currentmodule:: {{ module.split('.')[0] }}
.. autoaccessorcallable:: {{ (module.split('.')[1:] + [objname]) | join('.') }}.__call__ but |
I think this is a real problem. Does autosummary really not use the given template? If so, it's a bug. Could you share some examples? I'll try to investigate your problem. |
take a look at the docs of my extension: The classes are defined in example.py, the autosummary page is examples.rst. |
gentle ping, @tk0miya. As a summary, my problem is that So I think allowing to register functions that choose the documenter (with a fall back to the default algorithm if they return |
Could you describe this to me in detail? Is this an example of a bug that autosummary does not use the given template, or a bug that autosummary does not use your documenter even if it matches via
What is it different from |
I'm not sure if this is a bug at all, it's just that
They don't, the difference between normal methods and the ones I'm trying to document is not big enough to be able to use that function. I'm only able to reliably detect them using the template option.
The data it has access to, I guess? With |
gentle ping, @tk0miya. If you agree with the general approach (allowing to register a custom |
Yes, please. I can't answer you well because I'm confusing. A draft PR might help me. |
Is your feature request related to a problem? Please describe.
This is related to #6264, but a bit different (I think?): when using the
template
option ofautosummary
directives,autosummary
will ignore the template which means it will use the wrong documenter to produce its summary table.For an example, see sphinx-autosummary-accessors (examples.rst, build)
Describe the solution you'd like
I'd like
autosummary
to use the documenter specified in the template instead of choosing from the standard documenters.Describe alternatives you've considered
I considered using the priority to control the directive used but that would mean those directives are always used and not only together with the template.
In keewis/sphinx-autosummary-accessors#6 (keewis/sphinx-autosummary-accessors@aa44bda) I hacked around that by overriding
Autosummary.get_items
to extract that information from the template and use the correct documenter. That, however, is fragile since now I need to make sure this stays in sync with the upstream method.The text was updated successfully, but these errors were encountered: