Skip to content

Commit 20594d5

Browse files
committed
DOC: update readthedocs and replace sphinx-nbexamples with nbsphinx
1 parent bb761b3 commit 20594d5

File tree

4 files changed

+43
-7
lines changed

4 files changed

+43
-7
lines changed

.readthedocs.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
version: 2
22

3-
sphinx:
4-
configuration: docs/conf.py
3+
build:
4+
os: ubuntu-22.04
5+
tools:
6+
python: "3.12"
57

68
python:
7-
version: 3.7
89
install:
9-
- requirements: requirements-dev.txt
10+
- requirements: requirements-dev.txt
11+
- method: pip
12+
path: .
13+
14+
sphinx:
15+
configuration: docs/conf.py

docs/conf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import importlib
2+
import os
23
import pathlib
4+
import sys
35

46
author = "Brian de Silva, Krithika Manohar, Emily Clark"
57
project = "pysensors" # package name
@@ -11,6 +13,7 @@
1113

1214
module = importlib.import_module(project)
1315
version = release = getattr(module, "__version__")
16+
sys.path.insert(0, os.path.abspath("."))
1417

1518
# The master toctree document.
1619
master_doc = "index"
@@ -22,7 +25,8 @@
2225
"sphinx.ext.autosummary",
2326
"sphinx.ext.napoleon",
2427
"sphinx.ext.mathjax",
25-
"sphinx_nbexamples",
28+
"nbsphinx",
29+
"sphinx_copy_examples",
2630
]
2731

2832
apidoc_module_dir = f"../{project}"
@@ -33,7 +37,7 @@
3337
autodoc_member_order = "bysource"
3438
autoclass_content = "init"
3539

36-
language = None
40+
language = "en"
3741

3842
here = pathlib.Path(__file__).parent
3943

docs/sphinx_copy_examples.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import shutil
2+
from pathlib import Path
3+
4+
from sphinx.application import Sphinx
5+
6+
7+
def setup(app: Sphinx):
8+
"""Copy notebooks and supporting files from examples/ to docs/examples/"""
9+
source = Path(__file__).parent.parent / "examples"
10+
target = Path(__file__).parent / "examples"
11+
12+
if target.exists():
13+
shutil.rmtree(target)
14+
target.mkdir()
15+
16+
for item in source.rglob("*"):
17+
# Accomodates for any helper scripts and data files
18+
rel_path = item.relative_to(source)
19+
dest_path = target / rel_path
20+
21+
if item.is_dir():
22+
dest_path.mkdir(parents=True, exist_ok=True)
23+
else:
24+
dest_path.parent.mkdir(parents=True, exist_ok=True)
25+
shutil.copy2(item, dest_path)
26+
print(f"Copied {rel_path}")

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ sphinx >= 2
1212
sphinxcontrib-apidoc
1313
sphinx_rtd_theme
1414
pre-commit
15-
sphinx-nbexamples
15+
nbsphinx

0 commit comments

Comments
 (0)