Developing the application¶
This page is for contributors changing the repository. To add an external sequence plugin without modifying the application, use Writing sequence plugins; for a display factory, use Writing a plot display plugin. End users can follow Installation without the contributor workflow.
Development environment¶
Read AGENTS.md in the checkout before changing code. Project commands run
through the stoner_measurement Conda environment; activation need not persist
between shell calls:
conda env create -f environment.yml
conda run -n stoner_measurement python -m pip install -e . --no-deps
conda run -n stoner_measurement stoner-measurement
On Windows, prefer & $env:CONDA_EXE run -n stoner_measurement ... when that
variable is set. Use the Anaconda/Miniforge installation hosting the environment;
the repository instructions exclude the unreliable Miniconda location.
Choosing and running tests¶
Read notes/testing_guidelines.md before adding, moving or rewriting tests,
and maintain migration records in notes/testing_restructure_plan.md. Keep
unit tests focused on one module/contract and broader flows under
tests/integration. Use fake transports/drivers for automated hardware tests.
$env:QT_QPA_PLATFORM = "offscreen"
$env:QT_QPA_FONTDIR = "C:\Windows\Fonts"
conda run -n stoner_measurement python -m pytest tests/unit/plugins/command -q
conda run -n stoner_measurement python -m pytest -q
Choose the focused tests for the changed contract first. Use
managed_qt_widget for top-level widgets and
managed_plugin_config_tabs for every page returned by config_tabs().
Keep hidden preview pages alive until deterministic GUI-thread teardown.
Use a workspace --basetemp if the system temporary directory is inaccessible.
Quality and distribution checks¶
conda run -n stoner_measurement python -m ruff check src tests docs
conda run -n stoner_measurement python -m ruff format --check src tests docs
conda run -n stoner_measurement python -m pylint src
conda run -n stoner_measurement python -m build
conda run -n stoner_measurement python -m twine check dist/*
conda run -n stoner_measurement check-manifest
Scale checks to the change. Preserve production quality checks; repository Codacy configuration excludes test-only complexity from the relevant engines. Local lint is not proof of hosted Codacy or CI success: inspect the immutable pushed commit’s checks before reporting remote clearance.
Documentation and examples¶
Keep user-facing Sphinx pages in docs/ and developer plans/evidence in
notes/. Give each page a defined audience and purpose, link to the canonical
reference instead of copying it, and validate examples against current source.
Use Plugin Tab Ordering and the shared widgets when extending plugin UI.
conda run -n stoner_measurement python -m sphinx -E -a -b html -W --keep-going docs docs/_build/html
Build with a fresh Sphinx environment and treat every warning as an error,
as the documentation deployment workflow does. API detail pages under
docs/_generated/api/ are regenerated from the authored catalogues and
templates; edit the catalogue, template or owning docstring instead of those
generated files. Inspect the generated HTML, downloads and image links.
Validate executable examples, including generated actions and persistence,
rather than only syntax-highlighting their source.
Bundled Windows help¶
The installed Help > User Guide opens the bundled offline manual. Its
repository copy is src/stoner_measurement/help/stoner_measurement.chm.
This compiled file is tracked in the repository so pip and Conda builds can
include it without requiring a Windows documentation compiler on the build or
installation machine.
After changing the documentation, rebuild the guide on Windows using Microsoft
HTML Help Workshop’s hhc.exe and the project’s Conda environment:
conda run -n stoner_measurement python scripts/build_chm.py
conda run -n stoner_measurement python -m build
Pass --hhc PATH_TO_HHC.EXE or set HHC when the compiler is not at its
standard location. The script builds strict Sphinx HTML Help from a clean
temporary source tree, regenerates API pages, validates the compiled header
and stages the CHM at the package-data path. Include the rebuilt binary with
the corresponding documentation changes. HTML build trees remain generated
artefacts and are not committed.
The setuptools package-data rule includes the CHM in wheels; MANIFEST.in
includes it in source distributions. The Conda recipe installs that same pip
payload and checks that the packaged resource has a valid CHM header. A normal
pip or Conda installation does not rebuild the manual.