Skip to content

Commit 126a7ca

Browse files
authored
Merge pull request #107 from nightscout/docs-0.4.0
2 parents 3152292 + d3ea5c5 commit 126a7ca

File tree

392 files changed

+8767
-403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

392 files changed

+8767
-403
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI
2+
3+
# Controls when the action will run.
4+
on:
5+
# Remark: uncomment one section only
6+
# Remark: Next 1 line requires manual action, Click on action tab, then publish
7+
# workflow_dispatch
8+
# Remark: Next 5 lines triggers the workflow on push events for the main branch
9+
push:
10+
branches:
11+
- dev
12+
paths-ignore:
13+
- "README.md"
14+
15+
jobs:
16+
ci:
17+
runs-on: ubuntu-latest
18+
if: github.repository_owner == 'nightscout'
19+
steps:
20+
- name: Checkout Repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: 3.x
29+
30+
- name: Create, Activate and share a Python Virtual Env
31+
run: |
32+
python -m venv venv
33+
source venv/bin/activate
34+
# Persist venv related variables across the steps below
35+
# See: https://stackoverflow.com/a/74669486/386517
36+
echo "PATH=$PATH" >> "$GITHUB_ENV"
37+
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> "$GITHUB_ENV"
38+
39+
- name: Install Python Dependencies
40+
run: pip install -r requirements.txt
41+
42+
- name: Check for unused files
43+
run: CHECK_UNUSED_FILES=true mkdocs build -s

.github/workflows/pr_dependencies_check.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Prevent Blocked PRs from being Merged
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types:
66
- opened
77
- edited
@@ -18,6 +18,10 @@ on:
1818

1919
jobs:
2020
blocking_issues:
21+
permissions:
22+
checks: write
23+
issues: write
24+
pull-requests: write
2125
runs-on: ubuntu-latest
2226
steps:
2327
- uses: Levi-Lesches/blocking-issues@v2

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
# Remark: Next 5 lines triggers the workflow on push events for the main branch
99
push:
1010
branches:
11-
- docs-0.4.0
11+
- dev
1212
paths-ignore:
1313
- "README.md"
1414

@@ -57,7 +57,7 @@ jobs:
5757
run: playwright install --with-deps chromium
5858

5959
- name: Build Website
60-
run: mkdocs build
60+
run: MKDOCS_EXPORTER_PDF=true mkdocs build
6161

6262
- name: Push Website to gh-pages Branch
6363
uses: JamesIves/github-pages-deploy-action@v4

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ node_modules/
1818
/playwright-report/
1919
/blob-report/
2020
/playwright/.cache/
21+
22+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
23+
# Do not ignore this folder
24+
!/docs/install/build/
25+
26+
# Python
27+
__pycache__/

README.md

