Skip to content

Commit 0c5c50d

Browse files
Adding first attempt of documentation
1 parent 724ccce commit 0c5c50d

8 files changed

Lines changed: 209 additions & 2 deletions

File tree

.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

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: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
# based on pandas doc/source/conf.py
64+
def linkcode_resolve(domain, info):
65+
"""Determine the URL corresponding to Python object."""
66+
if domain != "py":
67+
return None
68+
69+
modname = info["module"]
70+
fullname = info["fullname"]
71+
72+
submod = sys.modules.get(modname)
73+
if submod is None:
74+
return None
75+
76+
obj = submod
77+
for part in fullname.split("."):
78+
try:
79+
with warnings.catch_warnings():
80+
# Accessing deprecated objects will generate noisy warnings
81+
warnings.simplefilter("ignore", FutureWarning)
82+
obj = getattr(obj, part)
83+
except AttributeError:
84+
return None
85+
86+
try:
87+
fn = inspect.getsourcefile(inspect.unwrap(obj))
88+
except TypeError:
89+
try: # property
90+
fn = inspect.getsourcefile(inspect.unwrap(obj.fget))
91+
except (AttributeError, TypeError):
92+
fn = None
93+
if not fn:
94+
return None
95+
96+
try:
97+
source, lineno = inspect.getsourcelines(obj)
98+
except TypeError:
99+
try: # property
100+
source, lineno = inspect.getsourcelines(obj.fget)
101+
except (AttributeError, TypeError):
102+
lineno = None
103+
except OSError:
104+
lineno = None
105+
106+
if lineno:
107+
linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
108+
else:
109+
linespec = ""
110+
111+
fn = os.path.relpath(fn, start=os.path.dirname(parcels.__file__))
112+
113+
if "-" in parcels.__version__:
114+
return f"https://github.com/OceanParcels/plasticparcels/blob/master/parcels/{fn}{linespec}"
115+
else:
116+
return (
117+
f"https://github.com/OceanParcels/plasticparcels/blob/"
118+
f"{parcels.__version__}/parcels/{fn}{linespec}"
119+
)

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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
OceanParcels website <https://oceanparcels.org/>

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

0 commit comments

Comments
 (0)