From 783cd9c4a1b920994de5368aea5c3c1190bd9073 Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 2 Jul 2020 13:10:51 +0200 Subject: [PATCH 1/6] properly configure isort --- setup.cfg | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 2e2b5767..1388ac34 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,4 +23,13 @@ ignore = # line break before binary operator W503 exclude= - .eggs \ No newline at end of file + .eggs + +[isort] +default_section = THIRDPARTY +known_first_party = pintxarray +multi_line_output = 3 +include_trailing_comma = True +force_grid_wrap = 0 +use_parentheses = True +line_length = 88 \ No newline at end of file From 95a69b717ce204a0dc0a1359127343ddeb32c946 Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 2 Jul 2020 13:11:07 +0200 Subject: [PATCH 2/6] initial documentation setup --- .gitignore | 1 + docs/api.rst | 38 ++++++++++++++++++++ docs/conf.py | 80 +++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 13 +++++++ docs/requirements.txt | 6 ++++ 5 files changed, 138 insertions(+) create mode 100644 docs/api.rst create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/requirements.txt diff --git a/.gitignore b/.gitignore index b6e47617..6a0852a0 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,7 @@ instance/ # Sphinx documentation docs/_build/ +docs/generated/ # PyBuilder target/ diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 00000000..4bcb96aa --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,38 @@ +.. currentmodule:: xarray + +API reference +============= +This page contains a auto-generated summary of ``pint-xarray``'s API. + + +Dataset +------- +.. autosummary:: + :toctree: generated/ + :template: autosummary/accessor_method.rst + + Dataset.pint.quantify + Dataset.pint.dequantify + Dataset.pint.to + Dataset.pint.to_base_units + Dataset.pint.to_system + +DataArray +--------- +.. autosummary:: + :toctree: generated/ + :template: autosummary/accessor_property.rst + + DataArray.pint.magnitude + DataArray.pint.units + DataArray.pint.dimensionality + DataArray.pint.registry + +.. autosummary:: + :toctree: generated/ + :template: autosummary/accessor_method.rst + + DataArray.pint.quantify + DataArray.pint.dequantify + DataArray.pint.to + DataArray.pint.to_base_units diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..d125c507 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,80 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# -- Imports ----------------------------------------------------------------- + +import datetime as dt + +import sphinx_autosummary_accessors + +# need to import so accessors get registered +import pintxarray # noqa: F401 + +# -- Project information ----------------------------------------------------- + +year = dt.datetime.now().year +project = "pint-xarray" +author = f"{project} developers" +copyright = f"{year}, {author}" + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.intersphinx", + "sphinx.ext.autosummary", + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", + "sphinx_autosummary_accessors", +] + +autosummary_generate = True +autodoc_typehints = "none" + +napoleon_use_param = True +napoleon_use_rtype = True + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates", sphinx_autosummary_accessors.templates_path] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + + +# -- Extension configuration ------------------------------------------------- + +# -- Options for intersphinx extension --------------------------------------- + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {"https://docs.python.org/3/": None} diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 00000000..b526353b --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,13 @@ +.. accessors documentation master file, created by + sphinx-quickstart on Thu Jul 2 01:49:50 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to accessors's documentation! +===================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + api diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..be287170 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,6 @@ +pint>=0.13 +xarray>=0.15.1 +sphinx>=3.0 +sphinx_rtd_theme +nbsphinx +git+https://github.com/keewis/sphinx-autosummary-accessors From 032f7e049fa07d81af3cef95eef7e72c8eada064 Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 2 Jul 2020 13:12:33 +0200 Subject: [PATCH 3/6] remove the not-yet-implemented Dataset.pint.to --- docs/api.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index 4bcb96aa..4a904190 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -13,7 +13,6 @@ Dataset Dataset.pint.quantify Dataset.pint.dequantify - Dataset.pint.to Dataset.pint.to_base_units Dataset.pint.to_system From b1f287a9227959867c8f88e86faabe64a508e2fa Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 2 Jul 2020 13:14:23 +0200 Subject: [PATCH 4/6] add RTD configuration --- readthedocs.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 readthedocs.yml diff --git a/readthedocs.yml b/readthedocs.yml new file mode 100644 index 00000000..b3a0483e --- /dev/null +++ b/readthedocs.yml @@ -0,0 +1,10 @@ +version: 2 + +build: + image: latest + +python: + install: + - requirements: docs/requirements.txt + - method: pip + path: . From 9ff8cf00f22347178b128f3a426b25c0aadba5a6 Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 2 Jul 2020 13:20:42 +0200 Subject: [PATCH 5/6] comment out the html_static_path setting --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index d125c507..42792882 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -69,7 +69,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] +# html_static_path = ["_static"] # -- Extension configuration ------------------------------------------------- From 1abf6d9108be0544f76434da156949ac218d013c Mon Sep 17 00:00:00 2001 From: Keewis Date: Thu, 2 Jul 2020 13:21:08 +0200 Subject: [PATCH 6/6] move the extension settings to the proper section --- docs/conf.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 42792882..7b9e884f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,12 +44,6 @@ "sphinx_autosummary_accessors", ] -autosummary_generate = True -autodoc_typehints = "none" - -napoleon_use_param = True -napoleon_use_rtype = True - # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates", sphinx_autosummary_accessors.templates_path] @@ -74,6 +68,12 @@ # -- Extension configuration ------------------------------------------------- +autosummary_generate = True +autodoc_typehints = "none" + +napoleon_use_param = True +napoleon_use_rtype = True + # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library.