From 3cb66aaa03ad8063a7c51fbb2277bd22c0a1ea75 Mon Sep 17 00:00:00 2001 From: maxlin-ipp Date: Sun, 17 Nov 2024 19:28:48 +0100 Subject: [PATCH 01/25] Update to gitignore --- tests/unit/__init__.py | 0 tests/unit/test_app.py | 7 +++++++ 2 files changed, 7 insertions(+) create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/test_app.py diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_app.py b/tests/unit/test_app.py new file mode 100644 index 0000000..386da12 --- /dev/null +++ b/tests/unit/test_app.py @@ -0,0 +1,7 @@ +def test_import_app(): + from app.main import main + print('app imported') + main() + +if __name__ == '__main__': + test_import_app() \ No newline at end of file From 545702a299e69999ae0f1ac33c6f46c5ee3c815a Mon Sep 17 00:00:00 2001 From: maxlin-ipp Date: Sun, 17 Nov 2024 19:55:37 +0100 Subject: [PATCH 02/25] formatting --- tests/unit/test_app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_app.py b/tests/unit/test_app.py index 386da12..5e9299e 100644 --- a/tests/unit/test_app.py +++ b/tests/unit/test_app.py @@ -1,7 +1,9 @@ def test_import_app(): from app.main import main - print('app imported') + + print("app imported") main() -if __name__ == '__main__': - test_import_app() \ No newline at end of file + +if __name__ == "__main__": + test_import_app() From 6453675c000d36637b71e2f60bcd4be05d7a0c69 Mon Sep 17 00:00:00 2001 From: maxlin-ipp Date: Tue, 11 Feb 2025 22:04:59 +0100 Subject: [PATCH 03/25] Lint in separate job --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e89673..3ef5fb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,10 @@ jobs: pytest . -xvs env: CI: true + + # Linting job + lint: + runs-on: ubuntu-latest - name: Test tutorial notebooks run: | From aaba56d2a826c11f0089caa5b0166d11a4499eaa Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 20 Apr 2025 11:52:41 +0200 Subject: [PATCH 04/25] Added docs dependencies --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 3cdbc4c..2cee812 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,11 @@ docs = [ "sphinx-rtd-theme", "scipy", ] +# https://medium.com/@pratikdomadiya123/build-project-documentation-quickly-with-the-sphinx-python-2a9732b66594 +docs = [ + "sphinx", + "sphinx_rtd_theme", +] [project.urls] "Source" = "https://github.com/max-models/maxtikzlib" From 6443bc70e35e99ccf7805f0d86b5adf153293658 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 20 Apr 2025 11:52:57 +0200 Subject: [PATCH 05/25] Added docs --- docs/conf.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 17 ++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 docs/conf.py create mode 100644 docs/index.rst diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..0c2f42c --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,54 @@ +# 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 +import os +import sys + +# sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath("../src/app")) + + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = "python-template" +copyright = "2025, Max" +author = "Max" + +# The full version, including alpha/beta/rc tags +release = "1.0.0" + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.viewcode", + "sphinx.ext.napoleon", + # 'myst_parser', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..e354a7c --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,17 @@ +.. python-template documentation master file, created by + sphinx-quickstart on Sun Apr 20 11:40:45 2025. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +python-template documentation +============================= + +Add your content using ``reStructuredText`` syntax. See the +`reStructuredText `_ +documentation for details. + + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + From bbb5535d4f7a5fa91eb673d6cc547776b89a35d8 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 20 Apr 2025 12:16:33 +0200 Subject: [PATCH 06/25] Create jekyll-gh-pages.yml --- .github/workflows/jekyll-gh-pages.yml | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/jekyll-gh-pages.yml diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml new file mode 100644 index 0000000..4b8bc4f --- /dev/null +++ b/.github/workflows/jekyll-gh-pages.yml @@ -0,0 +1,51 @@ +# Sample workflow for building and deploying a Jekyll site to GitHub Pages +name: Deploy Jekyll with GitHub Pages dependencies preinstalled + +on: + # Runs on pushes targeting the default branch + push: + branches: ["devel"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./ + destination: ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From a0da763cec80d6b12f940168eef28844e808eda2 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 20 Apr 2025 12:21:26 +0200 Subject: [PATCH 07/25] Set paths --- .github/workflows/jekyll-gh-pages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index 4b8bc4f..67b54ae 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -33,8 +33,8 @@ jobs: - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: - source: ./ - destination: ./_site + source: docs/ + destination: docs/_site - name: Upload artifact uses: actions/upload-pages-artifact@v3 From 89297656ddcd8c20378a8118a24dfb30669f490e Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 20 Apr 2025 16:02:43 +0200 Subject: [PATCH 08/25] docs testsing --- .github/workflows/jekyll-gh-pages.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index 67b54ae..150ae76 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -5,6 +5,10 @@ on: # Runs on pushes targeting the default branch push: branches: ["devel"] + pull_request: + branches: + - main + - devel # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -30,6 +34,15 @@ jobs: uses: actions/checkout@v4 - name: Setup Pages uses: actions/configure-pages@v5 + - name: Install dependencies + run: | + pip install ".[docs]" + - name: Sphinx build + run: | + sphinx-apidoc -o docs/ src/app/ + cd docs/ + make clean + make html - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: From eed536490c4595abfa8588a4c6b3943d1fae43c7 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:05:47 +0200 Subject: [PATCH 09/25] Cleaned up testing --- .github/workflows/ci.yml | 92 ----------------------------------- .github/workflows/testing.yml | 61 +++++++++++++++++++++++ 2 files changed, 61 insertions(+), 92 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 3ef5fb6..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: CI - -on: - push: - branches: - - main - - devel - pull_request: - branches: - - main - - devel - -defaults: - run: - shell: bash - -jobs: - build: - runs-on: ubuntu-latest - container: - image: texlive/texlive:latest - - steps: - # Checkout the repository - - name: Checkout code - uses: actions/checkout@v4 - - # Set up Python - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - # Cache pip dependencies - - name: Cache pip - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install pandoc - run: | - apt-get update - apt-get install -y pandoc - - # - name: Install TeX Live with pdflatex - # run: | - # sudo apt-get update - # sudo apt-get install -y texlive-full - # sudo apt-get install -y texlive texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-science - - - name: Check if pdflatex is available - run: | - which pdflatex - pdflatex --version - - # Create virtual environment and install project from pyproject.toml - - name: Set up virtual environment and install project - run: | - python -m venv env - source env/bin/activate - pip install --upgrade pip - pip install ".[test, dev, docs]" - - # Run tests - - name: Run tests - run: | - source env/bin/activate - pytest . -xvs - env: - CI: true - - # Linting job - lint: - runs-on: ubuntu-latest - - - name: Test tutorial notebooks - run: | - source env/bin/activate - jupyter nbconvert --to notebook --execute tutorials/*.ipynb --output-dir=/tmp --ExecutePreprocessor.timeout=300 - - - name: Test docs build - run: | - source env/bin/activate - pip install ".[docs]" - cd docs - make clean - make html - cd .. - ls docs/build/html/index.html \ No newline at end of file diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..fe24a48 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,61 @@ +name: Tests + +on: + push: + branches: + - main + - devel + pull_request: + branches: + - main + - devel + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Checkout the repository + - name: Checkout code + uses: actions/checkout@v3 + + # Set up Python + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' # Adjust as needed + + # Cache pip dependencies + - name: Cache pip + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install project + run: | + pip install --upgrade pip + pip install ".[test]" + + - name: Check installation + run: | + template-python + + - name: Run tests + run: | + pytest . + + - name: Test tutorials + run: | + jupyter nbconvert --to notebook --execute tutorials/*.ipynb --output-dir=/tmp --ExecutePreprocessor.timeout=300 + + - name: Test docs build + run: | + pip install ".[docs]" + cd docs + make clean + make html + cd .. + ls docs/_build/html/index.html \ No newline at end of file From 3c265ac7d5fc2ae384a2dd9c9a221d74f151105f Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:12:27 +0200 Subject: [PATCH 10/25] Added deps --- pyproject.toml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2cee812..e3d603d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,10 +43,17 @@ docs = [ "sphinx-rtd-theme", "scipy", ] + # https://medium.com/@pratikdomadiya123/build-project-documentation-quickly-with-the-sphinx-python-2a9732b66594 docs = [ + "myst-parser", "sphinx", - "sphinx_rtd_theme", + "sphinx-rtd-theme", + "nbsphinx", + "ipykernel", + "nbconvert", + "pre-commit", + "pyproject-fmt", ] [project.urls] From 6465439f3bb19c7237b3845daf437284483bb1eb Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:12:51 +0200 Subject: [PATCH 11/25] Formatted pyproject.toml with pyproject-fmt --- pyproject.toml | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e3d603d..2c918f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,26 @@ [build-system] -requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" +requires = [ "setuptools", "wheel" ] + [project] name = "maxtikzlib" version = "0.1" description = "Python interface to generate (readable) Tikz figures." readme = "README.md" +keywords = [ "python" ] +license = { file = "LICENSE.txt" } +authors = [ { name = "Max" } ] requires-python = ">=3.8" -license = {file = "LICENSE.txt"} -keywords = ["python"] -authors = [{name = "Max"}] classifiers = [ - "Development Status :: 3 - Alpha", + "Development Status :: 3 - Alpha", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] dependencies = [ "matplotlib", @@ -43,17 +51,16 @@ docs = [ "sphinx-rtd-theme", "scipy", ] - # https://medium.com/@pratikdomadiya123/build-project-documentation-quickly-with-the-sphinx-python-2a9732b66594 -docs = [ - "myst-parser", - "sphinx", - "sphinx-rtd-theme", - "nbsphinx", - "ipykernel", - "nbconvert", - "pre-commit", - "pyproject-fmt", +optional-dependencies.docs = [ + "ipykernel", + "myst-parser", + "nbconvert", + "nbsphinx", + "pre-commit", + "pyproject-fmt", + "sphinx", + "sphinx-rtd-theme", ] [project.urls] From 6cebfe34b6c38b3e9f4fd876ab456c08c8754a24 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:14:14 +0200 Subject: [PATCH 12/25] Removed .github/workflows/jekyll-gh-pages.yml --- .github/workflows/jekyll-gh-pages.yml | 64 --------------------------- 1 file changed, 64 deletions(-) delete mode 100644 .github/workflows/jekyll-gh-pages.yml diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml deleted file mode 100644 index 150ae76..0000000 --- a/.github/workflows/jekyll-gh-pages.yml +++ /dev/null @@ -1,64 +0,0 @@ -# Sample workflow for building and deploying a Jekyll site to GitHub Pages -name: Deploy Jekyll with GitHub Pages dependencies preinstalled - -on: - # Runs on pushes targeting the default branch - push: - branches: ["devel"] - pull_request: - branches: - - main - - devel - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: "pages" - cancel-in-progress: false - -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Pages - uses: actions/configure-pages@v5 - - name: Install dependencies - run: | - pip install ".[docs]" - - name: Sphinx build - run: | - sphinx-apidoc -o docs/ src/app/ - cd docs/ - make clean - make html - - name: Build with Jekyll - uses: actions/jekyll-build-pages@v1 - with: - source: docs/ - destination: docs/_site - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 From 40b5ffaf6b67a86683aba369535965d5d5a2ab15 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:16:29 +0200 Subject: [PATCH 13/25] Install with dev in the ci --- .github/workflows/testing.yml | 2 +- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index fe24a48..b713ea5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -37,7 +37,7 @@ jobs: - name: Install project run: | pip install --upgrade pip - pip install ".[test]" + pip install ".[dev]" - name: Check installation run: | diff --git a/pyproject.toml b/pyproject.toml index 2c918f8..7b82033 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,7 @@ optional-dependencies.docs = [ "myst-parser", "nbconvert", "nbsphinx", + "jupyterlab", "pre-commit", "pyproject-fmt", "sphinx", From 2db6e2c8b632b89dcfd360869ba6dd1918b6e012 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:18:39 +0200 Subject: [PATCH 14/25] build --> _build --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 08bbf57..10a1708 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -78,7 +78,7 @@ jobs: - name: Upload built docs uses: actions/upload-pages-artifact@v3 with: - path: docs/build/html/ + path: docs/_build/html/ - name: Deploy to GitHub Pages id: deployment From 9bbce4d0e7033affa0d088f83e27d223dc6b4aae Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:19:52 +0200 Subject: [PATCH 15/25] build tutorial in ci --- docs/conf.py | 19 ++++++++++++++++++- docs/index.rst | 4 +++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0c2f42c..920635b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,6 +4,23 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html import os import sys +import shutil + + +def copy_tutorials(app): + src = os.path.abspath("../tutorials") + dst = os.path.abspath("source/tutorials") + + # Remove existing target directory if it exists + if os.path.exists(dst): + shutil.rmtree(dst) + + shutil.copytree(src, dst) + + +def setup(app): + app.connect("builder-inited", copy_tutorials) + # sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0, os.path.abspath("../src/app")) @@ -51,4 +68,4 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] \ No newline at end of file +html_static_path = ["_static"] diff --git a/docs/index.rst b/docs/index.rst index e354a7c..439c8d8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -13,5 +13,7 @@ documentation for details. .. toctree:: :maxdepth: 2 - :caption: Contents: + :caption: Tutorials: + + tutorials/tutorial_01 From 44970d000f199b8109e3de69dca30622f7d54507 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:31:01 +0200 Subject: [PATCH 16/25] removed docs --- docs/Makefile | 20 -------------- docs/conf.py | 71 ------------------------------------------------ docs/index.rst | 19 ------------- docs/main.rst | 7 ----- docs/make.bat | 35 ------------------------ docs/modules.rst | 7 ----- 6 files changed, 159 deletions(-) delete mode 100644 docs/Makefile delete mode 100644 docs/conf.py delete mode 100644 docs/index.rst delete mode 100644 docs/main.rst delete mode 100644 docs/make.bat delete mode 100644 docs/modules.rst diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index d0c3cbf..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# 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 = source -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) diff --git a/docs/conf.py b/docs/conf.py deleted file mode 100644 index 920635b..0000000 --- a/docs/conf.py +++ /dev/null @@ -1,71 +0,0 @@ -# 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 -import os -import sys -import shutil - - -def copy_tutorials(app): - src = os.path.abspath("../tutorials") - dst = os.path.abspath("source/tutorials") - - # Remove existing target directory if it exists - if os.path.exists(dst): - shutil.rmtree(dst) - - shutil.copytree(src, dst) - - -def setup(app): - app.connect("builder-inited", copy_tutorials) - - -# sys.path.insert(0, os.path.abspath('..')) -sys.path.insert(0, os.path.abspath("../src/app")) - - -# -- Project information ----------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information - -project = "python-template" -copyright = "2025, Max" -author = "Max" - -# The full version, including alpha/beta/rc tags -release = "1.0.0" - - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.viewcode", - "sphinx.ext.napoleon", - # 'myst_parser', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = "sphinx_rtd_theme" - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 439c8d8..0000000 --- a/docs/index.rst +++ /dev/null @@ -1,19 +0,0 @@ -.. python-template documentation master file, created by - sphinx-quickstart on Sun Apr 20 11:40:45 2025. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -python-template documentation -============================= - -Add your content using ``reStructuredText`` syntax. See the -`reStructuredText `_ -documentation for details. - - -.. toctree:: - :maxdepth: 2 - :caption: Tutorials: - - tutorials/tutorial_01 - diff --git a/docs/main.rst b/docs/main.rst deleted file mode 100644 index eace87b..0000000 --- a/docs/main.rst +++ /dev/null @@ -1,7 +0,0 @@ -main module -=========== - -.. automodule:: main - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100644 index 747ffb7..0000000 --- a/docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -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 diff --git a/docs/modules.rst b/docs/modules.rst deleted file mode 100644 index 6378a90..0000000 --- a/docs/modules.rst +++ /dev/null @@ -1,7 +0,0 @@ -app -=== - -.. toctree:: - :maxdepth: 4 - - main From 61ce06fea747069616c69b0fdb8bc42fef454898 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:33:58 +0200 Subject: [PATCH 17/25] Updated docs --- docs/Makefile | 20 ++++++++++++++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/make.bat diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -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 = source +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) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +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 From e376d6e87a389a1830b54870b4c14c943c9cc997 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:40:40 +0200 Subject: [PATCH 18/25] Added pandoc to docs --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 7b82033..fb7cd4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ optional-dependencies.docs = [ "nbconvert", "nbsphinx", "jupyterlab", + "pandoc", "pre-commit", "pyproject-fmt", "sphinx", From 9bacfc448f61c97690f4db1e7fc7eaabac89d673 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:45:54 +0200 Subject: [PATCH 19/25] Install pandoc with apt-get --- .github/workflows/testing.yml | 5 +++++ pyproject.toml | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b713ea5..79ef452 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -34,6 +34,11 @@ jobs: restore-keys: | ${{ runner.os }}-pip- + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y pandoc + - name: Install project run: | pip install --upgrade pip diff --git a/pyproject.toml b/pyproject.toml index fb7cd4e..7b82033 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,6 @@ optional-dependencies.docs = [ "nbconvert", "nbsphinx", "jupyterlab", - "pandoc", "pre-commit", "pyproject-fmt", "sphinx", From d291c0a9bad0a4303c1944a445a4d2f1e123b603 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:48:31 +0200 Subject: [PATCH 20/25] _build --> build --- .github/workflows/docs.yml | 2 +- .github/workflows/testing.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 10a1708..08bbf57 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -78,7 +78,7 @@ jobs: - name: Upload built docs uses: actions/upload-pages-artifact@v3 with: - path: docs/_build/html/ + path: docs/build/html/ - name: Deploy to GitHub Pages id: deployment diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 79ef452..f84e48c 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -63,4 +63,4 @@ jobs: make clean make html cd .. - ls docs/_build/html/index.html \ No newline at end of file + ls docs/build/html/index.html \ No newline at end of file From 69bc73441b2494defb42560762b3fc442be95b7e Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 22 Jun 2025 16:54:50 +0200 Subject: [PATCH 21/25] Added link to documentation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5df426f..bed5680 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Python interface to generate (readable) Tikz figures. Documentation: https://max-models.github.io/maxtikzlib/ +Documentation: https://max-models.github.io/template-python/ + # Install Create and activate python environment From dcb442d9304a021ef460677215b3de8f5cba10e8 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 13 Sep 2025 19:29:32 +0200 Subject: [PATCH 22/25] Split the linting in the CI into multiple jobs (#6) * Reference tutorials with glob instead of specific paths * Split each linter into it's own job --- .github/workflows/static_analysis.yml | 63 ++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index bf3f9b6..2fba12b 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -10,8 +10,12 @@ on: - main - devel +defaults: + run: + shell: bash + jobs: - static-analysis: + cloc: runs-on: ubuntu-latest steps: - name: Checkout the code @@ -24,39 +28,74 @@ jobs: ./cloc --version ./cloc $(git ls-files) + black: + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - name: Code formatting with black run: | - pip install black - pip install "black[jupyter]" + pip install black "black[jupyter]" black --check src/ black --check tutorials/ + isort: + runs-on: ubuntu-latest + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - name: Code formatting with isort run: | pip install isort isort --check src/ isort --check tutorials/ - - name: Code formatting with mypy - continue-on-error: true + mypy: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Type checking with mypy run: | pip install mypy mypy src/ - - name: Code formatting with prospector - continue-on-error: true + prospector: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Code analysis with prospector run: | pip install prospector prospector src/ - - - name: Code formatting with ruff - continue-on-error: true + + ruff: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Linting with ruff run: | pip install ruff ruff check src/ - - name: Code formatting with pylint - continue-on-error: true + pylint: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Linting with pylint run: | pip install pylint pylint src/ From d085cfc85ad9c5099eef96b0ce7f23f5ea47ea28 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 13 Sep 2025 19:37:49 +0200 Subject: [PATCH 23/25] Removed unneccesary files --- .github/workflows/testing.yml | 66 ----------------------------------- tests/unit/__init__.py | 0 tests/unit/test_app.py | 9 ----- 3 files changed, 75 deletions(-) delete mode 100644 .github/workflows/testing.yml delete mode 100644 tests/unit/__init__.py delete mode 100644 tests/unit/test_app.py diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml deleted file mode 100644 index f84e48c..0000000 --- a/.github/workflows/testing.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Tests - -on: - push: - branches: - - main - - devel - pull_request: - branches: - - main - - devel - -jobs: - build: - runs-on: ubuntu-latest - - steps: - # Checkout the repository - - name: Checkout code - uses: actions/checkout@v3 - - # Set up Python - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' # Adjust as needed - - # Cache pip dependencies - - name: Cache pip - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y pandoc - - - name: Install project - run: | - pip install --upgrade pip - pip install ".[dev]" - - - name: Check installation - run: | - template-python - - - name: Run tests - run: | - pytest . - - - name: Test tutorials - run: | - jupyter nbconvert --to notebook --execute tutorials/*.ipynb --output-dir=/tmp --ExecutePreprocessor.timeout=300 - - - name: Test docs build - run: | - pip install ".[docs]" - cd docs - make clean - make html - cd .. - ls docs/build/html/index.html \ No newline at end of file diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/test_app.py b/tests/unit/test_app.py deleted file mode 100644 index 5e9299e..0000000 --- a/tests/unit/test_app.py +++ /dev/null @@ -1,9 +0,0 @@ -def test_import_app(): - from app.main import main - - print("app imported") - main() - - -if __name__ == "__main__": - test_import_app() From e876148654096e0febb2e99d9d36341ca0dcd16d Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 13 Sep 2025 19:45:48 +0200 Subject: [PATCH 24/25] Added || true to mypy, prospector, pylint, and ruff (#7) * Reference tutorials with glob instead of specific paths * Split each linter into it's own job * Added || true --- .github/workflows/static_analysis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index 2fba12b..61b3cb6 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -62,7 +62,7 @@ jobs: - name: Type checking with mypy run: | pip install mypy - mypy src/ + mypy src/ || true prospector: runs-on: ubuntu-latest @@ -74,7 +74,7 @@ jobs: - name: Code analysis with prospector run: | pip install prospector - prospector src/ + prospector src/ || true ruff: runs-on: ubuntu-latest @@ -86,7 +86,7 @@ jobs: - name: Linting with ruff run: | pip install ruff - ruff check src/ + ruff check src/ || true pylint: runs-on: ubuntu-latest @@ -98,4 +98,4 @@ jobs: - name: Linting with pylint run: | pip install pylint - pylint src/ + pylint src/ || true From d0d5da3fbe7527c0af284ed01d524747fb7d83e4 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 13 Sep 2025 19:54:21 +0200 Subject: [PATCH 25/25] Restored files to devel versions --- .github/workflows/ci.yml | 88 ++++++++++++++++++++++++++++++++++++++++ README.md | 2 - docs/main.rst | 7 ++++ docs/modules.rst | 7 ++++ pyproject.toml | 30 +++----------- 5 files changed, 107 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 docs/main.rst create mode 100644 docs/modules.rst diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4e89673 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,88 @@ +name: CI + +on: + push: + branches: + - main + - devel + pull_request: + branches: + - main + - devel + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + container: + image: texlive/texlive:latest + + steps: + # Checkout the repository + - name: Checkout code + uses: actions/checkout@v4 + + # Set up Python + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + # Cache pip dependencies + - name: Cache pip + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install pandoc + run: | + apt-get update + apt-get install -y pandoc + + # - name: Install TeX Live with pdflatex + # run: | + # sudo apt-get update + # sudo apt-get install -y texlive-full + # sudo apt-get install -y texlive texlive-latex-base texlive-latex-extra texlive-fonts-recommended texlive-science + + - name: Check if pdflatex is available + run: | + which pdflatex + pdflatex --version + + # Create virtual environment and install project from pyproject.toml + - name: Set up virtual environment and install project + run: | + python -m venv env + source env/bin/activate + pip install --upgrade pip + pip install ".[test, dev, docs]" + + # Run tests + - name: Run tests + run: | + source env/bin/activate + pytest . -xvs + env: + CI: true + + - name: Test tutorial notebooks + run: | + source env/bin/activate + jupyter nbconvert --to notebook --execute tutorials/*.ipynb --output-dir=/tmp --ExecutePreprocessor.timeout=300 + + - name: Test docs build + run: | + source env/bin/activate + pip install ".[docs]" + cd docs + make clean + make html + cd .. + ls docs/build/html/index.html \ No newline at end of file diff --git a/README.md b/README.md index bed5680..5df426f 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ Python interface to generate (readable) Tikz figures. Documentation: https://max-models.github.io/maxtikzlib/ -Documentation: https://max-models.github.io/template-python/ - # Install Create and activate python environment diff --git a/docs/main.rst b/docs/main.rst new file mode 100644 index 0000000..eace87b --- /dev/null +++ b/docs/main.rst @@ -0,0 +1,7 @@ +main module +=========== + +.. automodule:: main + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/modules.rst b/docs/modules.rst new file mode 100644 index 0000000..6378a90 --- /dev/null +++ b/docs/modules.rst @@ -0,0 +1,7 @@ +app +=== + +.. toctree:: + :maxdepth: 4 + + main diff --git a/pyproject.toml b/pyproject.toml index 7b82033..3cdbc4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,26 +1,18 @@ [build-system] +requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" -requires = [ "setuptools", "wheel" ] - [project] name = "maxtikzlib" version = "0.1" description = "Python interface to generate (readable) Tikz figures." readme = "README.md" -keywords = [ "python" ] -license = { file = "LICENSE.txt" } -authors = [ { name = "Max" } ] requires-python = ">=3.8" +license = {file = "LICENSE.txt"} +keywords = ["python"] +authors = [{name = "Max"}] classifiers = [ - "Development Status :: 3 - Alpha", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", + "Development Status :: 3 - Alpha", ] dependencies = [ "matplotlib", @@ -51,18 +43,6 @@ docs = [ "sphinx-rtd-theme", "scipy", ] -# https://medium.com/@pratikdomadiya123/build-project-documentation-quickly-with-the-sphinx-python-2a9732b66594 -optional-dependencies.docs = [ - "ipykernel", - "myst-parser", - "nbconvert", - "nbsphinx", - "jupyterlab", - "pre-commit", - "pyproject-fmt", - "sphinx", - "sphinx-rtd-theme", -] [project.urls] "Source" = "https://github.com/max-models/maxtikzlib"