Skip to content

Commit ba81eb7

Browse files
Merge pull request #67 from easyscience/patch
Enhances Notebook Workflows, Plot Rendering, and Documentation Updates
2 parents d14b1bf + e4d7c91 commit ba81eb7

File tree

10 files changed

+1478
-786
lines changed

10 files changed

+1478
-786
lines changed

.github/workflows/build-docs.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,22 @@ jobs:
3333
runs-on: ${{ matrix.os }}
3434

3535
steps:
36-
# Without this step, GITHUB_REPOSITORY is not accessible from mkdocs.yml
37-
- name: Get GitHub repository
38-
run: echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" >> $GITHUB_ENV
36+
- name: Check-out repository
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0 # full history + tags. needed to get the latest release version
3940

4041
# Save the latest release version of easyscience/diffraction-lib to RELEASE_VERSION
4142
# RELEASE_VERSION is used in the mkdocs.yml file to set release_version.
4243
# The release_version is then needed to display the latest release version in the index.md file
43-
- name: Get the latest release version of easydiffraction library
44+
- name: Set RELEASE_VERSION env variable (latest easydiffraction release)
4445
run: |
45-
git clone --depth 1 https://github.com/easyscience/${{ github.event.repository.name }} .
46-
git fetch --tags
47-
echo "RELEASE_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
46+
git fetch --tags --force
47+
echo "RELEASE_VERSION=$(git describe --tags --abbrev=0)" >> "$GITHUB_ENV"
48+
49+
# Without this step, GITHUB_REPOSITORY is not accessible from mkdocs.yml
50+
- name: Set GITHUB_REPOSITORY env variable
51+
run: echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" >> "$GITHUB_ENV"
4852

4953
# Activate dark mode to create documentation with Plotly charts in dark mode
5054
# Need a better solution to automatically switch the chart colour theme based on the mkdocs material switcher
@@ -57,9 +61,6 @@ jobs:
5761
# dark-mode on
5862
# dark-mode status
5963

60-
- name: Check-out repository
61-
uses: actions/checkout@v4
62-
6364
- name: Set up Python ${{ matrix.python-version }}
6465
uses: actions/setup-python@v5
6566
with:
@@ -113,7 +114,7 @@ jobs:
113114
cp -R ${{ env.NOTEBOOKS_DIR }}/data docs/${{ env.NOTEBOOKS_DIR }}/
114115
jupytext ${{ env.NOTEBOOKS_DIR }}/*.py --from py:percent --to ipynb
115116
nbstripout ${{ env.NOTEBOOKS_DIR }}/*.ipynb
116-
python tools/nb_uncomment_pip.py ${{ env.NOTEBOOKS_DIR }}/
117+
python tools/prepare_notebooks.py ${{ env.NOTEBOOKS_DIR }}/
117118
mv ${{ env.NOTEBOOKS_DIR }}/*.ipynb docs/${{ env.NOTEBOOKS_DIR }}/
118119
119120
# The following step is needed to avoid the following message during the build:

.github/workflows/test-tutorials.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
run: |
152152
jupytext ${{ env.NOTEBOOKS_DIR }}/*.py --from py:percent --to ipynb
153153
nbstripout ${{ env.NOTEBOOKS_DIR }}/*.ipynb
154-
python tools/nb_uncomment_pip.py ${{ env.NOTEBOOKS_DIR }}/
154+
python tools/prepare_notebooks.py ${{ env.NOTEBOOKS_DIR }}/
155155
156156
- name: Run tutorials as Jupyter Notebooks (using src/ as the source dir)
157157
shell: bash

DEVELOPMENT.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,31 @@ This is an example of a workflow that describes the development process.
106106
```
107107
- Add extra files to build documentation (from `../assets-docs/` and
108108
`../assets-branding/` directories)
109+
109110
```bash
110111
cp -R ../assets-docs/docs/assets/ docs/assets/
111112
cp -R ../assets-docs/includes/ includes/
112113
cp -R ../assets-docs/overrides/ overrides/
114+
113115
mkdir -p docs/assets/images/
114-
cp ../assets-branding/EasyDiffraction/logos/ed-logo_dark.svg docs/assets/images/
115-
cp ../assets-branding/EasyDiffraction/logos/ed-logo_light.svg docs/assets/images/
116-
cp ../assets-branding/EasyDiffraction/logos/edl-logo_dark.svg docs/assets/images/logo_dark.svg
117-
cp ../assets-branding/EasyDiffraction/logos/edl-logo_light.svg docs/assets/images/logo_light.svg
118-
cp ../assets-branding/EasyDiffraction/icons/ed-icon_256x256.png docs/assets/images/favicon.png
116+
cp ../assets-branding/easydiffraction/hero/dark.png docs/assets/images/hero_dark.png
117+
cp ../assets-branding/easydiffraction/hero/light.png docs/assets/images/hero_light.png
118+
cp ../assets-branding/easydiffraction/logos/dark.svg docs/assets/images/logo_dark.svg
119+
cp ../assets-branding/easydiffraction/logos/light.svg docs/assets/images/logo_light.svg
120+
cp ../assets-branding/easydiffraction/icons/color.png docs/assets/images/favicon.png
121+
119122
mkdir -p overrides/.icons/
120-
cp ../assets-branding/EasyDiffraction/icons/ed-icon_bw.svg overrides/.icons/easydiffraction.svg
121-
cp ../assets-branding/EasyScienceOrg/icons/eso-icon_bw.svg overrides/.icons/easyscience.svg
122-
cp -R examples/ docs/examples/
123-
cat ../assets-docs/mkdocs.yml docs/mkdocs.yml > mkdocs.yml
123+
cp ../assets-branding/easydiffraction/icons/bw.svg overrides/.icons/easydiffraction.svg
124+
cp ../assets-branding/easyscience-org/icons/eso-icon_bw.svg overrides/.icons/easyscience.svg
125+
126+
jupytext tutorials/*.py --from py:percent --to ipynb
127+
nbstripout tutorials/*.ipynb
128+
cp tutorials/*.ipynb docs/tutorials/
129+
cp -R tutorials/data docs/tutorials/
130+
131+
python tools/create_mkdocs-yml.py
124132
```
133+
125134
- Build documentation with MkDocs - static site generator
126135
```bash
127136
export JUPYTER_PLATFORM_DIRS=1

docs/introduction/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Zenodo, each with a version-specific Digital Object Identifier (DOI).
4949
Citation details in various styles (e.g., APA, MLA) and formats (e.g., BibTeX,
5050
JSON)
5151
are available on the
52-
[Zenodo archive page](https://doi.org/10.5281/zenodo.16806522).
52+
[Zenodo archive page](https://doi.org/10.5281/zenodo.16806521).
5353

5454
## Contributing
5555

src/easydiffraction/plotting/plotters/plotter_plotly.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
display = None
1313
HTML = None
1414

15-
from easydiffraction.utils.utils import is_pycharm
15+
from easydiffraction.utils.utils import is_github_ci
1616

1717
from .plotter_base import SERIES_CONFIG
1818
from .plotter_base import PlotterBase
@@ -106,14 +106,13 @@ def plot(
106106

107107
# Show the figure
108108

109-
# The standard `fig.show()` method method triggers the following
110-
# warning during the DMSC Summer School 2025 book build process:
111-
# WARNING: skipping unknown output mime type:
112-
# application/vnd.plotly.v1+json [mystnb.unknown_mime_type]
113-
# So, instead, we will use `pio.to_html()` to convert the figure
114-
# to HTML and keep `fig.show()` in PyCharm only.
115-
116-
if is_pycharm() or display is None or HTML is None:
109+
# In GitHub CI builds (e.g., during Jupyter Book generation), avoid
110+
#
111+
# calling `fig.show()`
112+
# because it can emit `application/vnd.plotly.v1+json` outputs that some toolchains warn about.
113+
# Instead, convert the figure to HTML and display it directly.
114+
# Use a regular Figure and show it
115+
if not is_github_ci() or display is None or HTML is None:
117116
fig.show(config=config)
118117
else:
119118
html_fig = pio.to_html(

src/easydiffraction/utils/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ def is_pycharm() -> bool:
101101
return os.environ.get('PYCHARM_HOSTED') == '1'
102102

103103

104+
def is_github_ci() -> bool:
105+
"""
106+
Determines if the current process is running in GitHub Actions CI.
107+
108+
Returns:
109+
bool: True if the environment variable ``GITHUB_ACTIONS`` is set
110+
(Always "true" on GitHub Actions), False otherwise.
111+
"""
112+
return os.environ.get('GITHUB_ACTIONS') is not None
113+
114+
104115
def render_table(
105116
columns_data,
106117
columns_alignment,

tools/nb_uncomment_pip.py

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)