diff --git a/.github/workflows/sphinx-build.yml b/.github/workflows/sphinx-build.yml new file mode 100644 index 000000000..c09056f9a --- /dev/null +++ b/.github/workflows/sphinx-build.yml @@ -0,0 +1,35 @@ +--- +name: Sphinx build + +on: + push: + branches: + - master + +jobs: + sphinx-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.13' + cache: 'pip' # caching pip dependencies + - run: pip install .[release] + + - name: Build HTML + run: ./action/build_docs.sh + + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: html-docs + path: ./sphinx_output/ + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: github.ref == 'refs/heads/master' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./sphinx_output +... diff --git a/.gitignore b/.gitignore index c452eb6d3..e8657302f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ __pycache__/ *.pyc /.vscode/ /build +/sphinx_output /venv diff --git a/CHANGES.rst b/CHANGES.rst index 8f7bbb1b2..d22622939 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,7 @@ These features will be included in the next release: Added ----- +- Add readthedocs site - New exit codes 2 for file not found, 3 for invalid command line arguments, 4 for missing dependencies and 123 for unknown failures. - Display exit code in parentheses after error message. diff --git a/action/build_docs.sh b/action/build_docs.sh new file mode 100755 index 000000000..3088c47f8 --- /dev/null +++ b/action/build_docs.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +THEME="sphinx_rtd_theme" +OUTPUT_DIR="../sphinx_output" +REPO_DIR=$PWD + +mkdir -p ../sphinx_project/source +pushd ../sphinx_project + +pip install $THEME + +cat < source/conf.py +project = "README" +html_theme = "$THEME" +EOL + +cp "../README.rst" ../sphinx_project/source/index.rst +sphinx-build -b html source $OUTPUT_DIR + +popd +mv ../sphinx_project/$OUTPUT_DIR . +rm -rf ../sphinx_project diff --git a/setup.cfg b/setup.cfg index 4739438df..0cf2c8e44 100644 --- a/setup.cfg +++ b/setup.cfg @@ -83,6 +83,8 @@ test = wheel>=0.21.0 release = darkgray-dev-tools~=0.1.1 + sphinx + sphinx-rtd-theme [flake8] # Line length according to Black rules