Writing a tutorial#
A technique tutorial is authored once and rendered in four places, so the app, the website and the docs can never drift apart:
Rendering |
Built by |
|---|---|
The in-app guided tour (a coachmark walkthrough over the live UI) |
|
Help → <technique> → Info… (background + further reading) |
|
The docs pages under Tutorials |
|
The standalone docs website (with interactive embeds) |
|
The source#
One file per technique in guides/ at the repository root, registered in
guides/index.ts. The format is guides/types.ts:
stepsThe click-by-click walkthrough. Each step names the UI element it is about by its stable
data-testid(anchor), carries a short markdownbody, and optionally animage(a screenshot) and adrive(a screenplay for reaching the step when generating screenshots).autoloadA backend action run once when the tour opens — in practice
tutorial_loadwith the name of a small, instant, no-download dataset fromspyde/backend/tutorial_data.py. This is what makes a tutorial self-contained: it brings its own data rather than assuming the user already has the right thing open.infoThe background half: a
blurbon what the technique is and when to reach for it, pluslinksto the upstream documentation. It becomes the tour’s final “More info” step, the Help → Info… dialog, and the More information section of the docs page.
Guidelines#
Link, don’t restate. SpyDE wraps pyxem, HyperSpy, eXSpy, kikuchipy and orix; those projects own the science and document it far better than a walkthrough can. Put their pages in
info.linkswith a one-line note on what the reader will find there, and keep the blurb to what SpyDE’s own interface does with the method.Keep the dataset tiny. A tutorial must load in a couple of seconds with no download. See the size assertions in
spyde/tests/migrated/test_tutorial_data.py.Everything the tour opens is closed again on exit. The Tour brackets itself with
tutorial_session_begin/tutorial_close_all; between those,Session._add_signalrecords every non-file-backed tree so the teardown gets the result windows too, not just the dataset. You do not need to do anything for this — but do not open windows from outside that lifecycle and expect them to be cleaned up.
Regenerating the docs pages#
doc/tutorials/*.rst is generated and committed, so a docs build needs
only Python. After editing any guide, regenerate and commit the result:
node scripts/gen_guide_docs.mjs # write doc/tutorials/
node scripts/gen_guide_docs.mjs --check # fail if it would change
(The script bundles the TypeScript guides with the esbuild already installed
under electron/node_modules, so run npm install in electron/ first.)
Screenshots are not copied into doc/. They are captured by the
Playwright run electron/tests/guide_screenshots.spec.ts, which walks each
step’s drive and writes into docs-site/public/media/<guide>/;
doc/conf.py mirrors that tree into doc/tutorials/media/ at build time. A
step whose screenshot has not been captured simply renders without one:
cd electron
SPYDE_E2E_REAL=1 npx playwright test guide_screenshots.spec.ts --project=electron-real