Skip to content

Commit 6f9918f

Browse files
authored
13 create a gallery (#15)
* Fixed tutorial 1 and 2 * set widths to 17cm * Removed .py tutorials * Added pre-commit config * Converted tutorials to ipynb * Adde pre-commit to pyproject.toml * Cleaned out tutorials * added tutorial 5 and 6 * Added docs * moved docs to new workflow * Commented out compile_pdf * Formatting * formatting * Added deployment * fix * Try using the gh template * bugfix * build on push to 13-create-a-gallery * removed temp branch from docs.yml
1 parent 297a871 commit 6f9918f

22 files changed

+727
-2395
lines changed

.github/workflows/ci_pipeline.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Install python dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install ".[test]"
31+
pip install ".[dev]"
3232
3333
- name: Inspect maxplotlib arguments
3434
run: |
@@ -38,3 +38,7 @@ jobs:
3838
run: |
3939
coverage run -m pytest .
4040
coverage report --sort=cover
41+
42+
- name: Test tutorials
43+
run: |
44+
jupyter nbconvert --to notebook --execute tutorials/*.ipynb --output-dir=/tmp --ExecutePreprocessor.timeout=300

.github/workflows/docs.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy docs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: ["devel", "main"] # TODO: Set to main only after release
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build-and-deploy:
19+
runs-on: ubuntu-latest
20+
environment:
21+
name: github-pages
22+
url: ${{ steps.deployment.outputs.page_url }}
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Install pandoc
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y pandoc
32+
33+
- name: Install Python dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install ".[docs]"
37+
38+
- name: Build Sphinx docs
39+
run: |
40+
cd docs
41+
make html
42+
43+
- name: Setup Pages
44+
uses: actions/configure-pages@v5
45+
46+
- name: Upload built docs
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: docs/build/html/
50+
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0 # Use the latest stable version
4+
hooks:
5+
- id: check-added-large-files # Prevent giant files from being committed.
6+
args: ["--maxkb=1000"]
7+
- id: check-merge-conflict # Check for files that contain merge conflict strings.
8+
- id: check-toml # Attempts to load all TOML files to verify syntax.
9+
- id: check-yaml # Attempts to load all yaml files to verify syntax.
10+
args: ["--unsafe"]
11+
12+
- repo: https://github.com/kynan/nbstripout
13+
rev: 0.8.1
14+
hooks:
15+
- id: nbstripout # remove jupyter notebook cell output

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 = source
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)

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=source
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

docs/source/conf.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
import os
7+
import shutil
8+
9+
10+
def copy_tutorials(app):
11+
src = os.path.abspath("../tutorials")
12+
dst = os.path.abspath("source/tutorials")
13+
14+
# Remove existing target directory if it exists
15+
if os.path.exists(dst):
16+
shutil.rmtree(dst)
17+
18+
shutil.copytree(src, dst)
19+
20+
21+
def setup(app):
22+
app.connect("builder-inited", copy_tutorials)
23+
24+
25+
# -- Project information -----------------------------------------------------
26+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
27+
28+
project = "maxplotlib"
29+
copyright = "2025, Max Lindqvist"
30+
author = "Max Lindqvist"
31+
32+
# -- General configuration ---------------------------------------------------
33+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
34+
35+
extensions = [
36+
"nbsphinx",
37+
"sphinx.ext.mathjax",
38+
"sphinx.ext.autodoc",
39+
]
40+
41+
templates_path = ["_templates"]
42+
exclude_patterns = []
43+
44+
45+
# -- Options for HTML output -------------------------------------------------
46+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
47+
48+
html_theme = "sphinx_rtd_theme"
49+
html_static_path = ["_static"]

docs/source/index.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. maxplotlib documentation master file, created by
2+
sphinx-quickstart on Sun Jun 22 11:14:00 2025.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
maxplotlib documentation
7+
========================
8+
9+
Add your content using ``reStructuredText`` syntax. See the
10+
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
11+
documentation for details.
12+
13+
14+
.. toctree::
15+
:maxdepth: 2
16+
:caption: Tutorials:
17+
18+
tutorials/tutorial_01
19+
tutorials/tutorial_02
20+
tutorials/tutorial_03
21+
tutorials/tutorial_04
22+
tutorials/tutorial_05
23+
tutorials/tutorial_06

pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,23 @@ test = [
2424
"pytest",
2525
"coverage",
2626
]
27+
docs = [
28+
"myst-parser",
29+
"sphinx",
30+
"sphinx-rtd-theme",
31+
"nbsphinx",
32+
"ipykernel",
33+
"nbconvert",
34+
]
2735
dev = [
28-
"maxplotlib[test]",
36+
"maxplotlib[test,docs]",
2937
"ruff",
3038
"black",
3139
"isort",
3240
"jupyterlab",
41+
"nbstripout",
42+
"pre-commit",
43+
"pyproject-fmt",
3344
]
3445
[project.urls]
3546
"Source" = "https://github.com/max-models/maxplotlib"

src/maxplotlib/canvas/canvas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def plot_matplotlib(self, show=True, savefig=False, layers=None, usetex=False):
205205

206206
for (row, col), subplot in self.subplots.items():
207207
ax = axes[row][col]
208+
# print(f"{subplot = }")
208209
subplot.plot_matplotlib(ax, layers=layers)
209210
# ax.set_title(f"Subplot ({row}, {col})")
210211
ax.grid()

src/maxplotlib/subfigure/line_plot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def add_node(self, x, y, label=None, content="", layer=0, **kwargs):
247247
if layer in self.layers:
248248
self.layers[layer].add(node)
249249
else:
250+
# print(f"{self.layers = } {layer = }")
250251
self.layers[layer] = Tikzlayer(layer)
251252
self.layers[layer].add(node)
252253
self._node_counter += 1

0 commit comments

Comments
 (0)