Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVG converter, fix PDF rendering on ReadTheDocs #407

Merged
merged 11 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ docs/.jupyter_cache
docs/apidoc/modules.rst
docs/apidoc/ravenpy*.rst
docs/jupyter_execute
docs/readme.rst

# PyBuilder
target/
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Internal changes
* Added `setuptools` to the `gis` build recipe to ensure that the `gdal` bindings are built successfully. (PR #400)
* Modified the sub-basin and channel profile extraction functions to correctly set the river length to zero and set default values for reach attributes in sub-basins with no channel routing (i.e., sub-basins with lakes or headwater basins). (issue #354, PR #401)
* Improved the HBV-EC emulator by adding parameter information (name, definition, and Raven default values), fixed the variable name for the adiabatic temperature lapse rate, and added an alias for rain snow fraction to match other emulators. (PR #404 and #408)
* Modified the `sphinx` configuration to better support SVG and to remove incompatible elements from the PDF build. (PR #407)

v0.15.0 (2024-06-20)
--------------------
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RavenPy
| Development Status | |status| |build| |coveralls| |
+----------------------------+-----------------------------------------------------+


A Python wrapper to setup and run the hydrologic modelling framework Raven_.

* Free software: MIT license
Expand Down
7 changes: 4 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SPHINXPROJ = ravenpy
SOURCEDIR = .
BUILDDIR = _build
Expand Down
38 changes: 31 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,35 @@
import os
import sys
from datetime import date
from pathlib import Path

sys.path.insert(0, os.path.abspath(".."))

import ravenpy # noqa: E402

# -- Workarounds ------------------------------------------------------

def rebuild_readme():
"""Rebuild the readme.rst file from the top-level README.rst file.

This is a workaround to remove the badge table found in the README.rst
when building the docs specifically for latex/pdf output.
"""

with Path("../README.rst").open(encoding="utf-8") as f:
readme = f.read()

# Remove the badge table
readme = readme.replace("=======\nRavenPy\n=======", "=======\nRavenPy\n=======\n\n.. only:: not latex")
readme = readme.replace("\n+-", "\n +-")
readme = readme.replace("\n|", "\n |")

with Path("readme.rst").open("w", encoding="utf-8") as f:
f.write(readme)

rebuild_readme()


# -- General configuration ---------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -42,11 +66,11 @@
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"IPython.sphinxext.ipython_console_highlighting",
# "nbsphinx",
"myst_nb",
"sphinx_click",
"sphinx_codeautolink",
"sphinx_copybutton",
"sphinxcontrib.cairosvgconverter",
# "sphinxcontrib.autodoc_pydantic", # FIXME: Does not seem to be compatible with RavenPy codebase.
]

Expand Down Expand Up @@ -126,7 +150,7 @@

# The suffix(es) of source filenames.
# You can specify multiple suffix as a dictionary of suffix: filetype
source_suffix = {'.rst': 'restructuredtext'}
source_suffix = {".rst": "restructuredtext"}

# The master toctree document.
master_doc = "index"
Expand Down Expand Up @@ -208,16 +232,16 @@
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
Expand Down Expand Up @@ -245,7 +269,7 @@
"RavenPy Documentation",
author,
"ravenpy",
"One line description of project.",
"A Python wrapper to setup and run the hydrologic modelling framework Raven.",
"Miscellaneous",
),
]
1 change: 0 additions & 1 deletion docs/readme.rst

This file was deleted.

5 changes: 3 additions & 2 deletions environment-rtd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ channels:
- conda-forge
- defaults
dependencies:
- python >=3.9,<3.10 # fixed to reduce solver time
- python >=3.10,<3.11 # fixed to reduce solver time
- raven-hydro >=0.3.1,<1.0
- autodoc-pydantic
- cairosvg
- click >=8.0.0
# - clisops # mocked
- gdal >=3.1
Expand Down Expand Up @@ -33,7 +34,7 @@ dependencies:
- sphinx-codeautolink
- sphinx-copybutton
- sphinx-rtd-theme >=1.0
- sphinxcontrib-napoleon
- sphinxcontrib-svg2pdfconverter
- typing_extensions
- wheel
# - xarray # mocked
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ dev = [
docs = [
"autodoc-pydantic",
"birdhouse-birdy",
"cairosvg",
"cartopy",
"clisops",
"gcsfs",
Expand Down Expand Up @@ -123,6 +124,7 @@ docs = [
"sphinx-codeautolink",
"sphinx-copybutton",
"sphinx-rtd-theme >=1.0",
"sphinxcontrib-svg2pdfconverter >=1.2.3",
"xesmf"
]
gis = [
Expand Down