Skip to content

Commit 5d4acec

Browse files
authored
Improve Documentation (#291)
* Move favicon and logo to where `DocumenterVitepress` expects them * modify nav-bar and add `VersionPicker` * modify documentation
1 parent 436ca3d commit 5d4acec

File tree

14 files changed

+127
-34
lines changed

14 files changed

+127
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
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

docs/make.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ DocMeta.setdocmeta!(QuantumToolbox, :DocTestSetup, :(using QuantumToolbox); recu
1010

1111
const DRAFT = false # set `true` to disable cell evaluation
1212

13-
bib = CitationBibliography(joinpath(@__DIR__, "src", "bibliography.bib"), style=:authoryear)
13+
bib = CitationBibliography(
14+
joinpath(@__DIR__, "src", "resources", "bibliography.bib"),
15+
style=:authoryear,
16+
)
1417

1518
const PAGES = [
1619
"Home" => "index.md",
1720
"Getting Started" => [
18-
"Introduction" => "getting_started.md",
21+
"Brief Example" => "getting_started.md",
1922
"Key differences from QuTiP" => "qutip_differences.md",
2023
"The Importance of Type-Stability" => "type_stability.md",
2124
# "Cite QuantumToolbox.jl" => "cite.md",
@@ -51,9 +54,11 @@ const PAGES = [
5154
"tutorials/logo.md",
5255
],
5356
],
54-
"API" => "api.md",
55-
"Bibliography" => "bibliography.md",
56-
# "Change Log" => "changelog.md",
57+
"Resources" => [
58+
"API" => "resources/api.md",
59+
# "Change Log" => "resources/changelog.md",
60+
"Bibliography" => "resources/bibliography.md",
61+
],
5762
]
5863

5964
makedocs(;

docs/src/.vitepress/config.mts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
33
import mathjax3 from "markdown-it-mathjax3";
44
import footnote from "markdown-it-footnote";
55

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+
618
// https://vitepress.dev/reference/site-config
719
export default defineConfig({
820
base: 'REPLACE_ME_DOCUMENTER_VITEPRESS',// TODO: replace this in makedocs!
@@ -35,7 +47,7 @@ export default defineConfig({
3547
detailedView: true
3648
}
3749
},
38-
nav: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
50+
nav,
3951
sidebar: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
4052
editLink: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
4153
socialLinks: [
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!-- Adapted from https://github.com/MakieOrg/Makie.jl/blob/master/docs/src/.vitepress/theme/VersionPicker.vue -->
2+
3+
<script setup lang="ts">
4+
import { computed, ref, onMounted } from 'vue'
5+
import { useRoute } from 'vitepress'
6+
import VPNavBarMenuGroup from 'vitepress/dist/client/theme-default/components/VPNavBarMenuGroup.vue'
7+
import VPNavScreenMenuGroup from 'vitepress/dist/client/theme-default/components/VPNavScreenMenuGroup.vue'
8+
9+
const props = defineProps<{
10+
screenMenu?: boolean
11+
}>()
12+
13+
const route = useRoute()
14+
15+
const versions = ref([]);
16+
const currentVersion = ref('Versions');
17+
18+
const waitForGlobalDocumenterVars = () => {
19+
return new Promise((resolve) => {
20+
const checkInterval = setInterval(() => {
21+
if (window.DOC_VERSIONS && window.DOCUMENTER_CURRENT_VERSION) {
22+
clearInterval(checkInterval);
23+
resolve({
24+
versions: window.DOC_VERSIONS,
25+
currentVersion: window.DOCUMENTER_CURRENT_VERSION
26+
});
27+
}
28+
}, 100); // Check every 100ms
29+
});
30+
};
31+
32+
onMounted(async () => {
33+
const globalvars = await waitForGlobalDocumenterVars();
34+
versions.value = globalvars.versions.map((v) => {
35+
return {text: v, link: `${window.location.origin}/${v}/`}
36+
});
37+
currentVersion.value = globalvars.currentVersion;
38+
});
39+
40+
</script>
41+
42+
<template>
43+
<VPNavBarMenuGroup
44+
v-if="!screenMenu"
45+
:item="{ text: currentVersion, items: versions }"
46+
class="VPVersionPicker"
47+
/>
48+
<VPNavScreenMenuGroup
49+
v-else
50+
:text="currentVersion"
51+
:items="versions"
52+
class="VPVersionPicker"
53+
/>
54+
</template>
55+
56+
<style scoped>
57+
.VPVersionPicker :deep(button .text) {
58+
color: var(--vp-c-text-1) !important;
59+
}
60+
61+
.VPVersionPicker:hover :deep(button .text) {
62+
color: var(--vp-c-text-2) !important;
63+
}
64+
</style>

docs/src/.vitepress/theme/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { h } from 'vue'
33
import type { Theme } from 'vitepress'
44
import DefaultTheme from 'vitepress/theme'
5+
import VersionPicker from "./VersionPicker.vue"
56

67
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
78
import './style.css'
@@ -14,6 +15,7 @@ export default {
1415
})
1516
},
1617
enhanceApp({ app, router, siteData }) {
17-
enhanceAppWithTabs(app)
18+
enhanceAppWithTabs(app);
19+
app.component('VersionPicker', VersionPicker);
1820
}
1921
} satisfies Theme

docs/src/.vitepress/theme/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ code {
9595
#9558B2 30%,
9696
#CB3C33);
9797

98+
--vp-home-hero-image-background-image: none; /* remove the blur background */
99+
/* (default setting)
98100
--vp-home-hero-image-background-image: linear-gradient(-45deg,
99101
#9558B2 30%,
100102
#389826 30%,
101103
#CB3C33);
104+
*/
102105
--vp-home-hero-image-filter: blur(40px);
103106
}
104107

docs/src/getting_started.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,6 @@
22
CurrentModule = QuantumToolbox
33
```
44

5-
## [Installation](@id doc:Installation)
6-
7-
!!! note "Requirements"
8-
`QuantumToolbox.jl` requires `Julia 1.10+`.
9-
10-
To install `QuantumToolbox.jl`, run the following commands inside Julia's interactive session (also known as REPL):
11-
```julia
12-
using Pkg
13-
Pkg.add("QuantumToolbox")
14-
```
15-
Alternatively, this can also be done in Julia's [Pkg REPL](https://julialang.github.io/Pkg.jl/v1/getting-started/) by pressing the key `]` in the REPL to use the package mode, and then type the following command:
16-
```julia-REPL
17-
(1.10) pkg> add QuantumToolbox
18-
```
19-
More information about `Julia`'s package manager can be found at [`Pkg.jl`](https://julialang.github.io/Pkg.jl/v1/).
20-
21-
To load the package and check the version information, use either [`QuantumToolbox.versioninfo()`](@ref) or [`QuantumToolbox.about()`](@ref), namely
22-
```julia
23-
using QuantumToolbox
24-
QuantumToolbox.versioninfo()
25-
QuantumToolbox.about()
26-
```
27-
285
## Brief Example
296

307
We now provide a brief example to demonstrate the similarity between [QuantumToolbox.jl](https://github.com/qutip/QuantumToolbox.jl) and [QuTiP](https://github.com/qutip/qutip).

docs/src/index.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ hero:
1313
- theme: brand
1414
text: Getting Started
1515
link: /getting_started
16+
- theme: alt
17+
text: Users Guide
18+
link: /users_guide/QuantumObject/QuantumObject
1619
- theme: alt
1720
text: View on Github
1821
link: https://github.com/qutip/QuantumToolbox.jl
@@ -37,6 +40,31 @@ features:
3740
---
3841
```
3942

43+
# [Introduction](@id doc:Introduction)
44+
4045
[QuantumToolbox.jl](https://github.com/qutip/QuantumToolbox.jl) is a cutting-edge Julia package designed for quantum physics simulations, closely emulating the popular Python [QuTiP](https://github.com/qutip/qutip) package. It uniquely combines the simplicity and power of Julia with advanced features like GPU acceleration and distributed computing, making simulation of quantum systems more accessible and efficient. Taking advantage of the Julia language features (like multiple dispatch and metaprogramming), QuantumToolbox.jl is designed to be easily extendable, allowing users to build upon the existing functionalities.
4146

4247
*__With this package, moving from Python to Julia for quantum physics simulations has never been easier__*, due to the similar syntax and functionalities.
48+
49+
# [Installation](@id doc:Installation)
50+
51+
!!! note "Requirements"
52+
`QuantumToolbox.jl` requires `Julia 1.10+`.
53+
54+
To install `QuantumToolbox.jl`, run the following commands inside Julia's interactive session (also known as REPL):
55+
```julia
56+
using Pkg
57+
Pkg.add("QuantumToolbox")
58+
```
59+
Alternatively, this can also be done in Julia's [Pkg REPL](https://julialang.github.io/Pkg.jl/v1/getting-started/) by pressing the key `]` in the REPL to use the package mode, and then type the following command:
60+
```julia-REPL
61+
(1.10) pkg> add QuantumToolbox
62+
```
63+
More information about `Julia`'s package manager can be found at [`Pkg.jl`](https://julialang.github.io/Pkg.jl/v1/).
64+
65+
To load the package and check the version information, use either [`QuantumToolbox.versioninfo()`](@ref) or [`QuantumToolbox.about()`](@ref), namely
66+
```julia
67+
using QuantumToolbox
68+
QuantumToolbox.versioninfo()
69+
QuantumToolbox.about()
70+
```
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)