Skip to content

Commit

Permalink
docs: Improve Python API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Mar 6, 2024
1 parent ac0131a commit e6d02d7
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 36 deletions.
1 change: 1 addition & 0 deletions py-polars/docs/requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sphinx-autosummary-accessors==2023.4.0
sphinx-copybutton==0.5.2
sphinx-design==0.5.0
sphinx-favicon==1.0.1
sphinx_reredirects==0.1.3
sphinx-toolbox==3.5.0

livereload==2.6.3
16 changes: 13 additions & 3 deletions py-polars/docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,36 @@ html[data-theme="dark"] {
--pst-color-border: #444444;
}

/* add subtle gradients to sidebar and card elements */
div.bd-sidebar-primary {
background-image: linear-gradient(90deg, var(--pst-gradient-sidebar-left) 0%, var(--pst-gradient-sidebar-right) 100%);
}
div.sd-card {
background-image: linear-gradient(0deg, var(--pst-gradient-sidebar-left) 0%, var(--pst-gradient-sidebar-right) 100%);
}

/* match docs footer colour to the header */
footer.bd-footer {
background-color: var(--pst-color-on-background);
}

/*
We're not currently doing anything meaningful with the right
ToC, so hide until there's actually something to put there...
we're not currently doing anything meaningful with the
right toc, so hide until there's something to put there
*/
div.bd-sidebar-secondary {
display: none;
}

label.sidebar-toggle.secondary-toggle {
display: none !important;
}

/* fix visited link colour */
a:visited {
color: var(--pst-color-link);
}

/* fix ugly navbar scrollbar display */
.sidebar-primary-items__end {
margin: 0 !important;
}
8 changes: 8 additions & 0 deletions py-polars/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
# Add py-polars directory
sys.path.insert(0, str(Path("../..").resolve()))


# -- Project information -----------------------------------------------------

project = "Polars"
author = "Ritchie Vink"
copyright = f"2020, {author}"


# -- General configuration ---------------------------------------------------

extensions = [
Expand All @@ -44,6 +46,7 @@
"sphinx_copybutton",
"sphinx_design",
"sphinx_favicon",
"sphinx_reredirects",
"sphinx_toolbox.more_autodoc.overloads",
]

Expand All @@ -67,6 +70,7 @@
# https://sphinx-toolbox.readthedocs.io/en/latest/
overloads_location = ["bottom"]


# -- Extension settings -----------------------------------------------------

# sphinx.ext.intersphinx - link to other projects' documentation
Expand All @@ -89,6 +93,10 @@
copybutton_prompt_text = r">>> |\.\.\. "
copybutton_prompt_is_regexp = True

# redirect empty root to the actual landing page
redirects = {"index": "reference/index.html"}


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.
Expand Down
4 changes: 2 additions & 2 deletions py-polars/docs/source/reference/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Providing new functionality
---------------------------

These functions allow you to register custom functionality in a dedicated
namespace on the underlying polars classes without requiring subclassing
namespace on the underlying Polars classes without requiring subclassing
or mixins. Expr, DataFrame, LazyFrame, and Series are all supported targets.

This feature is primarily intended for use by library authors providing
Expand All @@ -29,7 +29,7 @@ Available registrations

.. note::

You cannot override existing polars namespaces (such as ``.str`` or ``.dt``), and attempting to do so
You cannot override existing Polars namespaces (such as ``.str`` or ``.dt``), and attempting to do so
will raise an `AttributeError <https://docs.python.org/3/library/exceptions.html#AttributeError>`_.
However, you *can* override other custom namespaces (which will only generate a
`UserWarning <https://docs.python.org/3/library/exceptions.html#UserWarning>`_).
Expand Down
8 changes: 4 additions & 4 deletions py-polars/docs/source/reference/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Config options
Config.set_trim_decimal_zeros
Config.set_verbose

Config load, save, and current state
------------------------------------
Config load, save, state
------------------------
.. autosummary::
:toctree: api/

Expand Down Expand Up @@ -81,8 +81,8 @@ explicitly calling one or more of the available "set\_" methods on it...
with pl.Config(verbose=True):
do_various_things()
Use as a function decorator
---------------------------
Use as a decorator
------------------

In the same vein, you can also use ``Config`` as a function decorator to
temporarily set options for the duration of the function call:
Expand Down
2 changes: 1 addition & 1 deletion py-polars/docs/source/reference/datatypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Other
:toctree: api/
:nosignatures:

Boolean
Binary
Boolean
Categorical
Enum
Null
Expand Down
2 changes: 1 addition & 1 deletion py-polars/docs/source/reference/expressions/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Functions
=========

These functions are available from the polars module root and can be used as expressions, and sometimes also in eager contexts.
These functions are available from the Polars module root and can be used as expressions, and sometimes also in eager contexts.

----

Expand Down
2 changes: 1 addition & 1 deletion py-polars/docs/source/reference/expressions/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Expressions
===========

This page gives an overview of all public polars expressions.
This page gives an overview of all public Polars expressions.

.. toctree::
:maxdepth: 2
Expand Down
126 changes: 105 additions & 21 deletions py-polars/docs/source/reference/index.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,108 @@
=============
API reference
=============
====================
Python API reference
====================

This page gives an overview of all public polars objects, functions and
This page gives a high-level overview of all public Polars objects, functions and
methods. All classes and functions exposed in ``polars.*`` namespace are public.

.. toctree::
:maxdepth: 2

io
series/index
dataframe/index
lazyframe/index
expressions/index
selectors
api
functions
datatypes
config
exceptions
testing
sql
metadata

.. grid::

.. grid-item-card::

.. toctree::
:maxdepth: 2

dataframe/index

.. grid-item-card::

.. toctree::
:maxdepth: 2

lazyframe/index

.. grid-item-card::

.. toctree::
:maxdepth: 2

series/index


.. grid::

.. grid-item-card::

.. toctree::
:maxdepth: 2

expressions/index
selectors

.. grid-item-card::

.. toctree::
:maxdepth: 2

functions

.. grid-item-card::

.. toctree::
:maxdepth: 2

datatypes


.. grid::

.. grid-item-card::

.. toctree::
:maxdepth: 2

io

.. grid-item-card::

.. toctree::
:maxdepth: 2

config

.. grid-item-card::

.. toctree::
:maxdepth: 2

api


.. grid::

.. grid-item-card::

.. toctree::
:maxdepth: 2

sql

.. grid-item-card::

.. toctree::
:maxdepth: 1

exceptions

.. toctree::
:maxdepth: 2

testing

.. grid-item-card::

.. toctree::
:maxdepth: 1

metadata
6 changes: 3 additions & 3 deletions py-polars/docs/source/reference/sql.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===
SQL
===
=============
SQL Interface
=============
.. currentmodule:: polars

.. py:class:: SQLContext
Expand Down

0 comments on commit e6d02d7

Please sign in to comment.