You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs: updated API and CONTRIBUTING
* docs: move contributing in nav
* docs: remove venv
* feat: added docs building to nox
* docs: improve description
---------
Co-authored-by: Andrzej Novak <[email protected]>
Also conveniently accessible as `bash install.sh`.
17
15
18
16
## Pull Requests
@@ -30,35 +28,66 @@ If you would like to make a pull request please:
30
28
31
29
### Running the tests
32
30
33
-
You can run the unit tests (which should be fast!) via the following command.
31
+
You can run the unit tests (which should be fast!) via the following command:
32
+
33
+
**With pytest**
34
34
35
35
```bash
36
36
pytest --mpl --ignore=tests/test_notebooks.py
37
37
```
38
38
39
-
Note: This ignores the notebook tests (which are run via
40
-
[papermill](https://github.com/nteract/papermill) and run somewhat slow. Make
41
-
sure to run the complete suite before submitting a PR
39
+
Note: This ignores the notebook tests (which are run via[papermill](https://github.com/nteract/papermill)) and run somewhat slow.
40
+
41
+
Make sure to run the complete suite before submitting a PR
42
42
43
43
```bash
44
44
python -m pytest -r sa --mpl --mpl-results-path=pytest_results -n 4
45
45
```
46
46
47
+
**With nox**
48
+
49
+
```bash
50
+
nox -s tests
51
+
```
52
+
47
53
### Making a pull request
48
54
49
-
We follow [Conventional Commit](https://www.conventionalcommits.org/) for commit
50
-
messages and PR titles. Since we merge PR's using squash commits, it's fine if
51
-
the final commit messages (proposed in the PR body) follow this convention.
55
+
We follow [Conventional Commit](https://www.conventionalcommits.org/) for commit messages and PR titles. Since we merge PR's using squash commits, it's fine if the final commit messages (proposed in the PR body) follow this convention.
52
56
53
57
### Generating Reference Visuals
54
58
55
-
If you modified expected outcomes of the tests. New baseline visuals can be
56
-
generated using this command:
59
+
If you modified expected outcomes of the tests. New baseline visuals can be generated using this command:
60
+
61
+
**With pytest**
57
62
58
63
```bash
59
64
python -m pytest -r sa --mpl -n 4 --mpl-generate-path=tests/baseline
60
65
```
61
66
62
-
Only include the actually modified baseline images in your PR! Running `git add
63
-
-a` and the like will sometimes result in including images which are visually
64
-
identically but not the same bit-wise.
67
+
**With nox**
68
+
69
+
```bash
70
+
nox -s generate_examples_figures
71
+
```
72
+
73
+
Only include the actually modified baseline images in your PR! Running `git add -a` and the like will sometimes result in including images which are visually identically but not the same bit-wise.
74
+
75
+
### Linting and Formatting
76
+
77
+
We use `pre-commit` to manage code formatting and linting. Make sure to run it before committing your changes:
78
+
79
+
**With pre-commit**
80
+
81
+
```bash
82
+
pre-commit run --all-files
83
+
```
84
+
85
+
**With nox**
86
+
87
+
```bash
88
+
nox -s lint
89
+
```
90
+
91
+
## Contributing to the documentation
92
+
93
+
The documentation is built using [MkDocs](https://www.mkdocs.org/) and the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme. To contribute to the documentation, please look at the [`new_docs/CONTRIBUTING_DOC.md`](CONTRIBUTING_DOC.md) file for instructions.
Copy file name to clipboardExpand all lines: new_docs/CONTRIBUTING_DOC.md
+62-25Lines changed: 62 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,53 @@
1
-
# Style-Specific Guide Generation
1
+
# Documentation
2
2
3
-
This directory contains an automated system for generating a single `guide.md` file with tabs for each experiment style from a template.
3
+
The documentation for `mplhep` is built using [MkDocs](https://www.mkdocs.org/) with the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme.
4
4
5
-
## Overview
5
+
To build the documentation locally, run the following command from the root directory of the repository:
6
+
7
+
**With MkDocs:**
8
+
9
+
Additional requirements for building the docs are listed in `new_docs/requirements_docs.txt` and can be installed via:
10
+
11
+
```bash
12
+
pip install -r new_docs/requirements_docs.txt
13
+
```
14
+
Then run:
15
+
16
+
```bash
17
+
mkdocs build # Builds the documentation into the site/ directory
18
+
mkdocs serve # Serves the documentation locally
19
+
```
20
+
21
+
**With Nox:**
22
+
23
+
```bash
24
+
nox -s docs # Builds the documentation into the site/ directory
25
+
nox -s docs -- --fast # Builds the documentation quickly without rendering code blocks (much faster building time)
This directory contains an automated system for generating the documentation files with tabs for each experiment style from a template.
32
+
33
+
### Overview
6
34
7
35
Instead of manually maintaining separate guide files for each experiment style or manually maintaining one file with all the tabs, we use a template-based approach:
8
36
9
37
1.**Template Files**: `docs/*_template.md` contains the contents with tab placeholders ({{TABS_START}}/{{TABS_END}})
10
38
2.**Generation Script**: `generate_style_guides.py` expands tabs with style-specific code for each experiment
11
39
3.**MkDocs Hook**: `docs_hooks.py` automatically runs the script before each build
12
-
4.**Generated Files**: Single `docs/*.md` without the `_template`, with tabs for CMS, ATLAS, LHCb, ALICE, DUNE, and plothist
40
+
4.**Generated Files**: `docs/*.md` without the `_template`, with tabs for CMS, ATLAS, LHCb, ALICE, DUNE, and plothist
13
41
14
-
## Files
42
+
###Files
15
43
16
44
-`docs/*_template.md` - Templates with `{{TABS_START}}/{{TABS_END}}` markers
17
45
-`generate_style_guides.py` - Script to generate guide.md with experiment tabs
18
46
-`docs_hooks.py` - MkDocs hook that runs the generation script automatically
19
47
20
-
## How It Works
48
+
###How It Works
21
49
22
-
### Template Structure
50
+
####Template Structure
23
51
24
52
The template uses special markers to denote tabbed sections:
25
53
@@ -42,7 +70,7 @@ The template uses special markers to denote tabbed sections:
42
70
43
71
This generates tabs for all 6 styles (CMS, ATLAS, LHCb, ALICE, DUNE, plothist).
44
72
45
-
### Placeholders
73
+
####Placeholders
46
74
47
75
Within tabbed sections, these placeholders get replaced per style:
48
76
@@ -55,7 +83,7 @@ Within tabbed sections, these placeholders get replaced per style:
55
83
-`{{LABEL_CODE_LUMI}}` - Label code with luminosity
56
84
-`{{MAGIC_CODE}}` - mpl_magic() call if needed (ATLAS, ALICE only)
The MkDocs hook automatically runs the generation script before every build:
72
100
101
+
**With MkDocs:**
102
+
73
103
```bash
74
104
mkdocs build # Guide is generated automatically
75
105
mkdocs serve # Guide is generated on startup
76
106
```
77
107
78
-
## Making Changes
108
+
**With Nox:**
109
+
110
+
```bash
111
+
nox -s docs # Guide is generated automatically
112
+
nox -s docs -- --serve # Guide is generated on startup
113
+
```
114
+
115
+
### Making Changes
79
116
80
-
### To update the templates:
117
+
####To update the templates:
81
118
82
119
1. Edit `docs/*_template.md`
83
120
2. For content that should be the same across all styles, edit it directly
84
121
3. For content that varies by style, use `{{TABS_START}}` ... `{{TABS_END}}` markers
85
122
4. Test generation: `python generate_style_guides.py`
86
-
5. Build docs: `mkdocs build` or `mkdocs serve`
123
+
5. Build docs via MkDocs or Nox to see changes
87
124
6.`docs/*.md` without the `_template` files will be regenerated automatically
88
125
89
-
### To add a new style:
126
+
####To add a new style:
90
127
91
128
1. Add style configuration to `generate_style_guides.py` in the `STYLES` dict
92
129
2. Add the style name to `STYLE_ORDER` list
93
130
3. Run the generation script
94
131
95
-
### To modify style-specific code:
132
+
####To modify style-specific code:
96
133
97
134
1. Edit the appropriate entry in the `STYLES` dict in `generate_style_guides.py`
98
135
2. Regenerate: `python generate_style_guides.py`
99
136
100
-
## Example Template Usage
137
+
###Example Template Usage
101
138
102
139
```markdown
103
-
### Simple Example
140
+
#### Simple Example
104
141
105
142
This shows a basic histogram with different styles:
106
143
@@ -151,7 +188,7 @@ This generates:
151
188
...
152
189
```
153
190
154
-
## Benefits
191
+
###Benefits
155
192
156
193
1.**Single Source of Truth**: Edit one template, update all style tabs
157
194
2.**Consistency**: All style tabs have identical structure and examples
@@ -160,31 +197,31 @@ This generates:
160
197
5.**Flexible**: Easy to add new styles or modify existing ones
161
198
6.**Clean**: Template is much simpler than manually maintaining all tabs
162
199
163
-
## Troubleshooting
200
+
###Troubleshooting
164
201
165
-
### Guide not updating
202
+
####Guide not updating
166
203
167
204
Make sure you're editing `docs/*_template.md`.
168
205
169
-
### Build errors
206
+
####Build errors
170
207
171
208
Check that all placeholders in the template are defined in the `STYLES` dict in `generate_style_guides.py`.
172
209
173
-
### Missing mpl_magic calls
210
+
####Missing mpl_magic calls
174
211
175
212
ATLAS and ALICE styles need `mh.mpl_magic(soft_fail=True)` after labels. This is handled automatically via the `MAGIC_CODE` placeholder which includes proper indentation.
0 commit comments