Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to pyansys/actions and include get_version_match function #153

Merged
merged 15 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 39 additions & 69 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,95 +7,65 @@ on:
- "*"
branches:
- main
env:
MAIN_PYTHON_VERSION : '3.10'
pyansys-actions: 'pyansys/actions/.github/workflows'
cname: 'sphinxdocs.ansys.com'
Revathyvenugopal162 marked this conversation as resolved.
Show resolved Hide resolved

jobs:

style:
code-style:
name: Code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip tox
- name: Test with tox
run: tox -e style
- name: "Run PyAnsys code style checks"
uses: pyansys/actions/code-style@main

docs-style:
name: Documentation Style Check
doc-style:
name: Doc style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Running Vale
uses: errata-ai/vale-action@reviewdog
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: "Run Ansys documentation style checks"
uses: pyansys/actions/doc-style@main
with:
files: doc
reporter: github-pr-check
level: error
filter_mode: nofilter
fail_on_error: true
vale_flags: "--config=doc/.vale.ini"
token: ${{ secrets.GITHUB_TOKEN }}

docs:
name: Documentation
doc-build:
name: Doc building
runs-on: ubuntu-latest
needs: docs-style
needs: doc-style
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: "Run Ansys documentation building action"
uses: pyansys/actions/doc-build@main

- name: Install dependencies
run: |
sudo apt update
sudo apt-get install -y build-essential zip pandoc texlive-latex-extra latexmk texlive-pstricks
python -m pip install --upgrade pip tox
python -m pip install -r requirements/requirements_doc.txt
python -m pip install --editable .
- name: Build HTML documentation
run: tox -e doc

- name: Upload HTML Documentation
uses: actions/[email protected]
with:
name: HTML-Documentation
path: .tox/doc_out/
retention-days: 7

- name: Build PDF Documentation
run: |
make -C doc pdf
- name: Upload PDF Documentation
uses: actions/[email protected]
doc-deploy-development:
name: Doc dev version deploy
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: doc-build
steps:
- name: "Deploy developers documentation"
uses: pyansys/actions/doc-deploy-dev@main
with:
name: PDF-Documentation
path: doc/build/latex/ansys_sphinx_theme.pdf
retention-days: 7
cname: ${{ env.cname }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to gh-pages
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
uses: JamesIves/[email protected]
doc-deploy-stable:
name: Doc stable version deploy
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: doc-deploy-development
steps:
- name: "Deploy stable documentation"
uses: pyansys/actions/doc-deploy-stable@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: .tox/doc_out/
CLEAN: true
SINGLE_COMMIT: true
cname: ${{ env.cname }}
token: ${{ secrets.GITHUB_TOKEN }}

build:
name: Build
runs-on: ubuntu-latest
needs: style
needs: [code-style]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand All @@ -119,7 +89,7 @@ jobs:
release:
name: Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [style, docs-style, docs, build]
needs: build
runs-on: ubuntu-latest

steps:
Expand Down
5 changes: 5 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ansys_logo_white,
ansys_logo_white_cropped,
generate_404,
get_version_match,
latex,
watermark,
)
Expand All @@ -38,6 +39,10 @@
"github_url": "https://github.com/ansys/ansys-sphinx-theme",
"use_edit_page_button": True,
"contact_mail": "[email protected]",
"switcher": {
"json_url": "https://raw.githubusercontent.com/ansys/ansys-sphinx-theme/gh-pages/release/versions.json", # noqa: E501
Revathyvenugopal162 marked this conversation as resolved.
Show resolved Hide resolved
"version_match": get_version_match(__version__),
},
"additional_breadcrumbs": [
("Ansys Internal Developer Portal", "https://dev.docs.ansys.com"),
],
Expand Down
26 changes: 25 additions & 1 deletion src/ansys_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
page_404 = os.path.join(_this_path, "static", "404.rst")

html_logo = pyansys_logo_black

CSS_FILENAME = "ansys_sphinx_theme.css"


Expand All @@ -31,6 +30,30 @@ def get_html_theme_path():
return Path(__file__).parents[0].absolute()


def get_version_match(semver):
jorgepiloto marked this conversation as resolved.
Show resolved Hide resolved
"""Evaluate the version match for the multi-documentation."""
if semver.endswith("dev0"):
return "dev"
major, minor, _ = semver.split(".")
return ".".join([major, minor])


def prepare_html_configration(app, pagename, templatename, theme_options, doctree):
Revathyvenugopal162 marked this conversation as resolved.
Show resolved Hide resolved
"""Prepare some configuration values for the HTML build.

For some reason (in most of repo) switcher might not be there, so we manually adding in that
case.
"""
theme_switcher = theme_options.get("switcher")
if not theme_switcher or theme_switcher is None:
theme_switcher = {"version_match": "dev-stable"}

if not isinstance(theme_switcher, dict):
raise ValueError(f"Incorrect switcher config type: {type(theme_switcher)}")

theme_options["theme_switcher"] = theme_switcher


def setup(app):
"""Connect to the sphinx theme app."""
theme_path = get_html_theme_path()
Expand All @@ -43,6 +66,7 @@ def setup(app):
# add templates for autosummary
path_templates = os.path.join(_this_path, "_templates")
app.config.templates_path.append(path_templates)
app.connect("html-page-context", prepare_html_configration)

return {
"version": __version__,
Expand Down
5 changes: 5 additions & 0 deletions src/ansys_sphinx_theme/_templates/version-switcher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{%- extends "pydata_sphinx_theme/components/version-switcher.html" -%}

{{ super() }}


1 change: 1 addition & 0 deletions src/ansys_sphinx_theme/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ show_icons = True
hidden_icons =
additional_breadcrumbs =
switcher =
navbar_end = version-switcher.html, theme-switcher.html, navbar-icon-links.html