Skip to content

Commit

Permalink
Adding first attempt of documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvansebille committed May 3, 2024
1 parent 724ccce commit 0c5c50d
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ input_data/
**.pyc**
**.nc
**.zarr
docs/_build/*
docs/_downloads
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file added docs/_static/plasticparcelslogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 119 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import datetime
import inspect
import os
import sys
import warnings

project = 'PlasticParcels'
copyright = f'{datetime.datetime.now().year}, The OceanParcels Team'
author = 'The OceanParcels Team'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = []

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'pydata_sphinx_theme'
html_static_path = ['_static']

html_theme_options = {
"logo": {
"image_light": "plasticparcelslogo.png",
"image_dark": "plasticparcelslogo-inverted.png", # TODO create this
},
# "use_edit_page_button": True,
"github_url": "https://github.com/OceanParcels/plasticparcels",
"icon_links": [
{
"name": "Conda Forge",
"url": "https://anaconda.org/conda-forge/plasticparcels", # required
"icon": "fa-solid fa-box",
"type": "fontawesome",
}
]
}

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
"sphinx.ext.linkcode",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"myst_parser",
"nbsphinx",
"numpydoc",
]

# based on pandas doc/source/conf.py
def linkcode_resolve(domain, info):
"""Determine the URL corresponding to Python object."""
if domain != "py":
return None

modname = info["module"]
fullname = info["fullname"]

submod = sys.modules.get(modname)
if submod is None:
return None

obj = submod
for part in fullname.split("."):
try:
with warnings.catch_warnings():
# Accessing deprecated objects will generate noisy warnings
warnings.simplefilter("ignore", FutureWarning)
obj = getattr(obj, part)
except AttributeError:
return None

try:
fn = inspect.getsourcefile(inspect.unwrap(obj))
except TypeError:
try: # property
fn = inspect.getsourcefile(inspect.unwrap(obj.fget))
except (AttributeError, TypeError):
fn = None
if not fn:
return None

try:
source, lineno = inspect.getsourcelines(obj)
except TypeError:
try: # property
source, lineno = inspect.getsourcelines(obj.fget)
except (AttributeError, TypeError):
lineno = None
except OSError:
lineno = None

if lineno:
linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
else:
linespec = ""

fn = os.path.relpath(fn, start=os.path.dirname(parcels.__file__))

if "-" in parcels.__version__:
return f"https://github.com/OceanParcels/plasticparcels/blob/master/parcels/{fn}{linespec}"
else:
return (
f"https://github.com/OceanParcels/plasticparcels/blob/"
f"{parcels.__version__}/parcels/{fn}{linespec}"
)
12 changes: 12 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Examples
========

PlasticParcels has a few example notebooks, see below.



.. nbgallery::
:caption: Running simulations
:name: running-simulations

examples/example_Italy_coast.ipynb
3 changes: 1 addition & 2 deletions docs/examples/example_Italy_coast.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# PlasticParcels Example\n",
"## The pathways and fate of Italian coastal plastic pollution\n",
"# The pathways and fate of Italian coastal plastic pollution\n",
"In this example, we will use `plasticparcels` to run a basic simulation of microplastic pollution along the Italian coastline."
]
},
Expand Down
20 changes: 20 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. plasticparcels documentation master file, created by
sphinx-quickstart on Fri May 3 09:55:52 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
PlasticParcels documentation
============================

Welcome to the documentation of PlasticParcels.

``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.


.. toctree::
:maxdepth: 2
:caption: Contents

Home <self>
Examples <examples>
OceanParcels website <https://oceanparcels.org/>
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd

0 comments on commit 0c5c50d

Please sign in to comment.