Lines changed: 165 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Repository for [Trio documentation (under development)](https://docs.diy-trio.or
2121
```shell
2222
cd trio-docs # where you cloned the trio-docs repository
2323

24+
python -m pip install -r dev-requirements.txt
2425
python -m pip install -r requirements.txt
2526
```
2627

@@ -66,7 +67,26 @@ MKDOCS_EXPORTER_PDF=true mkdocs build
6667
```
6768

6869
The PDF file is generated in`site/trio-docs.pdf`.
70+
71+
### Find Unused Files
72+
73+
To find unused (orphaned) files in the project:
74+
75+
```shell
76+
CHECK_UNUSED_FILES=true mkdocs build -s
77+
```
78+
79+
> [!NOTE]
80+
> We use the [`mkdocs-unused-files`](https://github.com/wilhelmer/mkdocs-unused-files) plugin.
6981
82+
### Find Broken Links
83+
84+
To list broken links, we use [`mkdocs-htmlproofer-plugin`](https://github.com/manuzhang/mkdocs-htmlproofer-plugin):
85+
86+
```shell
87+
CHECK_BROKEN_LINKS=true mkdocs build --quiet
88+
```
89+
7090
## Contribute
7191

7292
You can contribute to the Trio documentation by correcting typos or suggesting new content.
@@ -132,47 +152,71 @@ git push -u origin add_FAQ_page
132152
This page displays a box saying you can create a Pull-Request for your branch.
133153
- Click the button to do so, then follow the instructions.
134154

135-
### Add a Plugin
155+
### Add a Package
156+
157+
> [!NOTE]
158+
> In this section, the terms Python **package** and **dependency** refer to the same thing.
136159
137-
- Create a feature branch
138-
- Add the pinned version of the new plugin to the **`requirements.in`** file
160+
- **Create** a feature **branch** (aka. topic branch)
161+
```shell
162+
git switch dev
163+
git switch -c feature/add_dependency_XXX
164+
```
165+
- **Add** the pinned version of the new **package** to the **`requirements.in`** file
139166
```shell
140167
MY_FAVORITE_EDITOR_HERE requirements.in
141168

142-
# Add the pinned version (i.e. plugin name + version) to `requirements.in
143-
XXX_PLUGIN_NAME_HERE==XXX_PLUGIN_VERSION_HERE
169+
# Add the pinned version of the package to `requirements.in
170+
XXX_PACKAGE_NAME_HERE==XXX_PACKAGE_VERSION_HERE
144171
```
145-
For example, add this line `mkdocs-exporter==6.1.1` to `requirements.in`
172+
For example, to add the `mkdocs-exporter` package version `6.1.1`, I added the following line to the `requirements.in` file:
173+
```text
174+
mkdocs-exporter==6.1.1
175+
```
146176
- Generate **`requirements.txt`**
147177
```shell
148178
cd trio-docs
149179
150180
# IMPORTANT: The project's virtual environment MUST be activated first
151181
source venv/bin/activate
152182
153-
# Remove already installed plugins
154-
python -m pip freeze --exclude-editable | xargs python -m pip uninstall -y
183+
# Remove the already installed packages in case you need to start from a blank slate
184+
# python -m pip freeze --exclude-editable | xargs python -m pip uninstall -y
185+
186+
# Install the development packages
187+
# (among which `pip-tools` that contains `pip-compile`)
188+
pip install -r dev-requirements.txt
155189
156-
# Install the dependencies listed in `requirements.in`
157-
# This installs the indirect dependencies these plugins depend upon.
190+
# Install the direct dependencies (listed in `requirements.in`
191+
# This also installs the indirect dependencies these packages depend upon.
158192
pip install -r requirements.in
159193
160-
# Generate `requirements.txt` with both direct AND indirect dependencies
161-
pip freeze > requirements.txt
194+
# Add code/doc using this package and test until it is ready.
162195
163-
# Commit the changes (where XXX denotes the plugin name)
196+
# Generate the `requirements.txt` file from `requirements.in`
197+
pip-compile
198+
199+
# Commit the changes (where XXX denotes the package name)
164200
git add requirements.in requirements.txt
165-
git commit -m "➕ Add dependency XXX"
201+
git commit -m "➕ Add dependency: XXX"
202+
203+
# Push your feature branch to your `origin` repository
204+
git push -u origin feature/add_dependency_XXX
166205
```
167-
168-
## Tips & Tricks
206+
- [**Create a Pull Request**](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) with your changes:
207+
- Open your clone repository of `trio-docs` on *GitHub* (`https://github.com/YOUR_USERNAME/trio-docs`)
208+
- Click the `Pull Requests` tab
209+
- Click "`Compare & pull request`" in the yellow banner next to your branch name
210+
211+
212+
## FAQs
169213

170214
> [!NOTE]
171215
> Please add!
172216

173217
### Add a Chapter
174218

175-
Using the `#` sign shows a chapter on the menu/index. The amount of `#`'s determines the level.
219+
Using the `#` sign shows a chapter on the menu/index. The number of `#`'s determines the level.
176220
177221
**Example**:
178222
@@ -197,11 +241,113 @@ Using the `#` sign shows a chapter on the menu/index. The amount of `#`'s determ
197241
> | `**bold text**` | **bold text** |
198242
> | `<b>bold text</b>` | **bold text** |
199243
200-
### Link to Another File
244+
### Add a Link to Another File
201245
202246
When linking to another Markdown file (ending with `.md`) in another directory, the link must start with `../`.
203247
204-
**Example**: `../directoryname/filename.md`
248+
In the below example, assuming you are editing `docs/install/index.md`, to add a link pointing to `docs/configuration/new-user-setup.md` with the text `new user setup`:
249+
250+
```html
251+
Now on to the [new user setup](../configuration/new-user-setup.md)
252+
```
253+
254+
Do not forget the `.md` suffix.
255+
256+
```
257+
docs <== ../
258+
├── install <== ./ denotes the current folder (docs/install/)
259+
│ └── index.md <== You are here (the current file)
260+
261+
├── configuration <== ../configuration
262+
│ └── new-user-setup.md <== ../configuration/new-user-setup.md
263+
```
264+
265+
### Update the Glossary
266+
267+
268+
> Trio's glossary is a dictionary for the acronyms and technical terms used in the documentation. It explains them in simple terms.
269+
> It is kind of a personal translator for all the diabetes jargon you will find there.
270+
271+
The glossary is composed of a source file and a generated Markdown page.
272+
The website uses the Markdown page of the glossary.
273+
274+
**Updating the glossary** is a 3-step **manual process**:
275+
1. Modify the glossary source file ([`includes/glossary.txt`](https://github.com/nightscout/trio-docs/tree/dev/includes/glossary.txt) ) to add/update/remove entries.
276+
2. Generate the glossary Markdown page (`docs/faqs/glossary.md`) using this handy shell script:
277+
```shell
278+
./make-glossary.sh
279+
```
280+
```mermaid
281+
---
282+
title: Generate the Glossary Page
283+
---
284+
flowchart LR
285+
subgraph Glossary Source
286+
text_glossary[/ includes/glossary.txt /]
287+
end
288+
subgraph Run Shell Script
289+
generator{ ./make-glossary.sh }
290+
end
291+
subgraph Glossary Page
292+
markdown_glossary[/ docs/faqs/glossary.md /]
293+
end
294+
295+
text_glossary --> generator --> markdown_glossary
296+
```
297+
3. **Commit** the changed files (glossary source file and generated page):
298+
```shell
299+
git add includes/glossary.txt docs/faqs/glossary.md
300+
git commit -m "Update Glossary: ..."
301+
```
302+
303+
> [!NOTE]
304+
> Remember to commit these 2 files.
305+
306+
### Create an Include File
307+
308+
When the same section of text is repeated in several files, it is time to consolidate all these occurrences into a single file and include it in all relevant files, that means:
309+
310+
- Move the existing redundant section of text to a new dedicated file.
311+
- Replace all redundant occurrences of that section with an include directive in all the files that previously defined it.
312+
313+
Let's break down these steps:
314+
315+
1. **Create a new file**
316+
Create a **Markdown file** in the `docs/includes/` folder, for example:
317+
`docs/includes/version-compatibility-matrix.md`.
318+
2. **Move the duplicated content**
319+
Move the duplicated section into this new file.
320+
3. **Mark it as includable**
321+
[Wrap the content](https://github.com/ebouchut/Trio-dev-docs/blob/9f22039213d5ac055b8dd171d5648d94fe0d506a/docs/includes/version-compatibility-matrix.md?plain=1#L2-L20) within `<!--include-markdown-start-->` and `<!--include-markdown-end-->` comments to define what will be included.
322+
```markdown
323+
Content before the start comment will not be included.
324+
325+
<!--include-markdown-start-->
326+
…your reusable content (duplicated text section)…
327+
<!--include-markdown-end-->
328+
329+
Content after the end comment will not be included.
330+
```
331+
1. **Replace each original redundant section with an include directive**
332+
In each file that originally contained the duplicated text, **replace it with the following [include directive](https://github.com/ebouchut/Trio-dev-docs/blob/9f22039213d5ac055b8dd171d5648d94fe0d506a/docs/install/build/requirements/devices/iphone.md?plain=1#L12)**:
333+
```markdown
334+
{%
335+
include-markdown "includes/version-compatibility-matrix.md"
336+
%}
337+
```
338+
Make sure the path is relative to the `docs/` folder.
339+
2. **Update `mkdocs.yml`**
340+
To prevent the included file from appearing in the navigation or triggering a warning, add it to the [**`not_in_nav`** section](https://github.com/ebouchut/Trio-dev-docs/blob/9f22039213d5ac055b8dd171d5648d94fe0d506a/mkdocs.yml#L203):
341+
```yaml
342+
not_in_nav: |
343+
includes/version-compatibility-matrix.md
344+
```
345+
346+
> [!NOTE]
347+
> Do not overuse this feature!
348+
>
349+
> Use it sparingly, as it adds a layer of abstraction that makes it harder to see the full contents of a page when editing it.
350+
205351
206352
### Migrate a Sphinx page to Mkdocs
207353

dev-requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mkdocs-translate
1+
pip-tools

dev-requirements.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.12
3+
# by the following command:
4+
#
5+
# pip-compile --output-file=dev-requirements.txt dev-requirements.in
6+
#
7+
build==1.2.2.post1
8+
# via pip-tools
9+
click==8.1.7
10+
# via pip-tools
11+
packaging==24.1
12+
# via build
13+
pip-tools==7.4.1
14+
# via -r dev-requirements.in
15+
pyproject-hooks==1.2.0
16+
# via
17+
# build
18+
# pip-tools
19+
wheel==0.44.0
20+
# via pip-tools
21+
22+
# The following packages are considered to be unsafe in a requirements file:
23+
# pip
24+
# setuptools

0 commit comments

Comments
 (0)