From 49f654993ebae23f200efb8e8eb6ec31bc38e1a6 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 1 Aug 2025 11:04:36 +0200 Subject: [PATCH] Change docs path and update publishing method --- .flake8 | 7 ++++--- .github/workflows/docs.yml | 26 +++++++++++++++++++++----- .github/workflows/publish.yml | 4 ++++ .gitignore | 2 +- docs/source/generate_class_list.py | 6 +++--- docs/source/index.md | 3 ++- docs/source/repo.md | 3 +++ 7 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 docs/source/repo.md diff --git a/.flake8 b/.flake8 index eb1eb4f..c3382da 100644 --- a/.flake8 +++ b/.flake8 @@ -12,9 +12,10 @@ exclude = __pycache__, build, dist, - .conda - .venv - venv + .conda, + .venv, + venv, + docs/source/api # Enable specific plugins or options # Example: Enabling flake8-docstrings diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 82b71ab..1d72250 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,7 +9,7 @@ permissions: contents: write jobs: - build-and-deploy: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -29,8 +29,24 @@ jobs: rm ./source/*.rst make html touch ./build/html/.nojekyll - - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4 + mkdir -p ./build/html/_autogenerated + cp ./build/html/api/* ./build/html/_autogenerated/ + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 with: - branch: gh-pages - folder: docs/build/html + path: docs/build/html + + deploy: + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae82350..65af788 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,6 +10,10 @@ jobs: name: Build and publish runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/${{ github.event.repository.name }}/ + steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index 68d7d8d..8490699 100644 --- a/.gitignore +++ b/.gitignore @@ -70,7 +70,7 @@ instance/ # Sphinx documentation docs/_build/ -docs/source/_autogenerated/ +docs/source/api/ # Autogenerated documentation docs/source/modules.md diff --git a/docs/source/generate_class_list.py b/docs/source/generate_class_list.py index 9a880ba..b557349 100644 --- a/docs/source/generate_class_list.py +++ b/docs/source/generate_class_list.py @@ -24,7 +24,7 @@ def write_classes(f: TextIOWrapper, patterns: list[str], module_name: str, title write_dochtree(f, title, classes) for cls in classes: - with open(f'docs/source/_autogenerated/{cls}.md', 'w') as f2: + with open(f'docs/source/api/{cls}.md', 'w') as f2: f2.write(f'# {module_name}.{cls}\n') f2.write('```{eval-rst}\n') f2.write(f'.. autoclass:: {module_name}.{cls}\n') @@ -52,9 +52,9 @@ def write_dochtree(f: TextIOWrapper, title: str, items: list[str]): if __name__ == "__main__": # Ensure the output directory exists - os.makedirs('docs/source/_autogenerated', exist_ok=True) + os.makedirs('docs/source/api', exist_ok=True) - with open('docs/source/_autogenerated/index.md', 'w') as f: + with open('docs/source/api/index.md', 'w') as f: f.write('# Classes and Modules\n\n') write_classes(f, ['BK*', 'WAGO_750_352'], 'pyhoff.devices', title='Bus coupler', diff --git a/docs/source/index.md b/docs/source/index.md index 20d99c4..b65f4c4 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -1,7 +1,8 @@ ```{toctree} :maxdepth: 1 :hidden: -_autogenerated/index +api/index +repo ``` ```{include} ../../README.md diff --git a/docs/source/repo.md b/docs/source/repo.md new file mode 100644 index 0000000..ffda717 --- /dev/null +++ b/docs/source/repo.md @@ -0,0 +1,3 @@ +# Code repository + +Code repository is on GitHub: [github.com/Nonannet/pyhoff](https://github.com/Nonannet/pyhoff). \ No newline at end of file