Skip to content

Commit f3ea956

Browse files
Merge pull request #14 from OceanParcels/documentation-start
Adding documentation
2 parents 0b4f446 + 6692fcc commit f3ea956

13 files changed

Lines changed: 416 additions & 162 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ input_data/
44
**.pyc**
55
**.nc
66
**.zarr
7+
docs/_build/*
8+
docs/_downloads

.readthedocs.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
build:
3+
os: ubuntu-22.04
4+
tools:
5+
python: mambaforge-22.9
6+
jobs:
7+
pre_build:
8+
- sphinx-build -b linkcheck docs/ _build/linkcheck
9+
10+
sphinx:
11+
configuration: docs/conf.py
12+
13+
conda:
14+
environment: docs/environment_docs.yml

README.md

Lines changed: 0 additions & 160 deletions
Large diffs are not rendered by default.

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
115 KB
Loading

docs/conf.py

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
import datetime
10+
import inspect
11+
import os
12+
import sys
13+
import warnings
14+
15+
project = 'PlasticParcels'
16+
copyright = f'{datetime.datetime.now().year}, The OceanParcels Team'
17+
author = 'The OceanParcels Team'
18+
19+
# -- General configuration ---------------------------------------------------
20+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
21+
22+
extensions = []
23+
24+
templates_path = ['_templates']
25+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
26+
27+
28+
29+
# -- Options for HTML output -------------------------------------------------
30+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
31+
32+
html_theme = 'pydata_sphinx_theme'
33+
html_static_path = ['_static']
34+
35+
html_theme_options = {
36+
"logo": {
37+
"image_light": "plasticparcelslogo.png",
38+
"image_dark": "plasticparcelslogo-inverted.png", # TODO create this
39+
},
40+
# "use_edit_page_button": True,
41+
"github_url": "https://github.com/OceanParcels/plasticparcels",
42+
"icon_links": [
43+
{
44+
"name": "Conda Forge",
45+
"url": "https://anaconda.org/conda-forge/plasticparcels", # required
46+
"icon": "fa-solid fa-box",
47+
"type": "fontawesome",
48+
}
49+
]
50+
}
51+
52+
extensions = [
53+
'sphinx.ext.autodoc',
54+
'sphinx.ext.todo',
55+
"sphinx.ext.linkcode",
56+
"sphinx.ext.mathjax",
57+
"sphinx.ext.napoleon",
58+
"myst_parser",
59+
"nbsphinx",
60+
"numpydoc",
61+
]
62+
63+
myst_enable_extensions = ["dollarmath", "amsmath"]
64+
65+
# based on pandas doc/source/conf.py
66+
def linkcode_resolve(domain, info):
67+
"""Determine the URL corresponding to Python object."""
68+
if domain != "py":
69+
return None
70+
71+
modname = info["module"]
72+
fullname = info["fullname"]
73+
74+
submod = sys.modules.get(modname)
75+
if submod is None:
76+
return None
77+
78+
obj = submod
79+
for part in fullname.split("."):
80+
try:
81+
with warnings.catch_warnings():
82+
# Accessing deprecated objects will generate noisy warnings
83+
warnings.simplefilter("ignore", FutureWarning)
84+
obj = getattr(obj, part)
85+
except AttributeError:
86+
return None
87+
88+
try:
89+
fn = inspect.getsourcefile(inspect.unwrap(obj))
90+
except TypeError:
91+
try: # property
92+
fn = inspect.getsourcefile(inspect.unwrap(obj.fget))
93+
except (AttributeError, TypeError):
94+
fn = None
95+
if not fn:
96+
return None
97+
98+
try:
99+
source, lineno = inspect.getsourcelines(obj)
100+
except TypeError:
101+
try: # property
102+
source, lineno = inspect.getsourcelines(obj.fget)
103+
except (AttributeError, TypeError):
104+
lineno = None
105+
except OSError:
106+
lineno = None
107+
108+
if lineno:
109+
linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
110+
else:
111+
linespec = ""
112+
113+
fn = os.path.relpath(fn, start=os.path.dirname(parcels.__file__))
114+
115+
if "-" in parcels.__version__:
116+
return f"https://github.com/OceanParcels/plasticparcels/blob/master/parcels/{fn}{linespec}"
117+
else:
118+
return (
119+
f"https://github.com/OceanParcels/plasticparcels/blob/"
120+
f"{parcels.__version__}/parcels/{fn}{linespec}"
121+
)

docs/environment_docs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: plasticparcels
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- python>=3.8
6+
- parcels>=3.0.2
7+
- shapely
8+
- geopandas
9+
10+
11+
# Formatting
12+
- black
13+
- isort
14+
15+
# Testing
16+
- pytest
17+
- pytest-html
18+
- coverage
19+
20+
# Linting
21+
- flake8>=2.1.0
22+
- pre_commit
23+
- pydocstyle
24+
25+
# Docs
26+
- ipython
27+
- numpydoc
28+
- nbsphinx
29+
- sphinx<6
30+
- pandoc>1.12.1,<3
31+
- pydata-sphinx-theme
32+
- sphinx-autobuild
33+
- myst-parser

docs/examples.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Examples
2+
========
3+
4+
PlasticParcels has a few example notebooks, see below.
5+
6+
7+
8+
.. nbgallery::
9+
:caption: Running simulations
10+
:name: running-simulations
11+
12+
examples/example_Italy_coast.ipynb

docs/examples/example_Italy_coast.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# PlasticParcels Example\n",
8-
"## The pathways and fate of Italian coastal plastic pollution\n",
7+
"# The pathways and fate of Italian coastal plastic pollution\n",
98
"In this example, we will use `plasticparcels` to run a basic simulation of microplastic pollution along the Italian coastline."
109
]
1110
},

docs/index.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. plasticparcels documentation master file, created by
2+
sphinx-quickstart on Fri May 3 09:55:52 2024.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
PlasticParcels documentation
7+
============================
8+
9+
Welcome to the documentation of PlasticParcels.
10+
11+
``plasticparcels`` is a python package for simulating the transport and dispersion of plastics in the ocean. The tool is based on the ``parcels`` computational Lagrangian ocean analysis framework, providing a modular and customisable collection of methods, notebooks, and tutorials for advecting virtual plastic particles with a wide range of physical properties.
12+
13+
14+
.. toctree::
15+
:maxdepth: 2
16+
:caption: Contents
17+
18+
Home <self>
19+
Examples <examples>
20+
Physics kernels <physicskernels>
21+
Plastic initialisation maps <initialisationmaps>
22+
OceanParcels website <https://oceanparcels.org/>

0 commit comments

Comments
 (0)