Skip to content

Commit

Permalink
DX: build documentation through sphinx-build (#25)
Browse files Browse the repository at this point in the history
* DOC: add website favicon
* DOC: add website icons to sidebar
* DOC: convert STRONG2020 logo to SVG
* DX: add Hypothesis.is overlay for commenting to website
* DX: implement autoformatters for TOML files
* ENH: update documentation requirements
* MAINT: define dependencies in pyproject instead of `requirements.txt`
* MAINT: extend `.gitignore` structure
  • Loading branch information
redeboer authored Oct 24, 2023
1 parent 94c273b commit f99ed4f
Show file tree
Hide file tree
Showing 18 changed files with 513 additions and 62 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ trim_trailing_whitespace = true

[*.{ipynb,md}]
indent_size = unset

[*.{py,toml}]
indent_size = 4
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- main
- epic/*
- "[0-9]+.[0-9]+.x"
pull_request:
branches:
- main
- epic/*
- "[0-9]+.[0-9]+.x"
workflow_dispatch:
inputs:
specific-pip-packages:
description: Run CI with specific pip packages
required: false
type: string

jobs:
style:
if: inputs.specific-pip-packages == ''
secrets:
token: ${{ secrets.PAT }}
uses: ComPWA/actions/.github/workflows/pre-commit.yml@v1
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install -r requirements.txt
- run: pip install -e .[doc] tox
- name: Fetch Jupyter cache
uses: actions/cache@v3
with:
Expand All @@ -36,7 +36,7 @@ jobs:
data
path: |
./docs/data
- run: jupyter book build docs/ -W
- run: tox -e docnb
- uses: actions/upload-pages-artifact@v2
if: always()
with:
Expand Down
39 changes: 37 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
# Output files
*.csv
*.dat
*.txt
data/

# Build files
*.egg-info/
*build/
.eggs/
.fuse_*
dist/
version.py

# Temporary files
*.pyc
*condaenv.*
.coverage
.coverage.*
.ipynb_checkpoints/
.mypy*/
.pytest_cache/
.virtual_documents/
__pycache__/
_build/
data/
docs/lecture18
htmlcov/
jupyter_execute/
prof/

# Virtual environments
*venv/
.tox/
pyvenv*/

# Settings
.idea/
**.code-workspace

# Exceptions
!.github/*.yml
!.github/*/*.yml
!.pre-commit-config.yaml
!.vscode/*.json
!environment.yml
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ci:
autoupdate_commit_msg: "MAINT: update pre-commit config file"
autoupdate_schedule: quarterly
skip:
- taplo

repos:
- repo: meta
Expand All @@ -13,6 +15,7 @@ repos:
hooks:
- id: check-case-conflict
- id: check-json
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
Expand Down Expand Up @@ -84,3 +87,15 @@ repos:
rev: v3.0.3
hooks:
- id: prettier

- repo: https://github.com/ComPWA/mirrors-taplo
rev: v0.8.1
hooks:
- id: taplo

- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort
args:
- --in-place
12 changes: 12 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[formatting]
align_comments = false
align_entries = false
allowed_blank_lines = 1
array_auto_collapse = false
array_auto_expand = true
array_trailing_comma = true
column_width = 88
compact_inline_tables = true
indent_string = " "
reorder_arrays = true
reorder_keys = true
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"mhutchie.git-graph",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.python",
"ms-toolsai.jupyter",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-toolsai.vscode-jupyter-slideshow",
"ms-vscode.live-server",
"stkb.rewrap",
"tamasfe.even-better-toml",
"tyriar.sort-lines",
"yzhang.markdown-all-in-one"
],
"unwantedRecommendations": [
"bungcip.better-toml",
"davidanson.vscode-markdownlint",
"ms-python.mypy-type-checker",
"travisillig.vscode-json-stable-stringify"
Expand Down
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,29 @@
"editor.rulers": [72],
"rewrap.wrappingColumn": 72
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.rulers": [88]
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"black-formatter.importStrategy": "useBundled",
"editor.formatOnSave": true,
"github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"],
"isort.args": ["--profile", "black"],
"livePreview.defaultPreviewPath": "docs/_build/html",
"notebook.gotoSymbols.showAllSymbols": true,
"rewrap.wrappingColumn": 88
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,20 @@ This (unofficial) repository contains the exercises for the [STRONG2020 HaSP Sch

## Documentation

The website [compwa.github.io/strong2020-salamanca](https://compwa.github.io/strong2020-salamanca) is automatically generated from the notebooks in this repository using [Jupyter Book](https://jupyterbook.org). You can also run the notebooks and build the documentation locally as follows:
The website [compwa.github.io/strong2020-salamanca](https://compwa.github.io/strong2020-salamanca) is automatically generated from the notebooks in this repository using [Sphinx](https://www.sphinx-doc.org) and [MyST-NB](https://myst-nb.rtfd.io). You can also run the notebooks and build the documentation locally as follows:

```shell
jb build docs/
tox -e docnb
```

Adding the flag `-W` renders warnings as errors, which is useful for checking whether the notebooks run correctly.
Alternatively, you can run the notebooks without building the documentation with

```shell
tox -e nb
```

or build the documentation without running the notebooks with

```shell
tox -e doc
```
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lecture18
40 changes: 0 additions & 40 deletions docs/_config.yml

This file was deleted.

Binary file added docs/_static/favicon.ico
Binary file not shown.
89 changes: 89 additions & 0 deletions docs/_static/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
format: jb-book
root: index
chapters:
entries:
- glob: lecture*
Loading

0 comments on commit f99ed4f

Please sign in to comment.