diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index ce9500c8..15f5c23d 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -14,6 +14,7 @@ on: env: MAIN_PYTHON_VERSION: '3.10' LIBRARY_NAME: 'ansys-openapi-common' + DOCUMENTATION_CNAME: 'ansys.github.io/openapi-common/' jobs: code-style: @@ -35,54 +36,14 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} doc-build: - name: Build Documentation + name: Documentation build runs-on: ubuntu-latest - needs: doc-style - steps: - - name: "Checkout the repository" - uses: actions/checkout@v4 - - - name: "Set up Python" - uses: actions/setup-python@v5 + - name: "Run Ansys documentation building action" + uses: ansys/actions/doc-build@v5 with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Install system dependencies" - run: | - sudo apt-get update && sudo apt-get install pandoc libkrb5-dev - - - name: "Install Python dependencies" - run: | - python -m pip install --upgrade pip tox - python -m pip install poetry~=1.7.0 - - - name: Install library - run: | - poetry install --with docs --extras "oidc linux-kerberos" - - - name: Build HTML - run: make -C doc html SPHINXOPTS="-W" - - - name: Build PDF Documentation - run: | - sudo apt update - sudo apt-get install -y texlive-latex-extra latexmk texlive-xetex fonts-freefont-otf xindy - make -C doc latexpdf - - - name: Upload HTML Documentation - uses: actions/upload-artifact@v4 - with: - name: documentation-html - path: doc/build/html - retention-days: 7 - - - name: Upload PDF Documentation - uses: actions/upload-artifact@v4 - with: - name: documentation-pdf - path: doc/build/latex/*.pdf - retention-days: 7 + check-links: false + sphinxopts: "-j 1 -W --keep-going" smoke-tests: name: "Build wheelhouse for latest Python versions" @@ -93,12 +54,6 @@ jobs: os: [ubuntu-latest, windows-latest] python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - - name: Install kerberos headers - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt install libkrb5-dev - - uses: ansys/actions/build-wheelhouse@v6 with: library-name: ${{ env.LIBRARY_NAME }} @@ -164,16 +119,23 @@ jobs: runs-on: ubuntu-latest needs: [ doc-build, tests ] steps: - - name: Install kerberos headers - run: | - sudo apt-get update - sudo apt install libkrb5-dev - - uses: ansys/actions/build-library@v6 with: library-name: ${{ env.LIBRARY_NAME }} python-version: ${{ env.MAIN_PYTHON_VERSION }} + doc-deploy-dev: + name: "Deploy development documentation" + runs-on: ubuntu-latest + needs: [ build-library ] + if: github.event_name == 'push' && !contains(github.ref, 'refs/tags') + steps: + - uses: ansys/actions/doc-deploy-dev@v6 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} + doc-artifact-name: documentation-html + update-changelog: name: "Update CHANGELOG for new tag" if: github.event_name == 'push' && contains(github.ref, 'refs/tags') @@ -210,25 +172,7 @@ jobs: needs: release if: github.event_name == 'push' && contains(github.ref, 'refs/tags') steps: - - uses: actions/checkout@v4 - - - name: Get Bot Application Token - id: get_workflow_token - uses: peter-murray/workflow-application-token-action@v3 - with: - application_id: ${{ secrets.BOT_APPLICATION_ID }} - application_private_key: ${{ secrets.BOT_APPLICATION_PRIVATE_KEY }} - - - uses: actions/download-artifact@v4 + - uses: ansys/actions/doc-deploy-stable@v6 with: - name: documentation-html - path: ~/html - - - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4.6.0 - with: - repository-name: pyansys/openapi-common-docs - token: ${{ steps.get_workflow_token.outputs.token }} - BRANCH: gh-pages - FOLDER: ~/html - CLEAN: true + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/doc/Makefile b/doc/Makefile index e9ada5fa..b9920308 100755 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,10 +2,10 @@ # # You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = poetry run sphinx-build +SPHINXOPTS = -j auto +SPHINXBUILD = sphinx-build SOURCEDIR = source -BUILDDIR = build +BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @@ -19,6 +19,14 @@ help: @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -# customized clean due to examples gallery +# Customized clean due to examples gallery clean: - rm -rf build + rm -rf $(BUILDDIR)/* + rm -rf $(SOURCEDIR)/examples + find . -type d -name "_autosummary" -exec rm -rf {} + + +# Customized pdf for svg format images +pdf: + @$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true + (test -f $(BUILDDIR)/latex/*.pdf && echo pdf exists) || exit 1 \ No newline at end of file diff --git a/doc/changelog.d/555.dependencies.md b/doc/changelog.d/555.dependencies.md new file mode 100644 index 00000000..a755a1bb --- /dev/null +++ b/doc/changelog.d/555.dependencies.md @@ -0,0 +1 @@ +Use ansys standard actions \ No newline at end of file diff --git a/doc/make.bat b/doc/make.bat index 6247f7e2..1bd5d668 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -8,9 +8,11 @@ if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set SOURCEDIR=source -set BUILDDIR=build +set BUILDDIR=_build if "%1" == "" goto help +if "%1" == "clean" goto clean +if "%1" == "pdf" goto pdf %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( @@ -28,8 +30,22 @@ if errorlevel 9009 ( %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% goto end +:clean +rmdir /s /q %BUILDDIR% > /NUL 2>&1 +for /d /r %SOURCEDIR% %%d in (_autosummary) do @if exist "%%d" rmdir /s /q "%%d" +goto end + :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +:pdf + %SPHINXBUILD% -M latex %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + cd "%BUILDDIR%\latex" + for %%f in (*.tex) do ( + pdflatex "%%f" --interaction=nonstopmode) + if NOT EXIST ansys-openapi-common.pdf ( + Echo "no pdf generated!" + exit /b 1) + Echo "pdf generated!" :end -popd +popd \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 27c93320..f66af2cd 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -2,7 +2,7 @@ import os import sys -from ansys_sphinx_theme import pyansys_logo_black +from ansys_sphinx_theme import get_version_match, pyansys_logo_black from ansys.openapi import common @@ -114,6 +114,8 @@ # -- Options for HTML output ------------------------------------------------- +cname = os.getenv("DOCUMENTATION_CNAME", "ansys.github.io/openapi-common/") + html_theme = "ansys_sphinx_theme" html_logo = pyansys_logo_black html_theme_options = { @@ -124,77 +126,14 @@ ("PyAnsys Documentation", "https://docs.pyansys.com"), ("Shared Components", "https://shared.docs.pyansys.com"), ], + "switcher": { + "json_url": f"https://{cname}/versions.json", + "version_match": get_version_match(common.__version__), + }, + "check_switcher": False, } # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = "openapicommondoc" - - -# -- Options for LaTeX output ------------------------------------------------ -latex_elements = {} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "ansys_openapi_common.tex", - "ansys.openapi.common Documentation", - author, - "manual", - ), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "ansys.openapi.common", - "ansys.openapi.common Documentation", - [author], - 1, - ) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "ansys.openapi.common", - "ansys.openapi.common Documentation", - author, - "ansys.openapi.common", - "Common authentication components for pyAnsys REST clients", - "Engineering Software", - ), -] -latex_engine = "xelatex" - -# -- Options for Epub output ------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ["search.html"] diff --git a/poetry.lock b/poetry.lock index a281ac23..c84b2fdb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1749,4 +1749,4 @@ oidc = ["keyring", "requests_auth"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "5873031e53ed990c3449b40089b66031966dfee83c0bac39525ed61432c967ba" +content-hash = "86685655396271a7871b9212dc3f80dc996b973ea8c0a061a03e38c2691bdf4e" diff --git a/pyproject.toml b/pyproject.toml index 38b59b1e..6cbad85b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,17 +62,23 @@ pydantic = { version = "*" } requests-mock = { version = "*" } pytest-mock = { version = "*" } covertable = { version = "*" } -asgi_gssapi = { version = "*", markers = "sys_platform == 'linux'" } + mypy = "^1.8.0" types-requests = { version = "*" } types-python-dateutil = { version = "*" } requests_auth = { version = "*" } keyring = { version = "*" } -[tool.poetry.group.docs] +[tool.poetry.group.dev-linux] +optional = true + +[tool.poetry.group.dev-linux.dependencies] +asgi_gssapi = { version = "*", markers = "sys_platform == 'linux'" } + +[tool.poetry.group.doc] optional = true -[tool.poetry.group.docs.dependencies] +[tool.poetry.group.doc.dependencies] # Doc packages ansys-sphinx-theme = { version = "0.15.2" } numpydoc = { version = "1.7.0" } @@ -108,7 +114,7 @@ python = [testenv] whitelist_externals = poetry commands_pre = - poetry install --no-root --extras "oidc linux-kerberos" + poetry install --no-root --with dev-linux --extras "oidc linux-kerberos" extras = oidc linux-kerberos