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

docs(python): improve structure of sphinx-generated API docs #5376

Merged
merged 2 commits into from
Oct 30, 2022
Merged

docs(python): improve structure of sphinx-generated API docs #5376

merged 2 commits into from
Oct 30, 2022

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Oct 29, 2022

"My fellow Americans Polars enthusiasts, our long national nightmare is over..." ;)
--Gerald Ford

After far, far too many hours today staring at all things Sphinx, I've finally cracked the issue with getting a clean path generated/displayed for the namespace accessors used by the public API (such as arr, dt, str, etc). This reduces the number of excessively long entries in the sidebar navigation down close to zero (dataframe GroupBy and Pivot ops could still do with some cleaning, but I need a break from Sphinx so will tackle that later!)

Also, we have meta information / structure available in the rst files that wasn't being reflected in the navigation, so I broke that out to help make it less overwhelming. Now we have better-contextualised subsections for all Expressions and Series entries. (DataFrame and LazyFrame can follow in another pass).

Minor black magic:

In order for Sphinx (and specifically the sphinx-autosummary-accessors extension) to be able to inspect the methods within the various *NameSpace objects, I needed to make them accessible on the class as well as the instance; this was achieved with the new @accessor decorator (added to polars.utils) which is harmless, but worth mentioning.

Screenshots:

For example...

  • Series:

    Adds structure, and renders namespaced methods as you would actually access them -

    polars_api_series_before polars_api_series_after

  • Expressions:

    As with Series, more structure and clean namespaces -

    polars_api_expressions

Next:

Would be good to try and cleanup the deep class paths given for many parameters in function/method signatures (such as polars.internals.expr.expr.Expr instead of justExpr... 💭), as well as continue to add structure to the other major pieces of the API (Data/LazyFrames).

Related issues:

Contributes to #4156.
Improves on #4604.
Closes #5341.

@github-actions github-actions bot added docs python Related to Python Polars labels Oct 29, 2022
@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Oct 29, 2022

Hmm. Needs a little massaging; will take care of it.

Update: done... will resubmit in a sec.

@ritchie46 ritchie46 merged commit 7def610 into pola-rs:master Oct 30, 2022
@ritchie46
Copy link
Member

Really nice work! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants