Skip to content

Commit aa883ef

Browse files
Merge pull request #2 from python-accelerator-middle-layer/tutorials
Adding tutorials for creating and inspecting accelerator
2 parents f344732 + 485157b commit aa883ef

15 files changed

Lines changed: 333 additions & 90 deletions

.github/workflows/deploy-pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727
with:
2828
python-version: "3.11"
2929

30-
- name: Install docs dependencies
30+
- name: Install dependencies
3131
run: |
3232
python -m pip install --upgrade pip
33-
pip install -r docs-requirements.txt
33+
pip install -r requirements.txt -r docs/requirements.txt
3434
3535
- name: Build Sphinx docs
3636
run: ./build-docs.sh

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,40 @@ The documentation follows the [Diataxis approach](https://diataxis.fr/).
44

55
## Building the Docs
66

7-
1. Create a virtual environment and activate it.
8-
2. Install the requirements with `pip install -r docs-requirements.txt`.
9-
3. Create a new branch. The main branch is protected so you can't push to it directly.
10-
4. Build the docs locally with `./build-docs.sh`. The new version is available in `docs/build/html/index.html`.
11-
5. When the local version looks good, push your changes and make a pull request. Pushes to main will build and deploy the new version.
7+
1. Clone the repository
8+
2. Create a virtual environment and activate it.
9+
3. Install the requirements with `pip install -r requirements.txt -r docs/requirements.txt`.
10+
4. Create a new branch. The main branch is protected so you can't push to it directly.
11+
5. Build the docs locally with `./build-docs.sh`. The new version is available in `docs/build/html/index.html`.
12+
6. When the local version looks good, push your changes and make a pull request. Pushes to main will build and deploy the new version.
1213

1314
For the notebooks it is necessary to have the required pyAML packages installed in the environment.
14-
If you add a new dependency remember to also add it in the requirements.txt or it will not be built correctly.
15+
If you add a new dependency remember to also add it in the `docs/requirements.txt` or it will not be built correctly.
1516

16-
## Where to Place Content
17+
## Developing Content
1718

1819
Content should be placed in these categories:
1920

2021
#### [Tutorials](https://diataxis.fr/tutorials/)
2122

2223
A tutorial is a practical activity where learning is done by doing something meaningful towards an achievable goal.
23-
The purpose is not to get something done but to help to learn.
24+
The purpose is not to get something done but to help to learn. It should be structured as a lesson. The recommended format is to use a Jupyter notebook.
2425

25-
It should be structured as a lesson. The recommended format is to use a Jupyter notebook.
26+
The tutorials are rendered using `sphinx-gallery`. They need to be written as a `.py` file using `rst` and not directly as Jupyter notebooks. You can use `jupytext` to make the workflow easier.
2627

27-
#### [How-to guides](https://diataxis.fr/how-to-guides/)
28+
Jupytext can be used in the terminal but if you are using an IDE there are extensions available which makes it easier. In VS Code install `Jupytext for Notebooks (congyiwu)`. You should then be able to right click on a `.py` file and choose `Open as a Jupyter Notebook`. You can run and modify the notebook as normal and the changes should happen in the `.py` automatically. Just remember that `sphinx-gallery` requires `rst` while notebooks use `markdown` so comments might not be rendered exactly the same.
29+
30+
To create a new tutorial you can start to write it as a notebook and then use the functionality to convert to `.py`. If you have written comments as markdown you need to manually convert them to `rst`.
31+
32+
#### [How-to Guides](https://diataxis.fr/how-to-guides/)
2833

2934
How-to guides help to get something done in the correct and safe way.
3035
The focus should be on how to achieve a specific task.
3136

3237
Details of the difference between tutorials or how-to guides can be found at https://diataxis.fr/tutorials-how-to/#tutorials-how-to
3338
if you are unsure where to place your content.
3439

35-
#### [Technical reference](https://diataxis.fr/reference/)
40+
#### [Technical Reference](https://diataxis.fr/reference/)
3641

3742
Technical references are technical descriptions of the software, for example the API.
3843

build-docs.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
set -euo pipefail
44

5-
rm -rf docs/build .jupyter_cache
5+
rm -rf docs/source/tutorials docs/source/sg_execution_times.rst
6+
rm -rf docs/build
7+
rm -rf .jupyter_cache
8+
69
mkdir -p docs/source/_static
710

811
sphinx-build -E -a -b html docs/source docs/build/html

docs-requirements.txt

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

docs/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pyaml-test-lattice==0.1.0a2
2+
git+https://github.com/python-accelerator-middle-layer/pyaml.git@main
3+
pyaml-cs-oa[tango] @ git+https://github.com/python-accelerator-middle-layer/pyaml-cs-oa.git@main
2.13 MB
Loading

docs/source/_static/custom.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,31 @@ a.gh-link:visited {
1111
.sphx-glr-download-zip {
1212
display: none;
1313
}
14+
15+
/* Change the number of columns in the sphinx gallery grid */
16+
/* .sphx-glr-thumbnails {
17+
grid-template-columns: 1fr;
18+
gap: 1rem;
19+
} */
20+
21+
.sphx-glr-signature {
22+
display: none;
23+
}
24+
25+
/* Modifications to show the output as in a notebook */
26+
.sphx-glr-script-out::before {
27+
display: none !important;
28+
content: none !important;
29+
}
30+
31+
.sphx-glr-script-out,
32+
.sphx-glr-script-out div.highlight,
33+
.sphx-glr-script-out pre {
34+
background: transparent !important;
35+
border: none !important;
36+
box-shadow: none !important;
37+
}
38+
39+
.sphx-glr-script-out pre {
40+
padding: 0;
41+
}
1.9 MB
Loading

docs/source/conf.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from sphinx_gallery.sorting import FileNameSortKey
2+
13
# Configuration file for the Sphinx documentation builder.
24
#
35
# For the full list of built-in configuration values, see the documentation:
@@ -31,26 +33,30 @@
3133
]
3234

3335
sphinx_gallery_conf = {
34-
"examples_dirs": "tutorials_src",
35-
"gallery_dirs": "tutorials",
36+
"examples_dirs": ["../tutorials"],
37+
"gallery_dirs": ["tutorials"],
38+
"filename_pattern": r"\.py$",
39+
"show_memory": False,
40+
"remove_config_comments": True,
41+
"min_reported_time": 999999,
42+
"within_subsection_order": FileNameSortKey("../tutorials"),
3643

3744
# Binder (cloud notebook)
3845
"binder": {
3946
"org": "python-accelerator-middle-layer",
4047
"repo": "documentation",
4148
"branch": "main",
4249
"binderhub_url": "https://mybinder.org",
43-
"dependencies": ["../../requirements.txt"],
50+
"dependencies": ["../requirements.txt"],
4451
"use_jupyter_lab": True,
4552
},
4653
}
4754

48-
exclude_patterns += [
49-
"tutorials/*.ipynb",
55+
exclude_patterns = [
5056
"tutorials/*.py",
57+
"tutorials/*.ipynb",
5158
"tutorials/*.zip",
5259
"tutorials/*.codeobj.json",
53-
"tutorials_src/GALLERY_HEADER.rst"
5460
]
5561

5662
# -- Options for HTML output -------------------------------------------------
@@ -67,4 +73,6 @@
6773
}
6874
html_theme_options = {
6975
"secondary_sidebar_items": ["page-toc","sg_download_links", "sg_launcher_links"],
76+
"pygments_light_style": "default",
77+
"pygments_dark_style": "monokai",
7078
}

docs/source/tutorials_src/GALLERY_HEADER.rst

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

0 commit comments

Comments
 (0)