Skip to content

Commit a483e6f

Browse files
authored
Vitepress documentation (#288)
2 parents ca872f6 + cad8e14 commit a483e6f

26 files changed

+711
-186
lines changed

.github/workflows/documentation.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,23 @@ on:
2121
- synchronize
2222
- ready_for_review
2323

24+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
25+
permissions:
26+
contents: write
27+
pages: write
28+
id-token: write
29+
statuses: write
30+
31+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
32+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
33+
concurrency:
34+
group: pages
35+
cancel-in-progress: false
36+
2437
jobs:
38+
# Build job
2539
build:
2640
runs-on: ubuntu-latest
27-
permissions:
28-
contents: write
29-
statuses: write
3041
if: ${{ !github.event.pull_request.draft }}
3142
steps:
3243
- uses: actions/checkout@v4
@@ -37,11 +48,8 @@ jobs:
3748
- uses: julia-actions/julia-buildpkg@v1
3849
- uses: julia-actions/julia-docdeploy@v1
3950
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
42-
- run: |
43-
julia --project=docs -e '
44-
using Documenter: DocMeta, doctest
45-
using QuantumToolbox
46-
DocMeta.setdocmeta!(QuantumToolbox, :DocTestSetup, :(using QuantumToolbox); recursive=true)
47-
doctest(QuantumToolbox)'
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
52+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
53+
JULIA_DEBUG: "Documenter"
54+
DATADEPS_ALWAYS_ACCEPT: true
55+
# GKSwstype: "100" # for Plots.jl plots (if you have them)

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*.jl.cov
55
*.jl.mem
66
Manifest.toml
7-
docs/build/
87

98
.vscode
10-
*.json
9+
10+
benchmarks/benchmarks_output.json
1111

1212
.ipynb_checkpoints
1313
*.ipynb

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ docs:
1212
${JULIA} --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
1313
${JULIA} --project=docs docs/make.jl
1414

15-
all: format test docs
15+
vitepress:
16+
npm --prefix docs i
17+
npm --prefix docs run docs:dev
18+
19+
all: format test docs vitepress
1620

1721
help:
1822
@echo "The following make commands are available:"
1923
@echo " - make format: format codes with JuliaFormatter"
2024
@echo " - make test: run the tests"
2125
@echo " - make docs: instantiate and build the documentation"
26+
@echo " - make vitepress: start Vitepress site of documentation"
2227
@echo " - make all: run every commands in the above order"
2328

24-
.PHONY: default format test docs all help
29+
.PHONY: default format test docs vitepress all help

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- Logo -->
22
<div align="center">
3-
<img src="./docs/src/assets/logo.png" alt="QuantumToolbox.jl logo" width="150">
3+
<img src="./docs/src/public/logo.png" alt="QuantumToolbox.jl logo" width="150">
44
</div>
55

66
# QuantumToolbox.jl
@@ -65,7 +65,7 @@ QuantumToolbox.jl is equipped with a robust set of features:
6565

6666
- **Quantum State and Operator Manipulation:** Easily handle quantum states and operators with a rich set of tools, with the same functionalities as QuTiP.
6767
- **Dynamical Evolution:** Advanced solvers for time evolution of quantum systems, thanks to the powerful [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl) package.
68-
- **GPU Computing:** Leverage GPU resources for high-performance computing. For example, you run the master equation directly on the GPU with the same syntax as the CPU case.
68+
- **GPU Computing:** Leverage GPU resources for high-performance computing. Simulate quantum dynamics directly on the GPU with the same syntax as the CPU case.
6969
- **Distributed Computing:** Distribute the computation over multiple nodes (e.g., a cluster). For example, you can run hundreds of quantum trajectories in parallel on a cluster, with, again, the same syntax as the simple case.
7070
- **Easy Extension:** Easily extend the package, taking advantage of the Julia language features, like multiple dispatch and metaprogramming.
7171

docs/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/
2+
node_modules/
3+
package-lock.json
4+
Manifest.toml

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
33
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
44
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
55
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
6+
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
67
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"

docs/README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
# How to build documentation locally ?
1+
# How to build documentation and start Vitepress site locally ?
22

33
## Working Directory
44
All the commands should be run under the root folder of the package: `/path/to/QuantumToolbox.jl/`
55

66
The document pages will be generated in the directory: `/path/to/QuantumToolbox.jl/docs/build/` (which is ignored by git).
77

88
## Method 1: Run with `make` command
9-
Run the following command:
9+
Run the following command to instantiate and build the documentation:
1010
```shell
1111
make docs
1212
```
1313

14-
## Method 2: Run `julia` command manually
14+
Run the following command to start Vitepress site of documentation:
15+
> [!NOTE]
16+
> You need to install `Node.js` and `npm` first.
17+
```shell
18+
make vitepress
19+
```
20+
21+
## Method 2: Run commands manually
1522

1623
### Build Pkg
1724
Run the following command:
@@ -25,3 +32,17 @@ Run the following command:
2532
```shell
2633
julia --project=docs docs/make.jl
2734
```
35+
36+
### Start a local Vitepress site
37+
> [!NOTE]
38+
> You need to install `Node.js` and `npm` first.
39+
40+
Install `npm` dependencies:
41+
```shell
42+
npm --prefix docs i
43+
```
44+
45+
Run the following command:
46+
```shell
47+
npm --prefix docs run docs:dev
48+
```

docs/make.jl

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,22 @@
33

44
using QuantumToolbox
55
using Documenter
6+
using DocumenterVitepress
67
using DocumenterCitations
78

89
DocMeta.setdocmeta!(QuantumToolbox, :DocTestSetup, :(using QuantumToolbox); recursive = true)
910

1011
const DRAFT = false # set `true` to disable cell evaluation
1112

12-
bib = CitationBibliography(joinpath(@__DIR__, "src", "bibliography.bib"), style=:authoryear)
13-
14-
const MathEngine = MathJax3(
15-
Dict(
16-
:loader => Dict("load" => ["[tex]/physics"]),
17-
:tex => Dict(
18-
"inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
19-
"tags" => "ams",
20-
"packages" => ["base", "ams", "autoload", "physics"],
21-
),
22-
)
13+
bib = CitationBibliography(
14+
joinpath(@__DIR__, "src", "resources", "bibliography.bib"),
15+
style=:authoryear,
2316
)
2417

2518
const PAGES = [
19+
"Home" => "index.md",
2620
"Getting Started" => [
27-
"Introduction" => "index.md",
21+
"Brief Example" => "getting_started.md",
2822
"Key differences from QuTiP" => "qutip_differences.md",
2923
"The Importance of Type-Stability" => "type_stability.md",
3024
# "Cite QuantumToolbox.jl" => "cite.md",
@@ -60,9 +54,11 @@ const PAGES = [
6054
"tutorials/logo.md",
6155
],
6256
],
63-
"API" => "api.md",
64-
"Bibliography" => "bibliography.md",
65-
# "Change Log" => "changelog.md",
57+
"Resources" => [
58+
"API" => "resources/api.md",
59+
# "Change Log" => "resources/changelog.md",
60+
"Bibliography" => "resources/bibliography.md",
61+
],
6662
]
6763

6864
makedocs(;
@@ -71,16 +67,17 @@ makedocs(;
7167
repo = Remotes.GitHub("qutip", "QuantumToolbox.jl"),
7268
sitename = "QuantumToolbox.jl",
7369
pages = PAGES,
74-
format = Documenter.HTML(;
75-
prettyurls = get(ENV, "CI", "false") == "true",
76-
canonical = "https://qutip.github.io/QuantumToolbox.jl",
77-
edit_link = "main",
78-
assets = ["assets/favicon.ico"],
79-
mathengine = MathEngine,
80-
size_threshold_ignore = ["api.md"],
70+
format = DocumenterVitepress.MarkdownVitepress(
71+
repo = "github.com/qutip/QuantumToolbox.jl",
8172
),
8273
draft = DRAFT,
8374
plugins = [bib],
8475
)
8576

86-
deploydocs(; repo = "github.com/qutip/QuantumToolbox.jl", devbranch = "main")
77+
deploydocs(;
78+
repo = "github.com/qutip/QuantumToolbox.jl",
79+
target = "build", # this is where Vitepress stores its output
80+
devbranch = "main",
81+
branch = "gh-pages",
82+
push_preview = true,
83+
)

docs/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"scripts": {
3+
"docs:dev": "vitepress dev build/.documenter",
4+
"docs:build": "vitepress build build/.documenter",
5+
"docs:preview": "vitepress preview build/.documenter"
6+
},
7+
"dependencies": {
8+
"@shikijs/transformers": "^1.1.7",
9+
"markdown-it": "^14.1.0",
10+
"markdown-it-footnote": "^4.0.0",
11+
"markdown-it-mathjax3": "^4.3.2",
12+
"vitepress": "^1.1.4",
13+
"vitepress-plugin-tabs": "^0.5.0"
14+
}
15+
}

docs/src/.vitepress/config.mts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { defineConfig } from 'vitepress'
2+
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
3+
import mathjax3 from "markdown-it-mathjax3";
4+
import footnote from "markdown-it-footnote";
5+
6+
const navTemp = {
7+
nav: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
8+
}
9+
10+
const nav = [
11+
...navTemp.nav,
12+
{ text: 'Benchmarks', link: 'https://qutip.org/QuantumToolbox.jl/benchmarks/' },
13+
{
14+
component: 'VersionPicker'
15+
}
16+
]
17+
18+
// https://vitepress.dev/reference/site-config
19+
export default defineConfig({
20+
base: 'REPLACE_ME_DOCUMENTER_VITEPRESS',// TODO: replace this in makedocs!
21+
title: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
22+
description: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
23+
lastUpdated: true,
24+
cleanUrls: true,
25+
outDir: 'REPLACE_ME_DOCUMENTER_VITEPRESS', // This is required for MarkdownVitepress to work correctly...
26+
head: [['link', { rel: 'icon', href: 'REPLACE_ME_DOCUMENTER_VITEPRESS_FAVICON' }]],
27+
ignoreDeadLinks: true,
28+
29+
markdown: {
30+
math: true,
31+
32+
// options for @mdit-vue/plugin-toc
33+
// https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-toc#options
34+
toc: { level: [1, 2] },
35+
36+
config(md) {
37+
md.use(tabsMarkdownPlugin),
38+
md.use(mathjax3),
39+
md.use(footnote)
40+
},
41+
theme: {
42+
light: "github-light",
43+
dark: "github-dark"
44+
}
45+
},
46+
themeConfig: {
47+
outline: 'deep',
48+
logo: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
49+
search: {
50+
provider: 'local',
51+
options: {
52+
detailedView: true
53+
}
54+
},
55+
nav,
56+
sidebar: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
57+
editLink: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
58+
socialLinks: [
59+
{ icon: 'github', link: 'REPLACE_ME_DOCUMENTER_VITEPRESS' }
60+
],
61+
footer: {
62+
message: 'Made with <a href="https://documenter.juliadocs.org/stable/" target="_blank"><strong>Documenter.jl</strong></a>, <a href="https://vitepress.dev" target="_blank"><strong>VitePress</strong></a> and <a href="https://luxdl.github.io/DocumenterVitepress.jl/stable" target="_blank"><strong>DocumenterVitepress.jl</strong></a><br>Released under the BSD 3-Clause License. Powered by the <a href="https://www.julialang.org" target="_blank">Julia Programming Language</a>.<br>',
63+
copyright: `© Copyright ${new Date().getUTCFullYear()} <a href="https://qutip.org/" target="_blank"><strong>QuTiP.org</strong></a>.`
64+
}
65+
}
66+
})

0 commit comments

Comments
 (0)