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

Clean up wrappers and append wrapper docs to matplotlib docs #43

Closed
lukelbd opened this issue Sep 15, 2019 · 1 comment
Closed

Clean up wrappers and append wrapper docs to matplotlib docs #43

lukelbd opened this issue Sep 15, 2019 · 1 comment

Comments

@lukelbd
Copy link
Collaborator

lukelbd commented Sep 15, 2019

This is a follow-up to #37 and #42.

I think my current approach of documenting wrappers separately from the functions to which they apply is very cumbersome and confusing for new users (many of whom don't really know what a "wrapper" is). The old approach stems only from a lack of imagination.

A better approach would be to:

  1. Concatenate call signatures, parameter tables, and header descriptions from the wrappers and the original matplotlib documentation. When users call help(ax.plot), they get usage info for the wrappers and the matplotlib method. Would look something like this:
Help on function plot in module proplot.axes

plot(self, ...) # concatenated call signature from wrappers and matplotlib
   -----------------------
   ProPlot documentation
   -----------------------
   Summary. Wrapper 1 summary. Wrapper 2 summary. ... Wrapper N summary.

   Parameters # concatenated parameter table
   ----------
   ...params from wrapper1
   ...params from wrapper2
   ...
   ...params from wrapperN

   --------------------------
   Matplotlib documentation
   --------------------------
   Original docstring placed here in its entirety.
  1. Add an option to my sphinx-automodapi fork that removes the matplotlib parameters when concatenating parameter tables. Matplotlib has some funky local sphinx extensions that will get messed up -- and anyway we don't want to copy their documenation onto our website. Would look something like this:
plot(self, ...) # concatenated call signature
   Summary. Wrapper 1 summary. Wrapper 2 summary. ... Wrapper N summary.

   Parameters
   -----------
   ...params from wrapper1
   ...params from wrapper2
   ...
   ...params from wrapperN

   Other parameters
   ----------------
   *args, **kwargs
       Passed to <matplotlib native function>.

This will have the following implications:

  • All wrapper-related features will be documented as Axes class methods. There will no longer be a Functions table in the Axes classes and related wrappers section of the online documentation.
  • Method-specific wrappers like plot_wrapper will be defined directly on the Axes with def plot.
  • "Bulk" wrappers like standardize_1d will be hidden and *no longer documented explicitly *-- they will only be documented on the individual methods to which they apply.
  • "Bulk" wrappers can be easily split up into separate functions, helping eliminate method-specific behavior inside the wrappers, e.g. the if name == 'contour' statements inside of cmap_features.

This will be tricky but I think it is really necessary to reduce new user confusion. It also has the added benefit of making it easier to merge features with matplotlib if matplotlib developers feel so inclined.

It should involve borrowing from matplotlib's docstring.py file and using the inspect.getdoc and inspect.signature functions (for the latter see this post).

@lukelbd
Copy link
Collaborator Author

lukelbd commented Aug 19, 2021

This is now implemented in v0.8. I use a PlotAxes class, simple %(snippet)s style docstring interpolation, and a simply concatenation of matplotlib/proplot docstrings (option 1) when rc['docstring.hardcopy'] is disabled. Option 2 would have been way too complicated and was not necessary.

@lukelbd lukelbd closed this as completed Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant