A repo for bootstrapping and maintaining SOPs: https://mattechlab.github.io/sops/
Workflow for editing sops:
-
Set up your environment, using one of the options below
conda create -n sops python=3.10 conda activate sops cd SOPS pip install -r requirements.txt npm install conda env config vars set JUPYTER_PLATFORM_DIRS=1 NO_MKDOCS_2_WARNING=true -n sops conda activate sops
npm installinstalls cspell, used to spellcheck the docs (requires Node.js).JUPYTER_PLATFORM_DIRS=1silences ajupyter_coredeprecation warning printed by themkdocs-jupyterplugin on every build; setting it as a conda env var (rather than in a build hook) guarantees it's set before mkdocs starts, since mkdocs importsmkdocs-jupyterbefore any of its own hooks run. The env var only takes effect after reactivating the environment, hence the secondconda activate sops.NO_MKDOCS_2_WARNING=truesilencesmkdocs-material's built-in announcement about breaking changes coming in MkDocs 2.0 (details), printed on every build/serve; same reasoning as above applies for setting it as a conda env var rather than in a hook.Skip the local conda/npm setup entirely and open the repo in a VS Code Dev Container (
Dev Containers: Reopen in Container), which builds a container with Python, Node, and all dependencies already installed (seeDockerfile/.devcontainer/devcontainer.json). Requires Docker and the Dev Containers extension. Once reopened in the container, every command below (mkdocs build,mkdocs serve,codespell,npx cspell, ...) works exactly as in Option A, from the integrated terminal. -
Add the new markdown in the folder desired, eg:
/docs/data-collection/data-collection_DEBI_protocol.md -
Save pictures in the folder:
/docs/assets/ -
Use MkDocs to build the static site
mkdocs build
mkdocs build(andmkdocs serve) automatically run codespell and cspell on the docs before building, and abort the build if either finds a spelling error.To run them independently of MkDocs:
codespell npx cspell --no-progress "**/*.md" -
Serve the site locally during development
mkdocs serve
Now you can visualize the website build locally, probably at http://127.0.0.1:8000/sops/. On push the website will be automatically deployed online.
-
Deploy the site to the github page
git add .
git commit -m 'your comment'
git push- Pushing to any branch runs
.github/workflows/tests.yml: two parallel jobs,codespellandcspell, just spellchecking the docs. Nothing is built or deployed. - Pushing to
mkdocsinstead runs.github/workflows/deploy.yml(tests.ymlskips this branch, since the same checks happen here too):codespellandcspelljobs run first (same as above).- Once both pass, the
buildjob checks out this branch intomkdocs/and thegh-pagesbranch intowww/, wipeswww/'s tracked files, then runsmkdocs build -d ../www/to regenerate the static site there (skipping its own spellcheck hooks, since the jobs above already checked this push). - The
Deploystep commits and pushes whatever changed inwww/straight togh-pages— that's the branch actually served at https://mattechlab.github.io/sops/.
- If either spellchecker fails, the build/deploy never runs, so a typo on
mkdocswon't reach the live site.
This is the automated equivalent of running mkdocs gh-deploy locally — you never need to run that yourself.
