Astro + Jupyter Book monorepo for the MindQuantum website and bilingual documentation.
- Astro powers the homepage and overall site shell.
- Jupyter Book builds bilingual tutorials only (EN+ZH).
- Jupyter Book also builds the self-contained course notebooks under
/courses. - Sphinx builds the API reference as two projects (EN+ZH) using the internal
mqdocsextension. - Shared design tokens keep visual consistency across both.
- GitHub Pages workflow builds and deploys both outputs together.
Prerequisites: Node 18+ and Python 3.9+.
- Install Node deps
npm install- (Optional) Create a Python venv and install Jupyter Book
python -m venv .venv
source .venv/bin/activate
pip install jupyter-book==1.0.4 sphinx-copybutton sphinx-design sphinx-thebe mindspore mindquantum- Sync docs content (optional during dev)
The repo can auto-clone the upstream sources into a local cache on first run. To sync both tutorials and API docs:
npm run sync:all # clone if missing, reuse cache if present
# or update to the latest upstreams before syncing
python scripts/sync_all.py --update- Build docs (tutorials + API)
npm run build:docs # auto-syncs upstreams, builds JB (tutorials) + Sphinx (API)- Run the site
npm run dev- Auto-clone: Upstreams are cached under
.upstreams/usingscripts/upstreams.json. - Tutorials:
scripts/sync_mindquantum_from_msdocs.pyvendors Sphinx sources from the cachedmindspore-docsclone. - API:
scripts/sync_mindquantum_api.pyvendors API sources from the cachedmindquantumclone. It also syncs into the standalone Sphinx projects atdocs/api-en/api_python_enanddocs/api-zh/api_python.
In addition to the Jupyter Books, the API reference builds as two Sphinx projects using a clean internal extension (mqdocs):
docs/api-en/– English API, usesms*autosummarydirectives that derive third columns from docstringsdocs/api-zh/– Chinese API, usesmscnautosummarydirectives that read summaries from the local RST pages
Shared assets live under docs/_ext, docs/_templates, and docs/_static.
Local build example:
# Ensure sources are synced into docs/api-*/
python scripts/sync_mindquantum_api.py
# Build EN API (centralized under docs/_build)
sphinx-build -b html docs/api-en docs/_build/api/en
# Build ZH API (centralized under docs/_build)
sphinx-build -b html docs/api-zh docs/_build/api/zhThe extension avoids monkey-patches and implements stable mscnautosummary/ms*autosummary directives plus a minimal stub generator for those directives only. Standard autosummary remains untouched.
npm run build:allbuilds Jupyter Books (tutorials + courses) and Sphinx intopublic/{docs,courses}/**, then builds Astro intodist/. Temporary artifacts are centralized underdocs/_build/andcourses/_build/.- GitHub Actions workflow
.github/workflows/deploy.ymlbuilds both and deploys thedist/folder to GitHub Pages. It auto-detects committed custom domains viapublic/CNAME, exportingASTRO_BASEandSITE_URLbefore the Astro build.
- Tutorials (Jupyter Book):
/docs/enand/docs/zh(frompublic/docs/enandpublic/docs/zh). - Courses (Jupyter Book):
/courses(frompublic/courses/zh). - API (Sphinx):
/docs/api/enand/docs/api/zh(frompublic/docs/api/enandpublic/docs/api/zh). - The site header should link to Tutorials and API for both languages.
- Shared CSS tokens live in
src/styles/tokens.css. - A small build step copies tokens to
docs/_static/mq-variables.cssso Jupyter Book can consume them. - Jupyter Book loads
mq-variables.cssandmq-theme.cssto style pages in line with the homepage.
src/– Astro pages, layouts, and styles.public/– static assets. Built docs are copied topublic/docs(ignored by Git).docs/– Documentation workspace:- Jupyter Book projects:
docs/enanddocs/zh(tutorials only) - Sphinx API projects:
docs/api-enanddocs/api-zh - Shared assets:
docs/_ext,docs/_static,docs/_templates
- Jupyter Book projects:
scripts/– helper scripts (token sync, upstream sync, local build).
Tutorial pages are now Thebe-enabled so users can click Run on code cells directly on the page. This uses Binder to start a live Jupyter kernel per user session.
- Toggle: A “Launch/Activate” button appears on each tutorial page to initialize Thebe. Once activated, each code cell shows a Run button.
- Scope: Execution is client-initiated; notebooks do not auto-execute. This keeps builds deterministic and scales better for traffic.
- Environment: The Binder environment is configured and controlled by the repository https://github.com/MindQuantum-HiQ/mq-env.
- Per-cell Run button: Implemented in
docs/_static/mq-thebe.jsand styled bydocs/_static/mq-thebe.css. It overlays a small “Run” button on Python code cells and notebook cells. On first click, it activates Thebe automatically and then runs the clicked cell. - Page banner: A compact banner at the top of tutorial pages advertises that the page is runnable in the browser. It provides “Activate” and “Run all examples” actions and mirrors the built-in Thebe status line.
- Inclusion: Both assets are registered in
docs/en/_config.ymlanddocs/zh/_config.ymlundersphinx.config.html_css_filesandsphinx.config.html_js_files. - Accessibility: Buttons include
aria-labels; colors use shared tokens for contrast. The overlay avoids the copy button by default and falls back gracefully if Thebe isn’t available on a given page.
Customization & maintenance:
- To disable the banner: remove
mq-thebe.css/mq-thebe.jsfromhtml_css_files/html_js_filesin the two Jupyter Book configs. - To limit per-cell buttons: adjust the selector logic in
mq-thebe.js(functionattachRunButtons) to match only your preferred patterns (e.g., only.cellor onlycode.language-python). Cells inside.thebe-ignoredare skipped automatically. - The script avoids private Thebe internals: it triggers the standard launch button and clicks the cell’s built-in
.thebe-run-button. This keeps it resilient across Thebe/Jupyter Book updates.
The homepage includes an interactive circuit builder that enables quantum graphical programming directly in the browser.
- Drag-and-drop gates, pick controls/targets, and view simulated results live.
- Implemented as a standalone web component
mq-circuit-builderwith:- UI logic in
src/components/circuit/QuantumCircuitElement.ts - Styles in
src/components/circuit/styles.css
- UI logic in
- Wrapped for Astro via
src/components/QuantumCircuitBuilder.astroand rendered onsrc/pages/index.astroandsrc/pages/[lang]/index.astro. - Labels/i18n come from
src/locales/home.tsunder thebuildersection. - Runs fully client-side; no server or Python environment required.