Skip to content

Commit 0cb30f4

Browse files
authored
Add sphinx docs (#32)
1 parent 41e2c3c commit 0cb30f4

File tree

6 files changed

+269
-0
lines changed

6 files changed

+269
-0
lines changed

.readthedocs.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
3+
build:
4+
os: "ubuntu-lts-latest"
5+
tools:
6+
python: "3.12"
7+
8+
sphinx:
9+
# Path to your Sphinx configuration file.
10+
configuration: docs/conf.py
11+
12+
python:
13+
install:
14+
- method: pip
15+
path: .
16+
extra_requirements:
17+
- docs
18+
19+
formats: []

docs/_static/style.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.xr-wrap {
2+
font-size: 0.85em;
3+
margin-left: 1.25em;
4+
padding-left: 1.25em;
5+
border-left: thin var(--color-foreground-muted) solid;
6+
}
7+
.xr-array-wrap,
8+
.xr-var-data,
9+
.xr-var-preview {
10+
font-size: 0.9em;
11+
}
12+
.gp {
13+
color: darkorange;
14+
}

docs/api.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. currentmodule:: rasterix
2+
3+
API Reference
4+
-------------
5+
6+
Functions
7+
~~~~~~~~~
8+
9+
.. autosummary::
10+
:toctree: generated/
11+
12+
assign_index

docs/conf.py

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
#
2+
# complexity documentation build configuration file, created by
3+
# sphinx-quickstart on Tue Jul 9 22:26:36 2013.
4+
#
5+
# This file is execfile()d with the current directory set to its containing dir.
6+
#
7+
# Note that not all possible configuration values are present in this
8+
# autogenerated file.
9+
#
10+
# All configuration values have a default; values that are commented out
11+
# serve to show the default.
12+
13+
import datetime
14+
import os
15+
import sys
16+
17+
import rasterix
18+
19+
# If extensions (or modules to document with autodoc) are in another directory,
20+
# add these directories to sys.path here. If the directory is relative to the
21+
# documentation root, use os.path.abspath to make it absolute, like shown here.
22+
# sys.path.insert(0, os.path.abspath('.'))
23+
24+
cwd = os.getcwd()
25+
parent = os.path.dirname(cwd)
26+
sys.path.insert(0, parent)
27+
28+
29+
# -- General configuration -----------------------------------------------------
30+
extensions = [
31+
"sphinx.ext.autodoc",
32+
"sphinx.ext.viewcode",
33+
"sphinx.ext.autosummary",
34+
"sphinx.ext.intersphinx",
35+
"sphinx.ext.extlinks",
36+
"numpydoc",
37+
"sphinx.ext.napoleon",
38+
"myst_nb",
39+
"sphinx_codeautolink",
40+
"sphinx_remove_toctrees",
41+
]
42+
43+
codeautolink_concat_default = True
44+
45+
extlinks = {
46+
"issue": ("https://github.com/dcherian/rasterix/issues/%s", "GH#%s"),
47+
"pr": ("https://github.com/dcherian/rasterix/pull/%s", "PR#%s"),
48+
}
49+
50+
templates_path = ["_templates"]
51+
source_suffix = [".rst"]
52+
master_doc = "index"
53+
language = "en"
54+
55+
remove_from_toctrees = ["generated/*"]
56+
57+
# General information about the project.
58+
project = "rasterix"
59+
current_year = datetime.datetime.now().year
60+
copyright = f"2021-{current_year}, rasterix contributors"
61+
author = "Rasterix Contributors"
62+
63+
# Myst_nb options
64+
nb_execution_excludepatterns = []
65+
nb_execution_raise_on_error = True
66+
nb_execution_mode = "cache"
67+
68+
# The version info for the project you're documenting, acts as replacement for
69+
# |version| and |release|, also used in various other places throughout the
70+
# built documents.
71+
# The short X.Y version.
72+
version = rasterix.__version__.split("+")[0]
73+
# The full version, including alpha/beta/rc tags.
74+
release = rasterix.__version__
75+
76+
# List of patterns, relative to source directory, that match files and
77+
# directories to ignore when looking for source files.
78+
exclude_patterns = ["_build"]
79+
80+
# The name of the Pygments (syntax highlighting) style to use.
81+
pygments_style = "igor"
82+
83+
84+
# -- Options for HTML output ---------------------------------------------------
85+
86+
html_theme = "furo"
87+
88+
# Theme options are theme-specific and customize the look and feel of a theme
89+
# further. For a list of options available for each theme, see the
90+
# documentation.
91+
css_vars = {
92+
"admonition-font-size": "0.9rem",
93+
"font-size--small": "92%",
94+
"font-size--small--2": "87.5%",
95+
}
96+
html_theme_options = dict(
97+
sidebar_hide_name=True,
98+
light_css_variables=css_vars,
99+
dark_css_variables=css_vars,
100+
)
101+
102+
html_context = {
103+
"github_user": "dcherian",
104+
"github_repo": "rasterix",
105+
"github_version": "main",
106+
"doc_path": "doc",
107+
}
108+
html_title = "rasterix"
109+
html_static_path = ["_static"]
110+
html_css_files = ["style.css"]
111+
htmlhelp_basename = "rasterixdoc"
112+
113+
intersphinx_mapping = {
114+
"python": ("https://docs.python.org/3/", None),
115+
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
116+
"numpy": ("https://numpy.org/doc/stable", None),
117+
"xarray": ("https://docs.xarray.dev/en/stable/", None),
118+
"xproj": ("https://xproj.readthedocs.io/en/stable/", None),
119+
}
120+
121+
autosummary_generate = True
122+
autodoc_typehints = "none"
123+
124+
# Napoleon configurations
125+
napoleon_google_docstring = False
126+
napoleon_numpy_docstring = True
127+
napoleon_use_param = False
128+
napoleon_use_rtype = False
129+
napoleon_preprocess_types = True
130+
napoleon_type_aliases = {
131+
# general terms
132+
"sequence": ":term:`sequence`",
133+
"iterable": ":term:`iterable`",
134+
"callable": ":py:func:`callable`",
135+
"dict_like": ":term:`dict-like <mapping>`",
136+
"dict-like": ":term:`dict-like <mapping>`",
137+
"path-like": ":term:`path-like <path-like object>`",
138+
"mapping": ":term:`mapping`",
139+
"file-like": ":term:`file-like <file-like object>`",
140+
# special terms
141+
# "same type as caller": "*same type as caller*", # does not work, yet
142+
# "same type as values": "*same type as values*", # does not work, yet
143+
# stdlib type aliases
144+
"MutableMapping": "~collections.abc.MutableMapping",
145+
"sys.stdout": ":obj:`sys.stdout`",
146+
"timedelta": "~datetime.timedelta",
147+
"string": ":class:`string <str>`",
148+
# numpy terms
149+
"array_like": ":term:`array_like`",
150+
"array-like": ":term:`array-like <array_like>`",
151+
"scalar": ":term:`scalar`",
152+
"array": ":term:`array`",
153+
"hashable": ":term:`hashable <name>`",
154+
# matplotlib terms
155+
"color-like": ":py:func:`color-like <matplotlib.colors.is_color_like>`",
156+
"matplotlib colormap name": ":doc:`matplotlib colormap name <matplotlib:gallery/color/colormap_reference>`",
157+
"matplotlib axes object": ":py:class:`matplotlib axes object <matplotlib.axes.Axes>`",
158+
"colormap": ":py:class:`colormap <matplotlib.colors.Colormap>`",
159+
# objects without namespace: xarray
160+
"DataArray": "~xarray.DataArray",
161+
"Dataset": "~xarray.Dataset",
162+
"Variable": "~xarray.Variable",
163+
"DatasetGroupBy": "~xarray.core.groupby.DatasetGroupBy",
164+
"DataArrayGroupBy": "~xarray.core.groupby.DataArrayGroupBy",
165+
# objects without namespace: numpy
166+
"ndarray": "~numpy.ndarray",
167+
"DaskArray": "~dask.array.Array",
168+
"MaskedArray": "~numpy.ma.MaskedArray",
169+
"dtype": "~numpy.dtype",
170+
"ComplexWarning": "~numpy.ComplexWarning",
171+
# objects without namespace: pandas
172+
"Index": "~pandas.Index",
173+
"MultiIndex": "~pandas.MultiIndex",
174+
"CategoricalIndex": "~pandas.CategoricalIndex",
175+
"TimedeltaIndex": "~pandas.TimedeltaIndex",
176+
"DatetimeIndex": "~pandas.DatetimeIndex",
177+
"Series": "~pandas.Series",
178+
"DataFrame": "~pandas.DataFrame",
179+
"Categorical": "~pandas.Categorical",
180+
"Path": "~~pathlib.Path",
181+
# objects with abbreviated namespace (from pandas)
182+
"pd.Index": "~pandas.Index",
183+
"pd.NaT": "~pandas.NaT",
184+
}

docs/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Rasterix
2+
3+
[![GitHub Workflow CI Status](https://img.shields.io/github/actions/workflow/status/dcherian/rasterix/ci.yaml?branch=main&logo=github&style=flat)](https://github.com/dcherian/rasterix/actions)
4+
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/dcherian/rasterix/main.svg)](https://results.pre-commit.ci/latest/github/dcherian/rasterix/main)
5+
[![image](https://img.shields.io/codecov/c/github/dcherian/rasterix.svg?style=flat)](https://codecov.io/gh/dcherian/rasterix)
6+
[![Documentation Status](https://readthedocs.org/projects/rasterix/badge/?version=latest)](https://rasterix.readthedocs.io/en/latest/?badge=latest)
7+
8+
[![PyPI](https://img.shields.io/pypi/v/rasterix.svg?style=flat)](https://pypi.org/project/rasterix/)
9+
[![Conda-forge](https://img.shields.io/conda/vn/conda-forge/rasterix.svg?style=flat)](https://anaconda.org/conda-forge/rasterix)
10+
11+
## Overview
12+
13+
## Installing
14+
15+
```shell
16+
$ pip install rasterix
17+
```
18+
19+
## Contents
20+
21+
```{eval-rst}
22+
.. toctree::
23+
:maxdepth: 1
24+
25+
api.rst
26+
```

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies = [
3333
"xarray>=2025",
3434
]
3535
dynamic=["version"]
36+
3637
[project.optional-dependencies]
3738
dask = ["dask-geopandas"]
3839
rasterize = [
@@ -53,6 +54,19 @@ test = [
5354
"netCDF4",
5455
"hypothesis",
5556
]
57+
docs = [
58+
# Doc building
59+
'sphinx',
60+
'sphinx-autobuild>=2021.3.14',
61+
'sphinx-copybutton',
62+
'sphinx-remove-toctrees',
63+
'sphinx-codeautolink',
64+
'myst-parser',
65+
'myst-nb',
66+
'furo',
67+
'numpydoc',
68+
]
69+
5670

5771
[tool.hatch]
5872
version.source = "vcs"

0 commit comments

Comments
 (0)