From 3953e3f400ad6ffc83e4ec7cd76d4034f5a8113b Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 20 May 2024 13:27:14 -0400 Subject: [PATCH 1/6] condition to deploy upon PR --- .github/workflows/docs.yml | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..eabc5279 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,49 @@ +name: Build Documentation + +on: + push: + branches: + - main + release: + + pull_request: + branches: + - main + + +jobs: + test: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: build + auto-update-conda: true + + - name: install requirements + run: >- + conda install -n build -c conda-forge + --file requirements/build.txt + --file requirements/run.txt + --file requirements/docs.txt + --quiet --yes + + - name: install the package + run: python -m pip install . --no-deps + + - name: build documents + run: make -C doc/manual html + + - name: Deploy + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./doc/manual/build/html \ No newline at end of file From 9a3594ef2e68b3c0c13cdf6c37bee7374fccb729 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 20 May 2024 13:42:57 -0400 Subject: [PATCH 2/6] Create subdirectory doc/manual --- doc/{ => manual}/Makefile | 0 doc/{ => manual}/images/aspirin_smear.png | Bin doc/{ => manual}/images/aspirin_stretch.png | Bin doc/{ => manual}/images/morph_ex1.png | Bin doc/{ => manual}/images/morph_ex2.png | Bin doc/{ => manual}/images/nacl_example.agr | 0 doc/{ => manual}/images/nacl_example.xcf | Bin doc/{ => manual}/images/pdfmorph_example.agr | 0 doc/{ => manual}/images/pdfmorph_example.png | Bin doc/{ => manual}/images/pdfmorph_example.xcf | Bin doc/{ => manual}/images/pdfmorph_smear.png | Bin doc/{ => manual}/images/pdfmorph_smear2.png | Bin doc/{ => manual}/images/pdfmorph_stretch.png | Bin doc/{ => manual}/make.bat | 70 +++++++++---------- doc/{ => manual}/source/conf.py | 0 doc/{ => manual}/source/index.rst | 0 doc/{ => manual}/source/license.rst | 0 doc/{ => manual}/source/mod_log.rst | 0 doc/{ => manual}/source/mod_pdfplot.rst | 0 doc/{ => manual}/source/mod_refine.rst | 0 doc/{ => manual}/source/mod_tools.rst | 0 doc/{ => manual}/source/morph_helpers.rst | 0 doc/{ => manual}/source/morphs.rst | 0 doc/{ => manual}/source/package.rst | 0 doc/{ => manual}/source/quickstart.rst | 0 doc/{ => manual}/source/release.rst | 0 26 files changed, 35 insertions(+), 35 deletions(-) rename doc/{ => manual}/Makefile (100%) rename doc/{ => manual}/images/aspirin_smear.png (100%) rename doc/{ => manual}/images/aspirin_stretch.png (100%) rename doc/{ => manual}/images/morph_ex1.png (100%) rename doc/{ => manual}/images/morph_ex2.png (100%) rename doc/{ => manual}/images/nacl_example.agr (100%) rename doc/{ => manual}/images/nacl_example.xcf (100%) rename doc/{ => manual}/images/pdfmorph_example.agr (100%) rename doc/{ => manual}/images/pdfmorph_example.png (100%) rename doc/{ => manual}/images/pdfmorph_example.xcf (100%) rename doc/{ => manual}/images/pdfmorph_smear.png (100%) rename doc/{ => manual}/images/pdfmorph_smear2.png (100%) rename doc/{ => manual}/images/pdfmorph_stretch.png (100%) rename doc/{ => manual}/make.bat (95%) rename doc/{ => manual}/source/conf.py (100%) rename doc/{ => manual}/source/index.rst (100%) rename doc/{ => manual}/source/license.rst (100%) rename doc/{ => manual}/source/mod_log.rst (100%) rename doc/{ => manual}/source/mod_pdfplot.rst (100%) rename doc/{ => manual}/source/mod_refine.rst (100%) rename doc/{ => manual}/source/mod_tools.rst (100%) rename doc/{ => manual}/source/morph_helpers.rst (100%) rename doc/{ => manual}/source/morphs.rst (100%) rename doc/{ => manual}/source/package.rst (100%) rename doc/{ => manual}/source/quickstart.rst (100%) rename doc/{ => manual}/source/release.rst (100%) diff --git a/doc/Makefile b/doc/manual/Makefile similarity index 100% rename from doc/Makefile rename to doc/manual/Makefile diff --git a/doc/images/aspirin_smear.png b/doc/manual/images/aspirin_smear.png similarity index 100% rename from doc/images/aspirin_smear.png rename to doc/manual/images/aspirin_smear.png diff --git a/doc/images/aspirin_stretch.png b/doc/manual/images/aspirin_stretch.png similarity index 100% rename from doc/images/aspirin_stretch.png rename to doc/manual/images/aspirin_stretch.png diff --git a/doc/images/morph_ex1.png b/doc/manual/images/morph_ex1.png similarity index 100% rename from doc/images/morph_ex1.png rename to doc/manual/images/morph_ex1.png diff --git a/doc/images/morph_ex2.png b/doc/manual/images/morph_ex2.png similarity index 100% rename from doc/images/morph_ex2.png rename to doc/manual/images/morph_ex2.png diff --git a/doc/images/nacl_example.agr b/doc/manual/images/nacl_example.agr similarity index 100% rename from doc/images/nacl_example.agr rename to doc/manual/images/nacl_example.agr diff --git a/doc/images/nacl_example.xcf b/doc/manual/images/nacl_example.xcf similarity index 100% rename from doc/images/nacl_example.xcf rename to doc/manual/images/nacl_example.xcf diff --git a/doc/images/pdfmorph_example.agr b/doc/manual/images/pdfmorph_example.agr similarity index 100% rename from doc/images/pdfmorph_example.agr rename to doc/manual/images/pdfmorph_example.agr diff --git a/doc/images/pdfmorph_example.png b/doc/manual/images/pdfmorph_example.png similarity index 100% rename from doc/images/pdfmorph_example.png rename to doc/manual/images/pdfmorph_example.png diff --git a/doc/images/pdfmorph_example.xcf b/doc/manual/images/pdfmorph_example.xcf similarity index 100% rename from doc/images/pdfmorph_example.xcf rename to doc/manual/images/pdfmorph_example.xcf diff --git a/doc/images/pdfmorph_smear.png b/doc/manual/images/pdfmorph_smear.png similarity index 100% rename from doc/images/pdfmorph_smear.png rename to doc/manual/images/pdfmorph_smear.png diff --git a/doc/images/pdfmorph_smear2.png b/doc/manual/images/pdfmorph_smear2.png similarity index 100% rename from doc/images/pdfmorph_smear2.png rename to doc/manual/images/pdfmorph_smear2.png diff --git a/doc/images/pdfmorph_stretch.png b/doc/manual/images/pdfmorph_stretch.png similarity index 100% rename from doc/images/pdfmorph_stretch.png rename to doc/manual/images/pdfmorph_stretch.png diff --git a/doc/make.bat b/doc/manual/make.bat similarity index 95% rename from doc/make.bat rename to doc/manual/make.bat index 6247f7e2..9534b018 100644 --- a/doc/make.bat +++ b/doc/manual/make.bat @@ -1,35 +1,35 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build - -if "%1" == "" goto help - -%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.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%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.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/doc/source/conf.py b/doc/manual/source/conf.py similarity index 100% rename from doc/source/conf.py rename to doc/manual/source/conf.py diff --git a/doc/source/index.rst b/doc/manual/source/index.rst similarity index 100% rename from doc/source/index.rst rename to doc/manual/source/index.rst diff --git a/doc/source/license.rst b/doc/manual/source/license.rst similarity index 100% rename from doc/source/license.rst rename to doc/manual/source/license.rst diff --git a/doc/source/mod_log.rst b/doc/manual/source/mod_log.rst similarity index 100% rename from doc/source/mod_log.rst rename to doc/manual/source/mod_log.rst diff --git a/doc/source/mod_pdfplot.rst b/doc/manual/source/mod_pdfplot.rst similarity index 100% rename from doc/source/mod_pdfplot.rst rename to doc/manual/source/mod_pdfplot.rst diff --git a/doc/source/mod_refine.rst b/doc/manual/source/mod_refine.rst similarity index 100% rename from doc/source/mod_refine.rst rename to doc/manual/source/mod_refine.rst diff --git a/doc/source/mod_tools.rst b/doc/manual/source/mod_tools.rst similarity index 100% rename from doc/source/mod_tools.rst rename to doc/manual/source/mod_tools.rst diff --git a/doc/source/morph_helpers.rst b/doc/manual/source/morph_helpers.rst similarity index 100% rename from doc/source/morph_helpers.rst rename to doc/manual/source/morph_helpers.rst diff --git a/doc/source/morphs.rst b/doc/manual/source/morphs.rst similarity index 100% rename from doc/source/morphs.rst rename to doc/manual/source/morphs.rst diff --git a/doc/source/package.rst b/doc/manual/source/package.rst similarity index 100% rename from doc/source/package.rst rename to doc/manual/source/package.rst diff --git a/doc/source/quickstart.rst b/doc/manual/source/quickstart.rst similarity index 100% rename from doc/source/quickstart.rst rename to doc/manual/source/quickstart.rst diff --git a/doc/source/release.rst b/doc/manual/source/release.rst similarity index 100% rename from doc/source/release.rst rename to doc/manual/source/release.rst From 003c182cbed871cbe2e1ec6b4a12d908787f979e Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 20 May 2024 13:53:20 -0400 Subject: [PATCH 3/6] fixing indent --- .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 eabc5279..24a0673b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,7 +8,7 @@ on: pull_request: branches: - - main + - main jobs: From 64d8d523547b9d8c302393e7cf7f524cdc6ecb5d Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 20 May 2024 14:17:00 -0400 Subject: [PATCH 4/6] fix path structure in index.rst, release.rst, and conf.py --- doc/manual/source/conf.py | 2 +- doc/manual/source/index.rst | 2 +- doc/manual/source/release.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/manual/source/conf.py b/doc/manual/source/conf.py index 766b082b..235d9f37 100644 --- a/doc/manual/source/conf.py +++ b/doc/manual/source/conf.py @@ -13,7 +13,7 @@ import sys import os sys.path.insert(0, os.path.abspath('../..')) -sys.path.insert(0, os.path.abspath('../../src')) +sys.path.insert(0, os.path.abspath('../../../src')) # -- Project information ----------------------------------------------------- diff --git a/doc/manual/source/index.rst b/doc/manual/source/index.rst index 51f252e1..4a484320 100644 --- a/doc/manual/source/index.rst +++ b/doc/manual/source/index.rst @@ -63,7 +63,7 @@ To get started, please go to :ref:`quick_start` release package -.. include:: ../../CHANGELOG.rst +.. include:: ../../../CHANGELOG.rst Indices ------- diff --git a/doc/manual/source/release.rst b/doc/manual/source/release.rst index ca8fa0b6..c028e34c 100644 --- a/doc/manual/source/release.rst +++ b/doc/manual/source/release.rst @@ -1,4 +1,4 @@ .. index:: release notes -.. include:: /../../CHANGELOG.rst +.. include:: /../../../CHANGELOG.rst From 6306610ab8a56a0d02bb4ae8cee83a2717f7dd76 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 20 May 2024 19:00:06 -0400 Subject: [PATCH 5/6] pre-commit installation in README --- README.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.rst b/README.rst index 39f7a603..3971272d 100644 --- a/README.rst +++ b/README.rst @@ -150,6 +150,24 @@ rather than copied to a system directory, use :: python -m pip install -e . +CONTRIBUTING +------------------------------------------------------------------------ +We welcome contributors from the community. Please consider posting issues, and taking issues and posting PRs. + +To ensure code quality and to prevent accidental commits into the default branch, please set up the use of our pre-commit +hooks. + +1. modify the permissions to executable on the bash script called ``prevent_commit_to_main.sh`` in this directory: ``chmod +x prevent_commit_to_main.sh`` + +2. install pre-commit in your working environment with ``conda install pre-commit`` + +3. initialize pre-commit (one time only) ``pre-commit install`` + +Thereafter your code will be linted by black and isort and checked against flake8 before you can commit. +If it fails by black or isort, just rerun and it should pass (black and isort will modify the files so should +pass after they are modified). If the flake8 test fails please see the error messages and fix them manually before +trying to commit again + CONTACTS ------------------------------------------------------------------------ From 84665dfff8bd91b30395fe2e794e5b86f7134199 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 20 May 2024 19:06:11 -0400 Subject: [PATCH 6/6] adding pre-commit .sh and .yaml files --- .pre-commit-config.yaml | 33 +++++++++++++++++++++++++++++++++ prevent_commit_to_main.sh | 9 +++++++++ 2 files changed, 42 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100755 prevent_commit_to_main.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..3983a4ea --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +default_language_version: + python: python3 +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/ambv/black + rev: 23.3.0 + hooks: + - id: black + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: ["--profile", "black"] + - repo: https://github.com/kynan/nbstripout + rev: 0.6.1 + hooks: + - id: nbstripout + - repo: local + hooks: + - id: prevent-commit-to-main + name: Prevent Commit to Main Branch + entry: ./prevent_commit_to_main.sh + language: script + stages: [commit] diff --git a/prevent_commit_to_main.sh b/prevent_commit_to_main.sh new file mode 100755 index 00000000..5237b16a --- /dev/null +++ b/prevent_commit_to_main.sh @@ -0,0 +1,9 @@ +#!/bin/sh +##!"C:\\Program Files\\Git\\usr\\bin\\bash.exe" + +branch="$(git rev-parse --abbrev-ref HEAD)" + +if [ "$branch" = "main" ]; then +echo "You are on the main branch. Committing to the main branch is not allowed." +exit 1 +fi