diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..24a0673b --- /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 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/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 ------------------------------------------------------------------------ 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 98% rename from doc/source/conf.py rename to doc/manual/source/conf.py index 766b082b..235d9f37 100644 --- a/doc/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/source/index.rst b/doc/manual/source/index.rst similarity index 98% rename from doc/source/index.rst rename to doc/manual/source/index.rst index 51f252e1..4a484320 100644 --- a/doc/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/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/manual/source/release.rst b/doc/manual/source/release.rst new file mode 100644 index 00000000..c028e34c --- /dev/null +++ b/doc/manual/source/release.rst @@ -0,0 +1,4 @@ +.. index:: release notes + +.. include:: /../../../CHANGELOG.rst + diff --git a/doc/source/release.rst b/doc/source/release.rst deleted file mode 100644 index ca8fa0b6..00000000 --- a/doc/source/release.rst +++ /dev/null @@ -1,4 +0,0 @@ -.. index:: release notes - -.. include:: /../../CHANGELOG.rst - 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