From a90c411ff17cda826b946ef9c8319e5fcfb590ec Mon Sep 17 00:00:00 2001 From: Nicolas Date: Fri, 1 Aug 2025 12:08:18 +0200 Subject: [PATCH] Update deploy method and docs api path --- .flake8 | 7 ++++--- .github/workflows/docs.yml | 31 ++++++++++++++++++++++-------- .github/workflows/publish.yml | 4 ++++ .gitignore | 2 +- docs/source/generate_class_list.py | 8 ++++---- docs/source/index.md | 3 ++- docs/source/repo.md | 3 +++ 7 files changed, 41 insertions(+), 17 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 0c1c105..5b10353 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 @@ -30,12 +30,27 @@ jobs: cp LICENSE docs/source/LICENSE.md cd docs sphinx-apidoc -o source/ ../src/ -M --no-toc - rm source/*.rst + rm ./source/*.rst make html - touch build/html/.nojekyll - - - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4 + touch ./build/html/.nojekyll + 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 17c7ff0..f91c170 100644 --- a/.gitignore +++ b/.gitignore @@ -70,7 +70,7 @@ instance/ # Sphinx documentation docs/build/ -docs/source/_autogenerated/ +docs/source/api/ # PyBuilder .pybuilder/ diff --git a/docs/source/generate_class_list.py b/docs/source/generate_class_list.py index d7272de..c2b4999 100644 --- a/docs/source/generate_class_list.py +++ b/docs/source/generate_class_list.py @@ -22,7 +22,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') @@ -50,7 +50,7 @@ def write_functions(f: TextIOWrapper, patterns: list[str], module_name: str, tit for func in functions: if not func.startswith('_'): - with open(f'docs/source/_autogenerated/{func}.md', 'w') as f2: + with open(f'docs/source/api/{func}.md', 'w') as f2: f2.write(f'# {module_name}.{func}\n') f2.write('```{eval-rst}\n') f2.write(f'.. autofunction:: {module_name}.{func}\n') @@ -69,9 +69,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 functions\n\n') write_classes(f, ['DocumentWriter'], 'pyladoc', title='DocumentWriter Class') write_functions(f, ['*'], 'pyladoc', title='Functions') 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..7300cc6 --- /dev/null +++ b/docs/source/repo.md @@ -0,0 +1,3 @@ +# Code repository + +Code repository is on GitHub: [github.com/Nonannet/pyladoc](https://github.com/Nonannet/pyladoc). \ No newline at end of file