Skip to content

Commit a7461cb

Browse files
authored
doc: basic gallery of examples (#226)
2 parents 3af0981 + 64909dc commit a7461cb

File tree

14 files changed

+637
-295
lines changed

14 files changed

+637
-295
lines changed

.github/workflows/ci_cd_pr.yml

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -65,61 +65,92 @@ jobs:
6565

6666
doc-build:
6767
name: "Doc build"
68-
runs-on: ubuntu-latest
68+
runs-on: [self-hosted, pystk]
6969
needs: doc-style
7070
timeout-minutes: 30
7171
steps:
7272

73+
- name: "Checkout the project"
74+
uses: actions/checkout@v4
75+
76+
- name: "Generate the name of the Docker image and the container"
77+
run: |
78+
python_image_name=${{ env.STK_DOCKER_IMAGE }}-python${{ env.MAIN_PYTHON_VERSION }}
79+
container_name=stk-python${{ env.MAIN_PYTHON_VERSION }}
80+
echo "STK_PYTHON_IMAGE=$python_image_name" >> $GITHUB_ENV
81+
echo "STK_CONTAINER=$container_name" >> $GITHUB_ENV
82+
83+
- name: "Start the container from the desired image"
84+
run: |
85+
docker run \
86+
--detach -it \
87+
--network="host" \
88+
--name ${{ env.STK_CONTAINER }} \
89+
--env ANSYSLMD_LICENSE_FILE=${{ env.LICENSE_SERVER_PORT }}@${{ secrets.LICENSE_SERVER }} \
90+
--volume ${PWD}:/home/stk/pystk \
91+
${{ env.STK_PYTHON_IMAGE }}
92+
93+
- name: "Install Pandoc inside the container"
94+
run: |
95+
docker exec \
96+
--user root \
97+
--workdir ${{ env.PYSTK_DIR }} \
98+
${{ env.STK_CONTAINER }} /bin/bash -c \
99+
"yum install -y epel-release && yum install -y pandoc --enablerepo=epel"
100+
101+
- name: "Install Tox"
102+
run: |
103+
docker exec \
104+
--workdir ${{ env.PYSTK_DIR }} \
105+
${{ env.STK_CONTAINER }} /bin/bash -c \
106+
"python -m pip install tox && rm -rf .tox"
107+
73108
# Render the documentation including or excluding different sections
74109
# according to the labels of the pull-request.
75110

76111
- name: "Build docs including the 'Examples' section"
77112
id: build-doc-with-examples
78-
uses: ansys/actions/doc-build@v5
79113
if: |
80114
contains(github.event.pull_request.labels.*.name, 'docs:examples') &&
81115
!contains(github.event.pull_request.labels.*.name, 'docs:api')
82-
with:
83-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
84-
env:
85-
BUILD_API: false
86-
BUILD_EXAMPLES: true
116+
run: |
117+
docker exec \
118+
--workdir ${{ env.PYSTK_DIR }} \
119+
${{ env.STK_CONTAINER }} /bin/bash -c \
120+
"export BUILD_API=false BUILD_EXAMPLES=true && tox -e doc"
87121
88122
- name: "Build docs including the 'API' section"
89123
id: build-doc-with-api
90-
uses: ansys/actions/doc-build@v5
91124
if: |
92125
contains(github.event.pull_request.labels.*.name, 'docs:api') &&
93126
!contains(github.event.pull_request.labels.*.name, 'docs:examples')
94-
with:
95-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
96-
env:
97-
BUILD_API: true
98-
BUILD_EXAMPLES: false
127+
run: |
128+
docker exec \
129+
--workdir ${{ env.PYSTK_DIR }} \
130+
${{ env.STK_CONTAINER }} /bin/bash -c \
131+
"export BUILD_API=true BUILD_EXAMPLES=false && tox -e doc"
99132
100133
- name: "Build docs excluding 'API' and 'Examples' sections"
101134
id: build-doc-minimum
102-
uses: ansys/actions/doc-build@v5
103135
if: |
104136
!contains(github.event.pull_request.labels.*.name, 'docs:examples') &&
105137
!contains(github.event.pull_request.labels.*.name, 'docs:api')
106-
with:
107-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
108-
env:
109-
BUILD_API: false
110-
BUILD_EXAMPLES: false
138+
run: |
139+
docker exec \
140+
--workdir ${{ env.PYSTK_DIR }} \
141+
${{ env.STK_CONTAINER }} /bin/bash -c \
142+
"export BUILD_API=false BUILD_EXAMPLES=false && tox -e doc"
111143
112144
- name: "Build docs including 'API' and 'Examples' sections"
113145
id: build-doc-full
114-
uses: ansys/actions/doc-build@v5
115146
if: |
116147
contains(github.event.pull_request.labels.*.name, 'docs:examples') &&
117148
contains(github.event.pull_request.labels.*.name, 'docs:api')
118-
with:
119-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
120-
env:
121-
BUILD_API: true
122-
BUILD_EXAMPLES: true
149+
run: |
150+
docker exec \
151+
--workdir ${{ env.PYSTK_DIR }} \
152+
${{ env.STK_CONTAINER }} /bin/bash -c \
153+
"export BUILD_API=true BUILD_EXAMPLES=true && tox -e doc"
123154
124155
# If required, combine partially rendered documentation with the nightly
125156
# build artifacts. Upload the generated documentation as an artifact in
@@ -134,15 +165,15 @@ jobs:
134165

135166
- name: "Include 'API' section from nightly build docs"
136167
if: |
137-
steps.build-doc-with-api.outcome == 'success' ||
168+
steps.build-doc-with-examples.outcome == 'success' ||
138169
steps.build-doc-minimum.outcome == 'success'
139170
run: |
140171
cp -r gh-pages/version/dev/api doc/_build/html/api
141172
cp gh-pages/version/dev/index.html doc/_build/html/index.html
142173
143174
- name: "Include 'Examples' section from nightly build docs"
144175
if: |
145-
steps.build-doc-with-examples.outcome == 'success' ||
176+
steps.build-doc-with-api.outcome == 'success' ||
146177
steps.build-doc-minimum.outcome == 'success'
147178
run: |
148179
cp gh-pages/version/dev/examples.html doc/_build/html/examples.html
@@ -155,6 +186,13 @@ jobs:
155186
path: doc/_build/html
156187
name: full-documentation-html
157188

189+
- name: "Stop the container"
190+
if: always()
191+
run: |
192+
docker stop ${{ env.STK_CONTAINER }}
193+
docker logs ${{ env.STK_CONTAINER }}
194+
docker rm ${{ env.STK_CONTAINER }}
195+
158196
tests:
159197
name: "Tests Python ${{ matrix.python }}"
160198
runs-on: [self-hosted, pystk]

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,10 @@ distributions/
164164

165165
# Backup files
166166
*.bak
167+
168+
# Examples are kept at the root of the repository but copied at documentation
169+
# build time inside the documentation source directory
170+
doc/source/examples/
171+
172+
# Ignore trash generated by Jupyter Notebook
173+
.Trash-1000/

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repos:
1515
# As per this issue https://github.com/pre-commit/pre-commit/issues/2936,
1616
# it looks like the `--all-files` only listens for the `exclude` option in a
1717
# pre-commit hook, ignoring `pyproject.toml` excludes.
18-
exclude: ^(src/ansys/stk/core/internal/|tests/|doc/_build|doc/styles/)
18+
exclude: ^(src/ansys/stk/core/internal/|tests/|doc/_build|doc/styles/|doc/source/_static)
1919
args: [--ignore-words=./doc/styles/Vocab/ANSYS/accept.txt]
2020
# TODO: pre-commit seems to ignore the configuration declared for codespell
2121
# in the `pyproject.toml` file. For more details, see `[tool.codespell]` in
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import "../../ansys-sphinx-theme.css";
2+
3+
/* Do not show number cells */
4+
.nbinput .prompt,
5+
.nboutput .prompt {
6+
display: none;
7+
}
8+
9+
/* Center output notebook images */
10+
.nboutput img {
11+
display: block !important;
12+
margin: 0 auto !important;
13+
}
14+
15+
/* Remove the 'snapshot' label in the JupyterWidget snapshots */
16+
.nboutput img + * {
17+
display: none;
18+
}
19+
20+
/* Ensure that text in the code blocks has the desired font-size */
21+
.highlight { font-size: 1rem; background: #f0f0f0 !important; }
61.3 KB
Loading

0 commit comments

Comments
 (0)