-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Improving documentation of plot handlers #839
Conversation
In this PR the automatic docstrings for plot handlers depend on |
Hmm.. I have looked a bit into this. And it seems this is the wrong way to go about this.
are all explicitly creating their This would also enable accessor documentation as we would like it: Plotting
--------
.. autosummary::
:toctree: generated/
:template: autosummary/accessor_method.rst
Dataset.plot.scatter
Dataset.plot.quiver
Dataset.plot.streamplot above is an excerpt from Only thing that is needed is the package I think this could solve all issues, albeit it would be a somewhat hurdle to get right for the first time and it requires us to manually add functions to the documentation. However, perhaps that could solve other issues, such as grouping, proper documentation style etc. What would be your thoughts on this transition? |
It might require a bit of adjustment and play with it. But it seems to be easier to manage in the long run, and I don't like the hacky way of building a project with errors, then patching it and hoping nothing broke... It is too fragile IMHO. |
I think it could make sense to create our custom We could have some scripts to automatically generate the rst files.
Users are never going to build the documentation, it is always built in a controlled environment, so it is not so clear to me that the approach is that bad. But yeah if you have an idea for automatizing the custom rst files it is better of course. I can do it if you have a clear picture of what you want. Otherwise if this issue is going to stall because of lack of time I think having the documentation built with the hack is much better than having undocumented parts of the code. |
The replacement of the placeholder could be done also within sphinx I think, but I haven't found the exact way to do it yet. That would be less hacky in the sense that it doesn't need external scripts so it would work every time |
It is only manual for the overview, not for the actual documentation. I.e. see here.
Just like we had an issue with the notebooks not fully working (which required us to actually see it) this could pose problems. I agree users don't interwene, but these things always bite back at some point... |
That file is generated automatically, no? |
I am pretty sure its hand-made... But rather simple, right, the |
Actually I find In any case, I think I have been playing with |
I agree xarray is horrible in many ways... :( But, I don't think we should put it in like this, we will never fix it... And I am afraid we end up with bugs later on that are hard to deal with... |
39ab49f
to
e35cb57
Compare
Ok, so I discovered that autoclass actually has no problem with attributes that contain a dot and will document them. The only problem is with autosummary, which interprets a dot as a "get attribute" and can only show either the full name or the last word after a dot. E.g. for the pdos plot handler either So I removed the placeholder thing and updated the class template for autosummary so that it shows this: This is a step, but I think it will be not entirely clear for users. What I have thought also is to separate the dispatchers in a different autosummary. Maybe then the long path is not so confusing... |
Yeah, I think we need to separate it in some way. |
This is related to #838
Most changes are just general improvements of the automatic documentation of plot handlers (regardless of who renders it).
The changes related to sphinx are only in
docs/conf.py
anddocs/build_docs.sh
, where I followed the approach explained in #838 (comment). I also madeconf.py
document theGeometry.to
andBrillouinZone.apply
dispatchers, as the difficulty to document dispatchers also affects them.I have tried to use sphinx events, but I haven't succeeded. If you come up with a better way to document nested methods inside dispatchers then great, but I think that the current method, although hacky, it produces nice documentation results:
Plotting methods in the summary:
Plotting methods documentation:
Geometry.to dispatchs:
(this PR is not ready yet because I want to further improve the docstrings of the plotting methods, it's just so that you can see the approach that I'm taking and provide better ideas)