Skip to content

Commit d0dcc78

Browse files
authored
[Doc] Update to DocumenterVitepress.jl v0.2 (#467)
1 parent e4ff0f7 commit d0dcc78

File tree

15 files changed

+240
-458
lines changed

15 files changed

+240
-458
lines changed

.github/workflows/documentation.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ on:
2121
- synchronize
2222
- ready_for_review
2323

24+
# Allows you to run this workflow manually from the Actions tab
25+
workflow_dispatch:
26+
2427
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
2528
permissions:
2629
contents: write

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ docs:
1919
${JULIA} --project=docs docs/make.jl
2020

2121
vitepress:
22-
npm --prefix docs i
2322
npm --prefix docs run docs:dev
2423

2524
all: setup format changelog test docs vitepress

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
66
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
77
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
88
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
9+
10+
[compat]
11+
DocumenterVitepress = "0.2"

docs/README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
## Working Directory
44
All the commands should be run under the root folder of the package: `/path/to/QuantumToolbox.jl/`
55

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

88
## Method 1: Run with `make` command
99
Run the following command to instantiate and build the documentation:
10+
> [!NOTE]
11+
> You need to install `Node.js` and `npm` first.
1012
```shell
1113
make docs
1214
```
1315

14-
Run the following command to start Vitepress site of documentation:
15-
> [!NOTE]
16-
> You need to install `Node.js` and `npm` first.
16+
Run the following command to start a local Vitepress site:
1717
```shell
1818
make vitepress
1919
```
20+
This will start a local Vitepress site of documentation at [http://localhost:5173](http://localhost:5173) in your computer.
2021

2122
## Method 2: Run commands manually
2223

@@ -29,20 +30,15 @@ julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.in
2930
3031
### Build Documentation
3132
Run the following command:
32-
```shell
33-
julia --project=docs docs/make.jl
34-
```
35-
36-
### Start a local Vitepress site
3733
> [!NOTE]
3834
> You need to install `Node.js` and `npm` first.
39-
40-
Install `npm` dependencies:
4135
```shell
42-
npm --prefix docs i
36+
julia --project=docs docs/make.jl
4337
```
4438

39+
### Start a local Vitepress site
4540
Run the following command:
4641
```shell
4742
npm --prefix docs run docs:dev
48-
```
43+
```
44+
This will start a local Vitepress site of documentation at [http://localhost:5173](http://localhost:5173) in your computer.

docs/make.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ const PAGES = [
4646
],
4747
"Users Guide" => [
4848
"Basic Operations on Quantum Objects" => [
49-
"users_guide/QuantumObject/QuantumObject.md",
50-
"users_guide/QuantumObject/QuantumObject_functions.md",
49+
"Quantum Objects (Qobj)" => "users_guide/QuantumObject/QuantumObject.md",
50+
"Functions operating on Qobj" => "users_guide/QuantumObject/QuantumObject_functions.md",
5151
],
5252
"Manipulating States and Operators" => "users_guide/states_and_operators.md",
5353
"Tensor Products and Partial Traces" => "users_guide/tensor.md",
@@ -66,8 +66,8 @@ const PAGES = [
6666
"Two-time correlation functions" => "users_guide/two_time_corr_func.md",
6767
"QuantumToolbox Settings" => "users_guide/settings.md",
6868
"Extensions" => [
69-
"users_guide/extensions/cuda.md",
70-
"users_guide/extensions/cairomakie.md",
69+
"Extension for CUDA.jl" => "users_guide/extensions/cuda.md",
70+
"Extension for the Makie.jl ecosystem" => "users_guide/extensions/cairomakie.md",
7171
],
7272
],
7373
"Resources" => [
@@ -90,15 +90,17 @@ makedocs(;
9090
pages = PAGES,
9191
format = DocumenterVitepress.MarkdownVitepress(
9292
repo = "github.com/qutip/QuantumToolbox.jl",
93+
devbranch = "main",
94+
devurl = "dev",
9395
),
9496
draft = DRAFT,
9597
doctest = DOCTEST,
9698
plugins = [bib],
9799
)
98100

99-
deploydocs(;
101+
DocumenterVitepress.deploydocs(;
100102
repo = "github.com/qutip/QuantumToolbox.jl",
101-
target = "build", # this is where Vitepress stores its output
103+
target = joinpath(@__DIR__, "build"),
102104
devbranch = "main",
103105
branch = "gh-pages",
104106
push_preview = true,

docs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"docs:preview": "vitepress preview build/.documenter"
66
},
77
"dependencies": {
8-
"@shikijs/transformers": "^1.1.7",
8+
"@nolebase/vitepress-plugin-enhanced-readabilities": "^2.14.0",
99
"markdown-it": "^14.1.0",
1010
"markdown-it-footnote": "^4.0.0",
1111
"markdown-it-mathjax3": "^4.3.2",
12-
"vitepress": "^1.1.4",
13-
"vitepress-plugin-tabs": "^0.5.0"
12+
"vitepress": "^1.6.3",
13+
"vitepress-plugin-tabs": "^0.6.0"
1414
}
1515
}

docs/src/.vitepress/config.mts

Lines changed: 78 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ import { defineConfig } from 'vitepress'
22
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
33
import mathjax3 from "markdown-it-mathjax3";
44
import footnote from "markdown-it-footnote";
5+
import path from 'path'
6+
7+
function getBaseRepository(base: string): string {
8+
if (!base || base === '/') return '/';
9+
const parts = base.split('/').filter(Boolean);
10+
return parts.length > 0 ? `/${parts[0]}/` : '/';
11+
}
512

613
const baseTemp = {
7-
base: 'REPLACE_ME_DOCUMENTER_VITEPRESS',// TODO: replace this in makedocs!
14+
base: 'REPLACE_ME_DOCUMENTER_VITEPRESS',// TODO: replace this in makedocs!
815
}
916

1017
const navTemp = {
@@ -22,55 +29,78 @@ const nav = [
2229

2330
// https://vitepress.dev/reference/site-config
2431
export default defineConfig({
25-
base: baseTemp.base,
26-
title: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
27-
description: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
28-
lastUpdated: true,
29-
cleanUrls: true,
30-
outDir: 'REPLACE_ME_DOCUMENTER_VITEPRESS', // This is required for MarkdownVitepress to work correctly...
31-
head: [
32-
['link', { rel: 'icon', href: '/QuantumToolbox.jl/favicon.ico' }],
33-
['link', { rel: 'icon', href: 'REPLACE_ME_DOCUMENTER_VITEPRESS_FAVICON' }],
34-
['script', {src: `/QuantumToolbox.jl/versions.js`}],
35-
['script', {src: `${baseTemp.base}siteinfo.js`}]
36-
],
37-
ignoreDeadLinks: true,
38-
39-
markdown: {
40-
math: true,
32+
base: 'REPLACE_ME_DOCUMENTER_VITEPRESS',// TODO: replace this in makedocs!
33+
title: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
34+
description: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
35+
lastUpdated: true,
36+
cleanUrls: true,
37+
outDir: 'REPLACE_ME_DOCUMENTER_VITEPRESS', // This is required for MarkdownVitepress to work correctly...
38+
head: [
39+
['link', { rel: 'icon', href: '/QuantumToolbox.jl/favicon.ico' }],
40+
['script', {src: `${getBaseRepository(baseTemp.base)}versions.js`}],
41+
// ['script', {src: '/versions.js'], for custom domains, I guess if deploy_url is available.
42+
['script', {src: `${baseTemp.base}siteinfo.js`}]
43+
],
44+
45+
vite: {
46+
define: {
47+
__DEPLOY_ABSPATH__: JSON.stringify('REPLACE_ME_DOCUMENTER_VITEPRESS_DEPLOY_ABSPATH'),
48+
},
49+
resolve: {
50+
alias: {
51+
'@': path.resolve(__dirname, '../components')
52+
}
53+
},
54+
optimizeDeps: {
55+
exclude: [
56+
'@nolebase/vitepress-plugin-enhanced-readabilities/client',
57+
'vitepress',
58+
'@nolebase/ui',
59+
],
60+
},
61+
ssr: {
62+
noExternal: [
63+
// If there are other packages that need to be processed by Vite, you can add them here.
64+
'@nolebase/vitepress-plugin-enhanced-readabilities',
65+
'@nolebase/ui',
66+
],
67+
},
68+
},
69+
markdown: {
70+
math: true,
4171

42-
// options for @mdit-vue/plugin-toc
43-
// https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-toc#options
44-
toc: { level: [2, 3, 4] }, // for API page, triggered by: [[toc]]
72+
// options for @mdit-vue/plugin-toc
73+
// https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-toc#options
74+
toc: { level: [2, 3, 4] }, // for API page, triggered by: [[toc]]
4575

46-
config(md) {
47-
md.use(tabsMarkdownPlugin),
48-
md.use(mathjax3),
49-
md.use(footnote)
50-
},
51-
theme: {
52-
light: "github-light",
53-
dark: "github-dark"
54-
}
76+
config(md) {
77+
md.use(tabsMarkdownPlugin),
78+
md.use(mathjax3),
79+
md.use(footnote)
5580
},
56-
themeConfig: {
57-
outline: 'deep',
58-
logo: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
59-
search: {
60-
provider: 'local',
61-
options: {
62-
detailedView: true
63-
}
64-
},
65-
nav,
66-
sidebar: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
67-
editLink: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
68-
socialLinks: [
69-
{ icon: 'github', link: 'REPLACE_ME_DOCUMENTER_VITEPRESS' }
70-
],
71-
footer: {
72-
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>',
73-
copyright: `© Copyright ${new Date().getUTCFullYear()} <a href="https://qutip.org/" target="_blank"><strong>QuTiP.org</strong></a>.`
74-
}
81+
theme: {
82+
light: "github-light",
83+
dark: "github-dark"
7584
}
85+
},
86+
themeConfig: {
87+
outline: 'deep',
88+
logo: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
89+
search: {
90+
provider: 'local',
91+
options: {
92+
detailedView: true
93+
}
94+
},
95+
nav,
96+
sidebar: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
97+
editLink: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
98+
socialLinks: [
99+
{ icon: 'github', link: 'REPLACE_ME_DOCUMENTER_VITEPRESS' }
100+
],
101+
footer: {
102+
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>',
103+
copyright: `© Copyright ${new Date().getUTCFullYear()} <a href="https://qutip.org/" target="_blank"><strong>QuTiP.org</strong></a>.`
104+
}
105+
}
76106
})

0 commit comments

Comments
 (0)