Skip to content

Commit 088d2cb

Browse files
author
Documenter.jl
committed
build based on d2e9dc7
1 parent e4f2eb1 commit 088d2cb

351 files changed

Lines changed: 13787 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
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+
import { transformerMetaWordHighlight } from '@shikijs/transformers';
6+
7+
const baseTemp = {
8+
base: '/HarmonicBalance.jl/previews/PR491/',// TODO: replace this in makedocs!
9+
}
10+
11+
const navTemp = {
12+
nav: [
13+
{ text: 'Home', link: '/index' },
14+
{ text: 'Getting Started', link: '/introduction/index' },
15+
{ text: 'Theoretical Background', collapsed: false, items: [
16+
{ text: 'Floquet expansions', link: '/background/harmonic_balance' },
17+
{ text: 'Stability and Linear Response', link: '/background/stability_response' },
18+
{ text: 'Limit Cycles', link: '/background/limit_cycles' }]
19+
},
20+
{ text: 'Tutorials', collapsed: false, items: [
21+
{ text: 'Steady States', link: '/tutorials/steady_states' },
22+
{ text: 'Classifying Solutions', link: '/tutorials/classification' },
23+
{ text: 'Linear Response', link: '/tutorials/linear_response' },
24+
{ text: 'Transient Dynamics', link: '/tutorials/time_dependent' },
25+
{ text: 'Limit Cycles', link: '/tutorials/limit_cycles' },
26+
{ text: 'Examples', collapsed: false, items: [
27+
{ text: 'Wave Mixing', link: '/examples/wave_mixing' },
28+
{ text: 'Parametric Three Wave Mixing', link: '/examples/parametric_via_three_wave_mixing' },
29+
{ text: 'Parametric Oscillator', link: '/examples/parametron' },
30+
{ text: 'State Dependent Perturbation', link: '/examples/state_dependent_perturbation' },
31+
{ text: 'Ab Initio Noise spectrum', link: '/examples/ab_initio_noise' },
32+
{ text: 'Adiabatic sweep', link: '/examples/steady_state_sweep' },
33+
{ text: 'Quantum Cumulants', link: '/examples/cumulants_KPO' },
34+
{ text: 'KB vs HB method', link: '/examples/harmonic_oscillator_KB_vs_HB' },
35+
{ text: 'Forward Transmission', link: '/examples/forward_transmission' }]
36+
}]
37+
},
38+
{ text: 'Resources', collapsed: false, items: [
39+
{ text: 'API', link: '/manual/API' },
40+
{ text: 'Bibliography', link: '/introduction/citation' },
41+
{ text: 'Manual', collapsed: false, items: [
42+
{ text: 'Entering Equations of Motion', link: '/manual/entering_eom' },
43+
{ text: 'Computing Effective System', link: '/manual/extracting_harmonics' },
44+
{ text: 'Computing Steady States', link: '/manual/methods' },
45+
{ text: 'Extract the Steady States', link: '/manual/analyse_solutions' },
46+
{ text: 'Plotting', link: '/manual/plotting' },
47+
{ text: 'Time Evolution', link: '/manual/time_dependent' },
48+
{ text: 'Linear Response', link: '/manual/linear_response' },
49+
{ text: 'SciML Extension', link: '/manual/SciMLExt' }]
50+
}]
51+
}
52+
]
53+
,
54+
}
55+
56+
const nav = [
57+
...navTemp.nav,
58+
{
59+
component: 'VersionPicker'
60+
}
61+
]
62+
63+
// https://vitepress.dev/reference/site-config
64+
export default defineConfig({
65+
base: baseTemp.base,
66+
title: 'HarmonicBalance.jl',
67+
description: 'Documentation for HarmonicBalance.jl',
68+
cleanUrls: true,
69+
outDir: '../1', // This is required for MarkdownVitepress to work correctly...
70+
head: [
71+
[
72+
"script",
73+
{ async: "", src: "https://www.googletagmanager.com/gtag/js?id=G-RE962QZ6DQ" },
74+
],
75+
[
76+
"script",
77+
{},
78+
`window.dataLayer = window.dataLayer || [];
79+
function gtag(){dataLayer.push(arguments);}
80+
gtag('js', new Date());
81+
gtag('config', 'G-RE962QZ6DQ');`,
82+
],
83+
['link', { rel: 'icon', href: '/HarmonicBalance.jl/dev/favicon.ico' }],
84+
['link', { rel: 'icon', href: `${baseTemp.base}favicon.ico` }],
85+
['link', { rel: 'manifest', href: '/site.webmanifest' }],
86+
87+
['script', { src: `/HarmonicBalance.jl/versions.js` }],
88+
['script', { src: `${baseTemp.base}siteinfo.js` }]
89+
],
90+
ignoreDeadLinks: true,
91+
92+
markdown: {
93+
math: true,
94+
95+
// options for @mdit-vue/plugin-toc
96+
// https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-toc#options
97+
toc: { level: [2, 3, 4] }, // for API page, triggered by: [[toc]]
98+
99+
config(md) {
100+
md.use(tabsMarkdownPlugin),
101+
md.use(mathjax3),
102+
md.use(footnote)
103+
},
104+
theme: {
105+
light: "github-light",
106+
dark: "github-dark"
107+
}
108+
},
109+
themeConfig: {
110+
outline: 'deep',
111+
logo: { src: '/logo.png', width: 24, height: 24},
112+
search: {
113+
provider: 'local',
114+
options: {
115+
detailedView: true
116+
}
117+
},
118+
nav,
119+
sidebar: [
120+
{ text: 'Home', link: '/index' },
121+
{ text: 'Getting Started', link: '/introduction/index' },
122+
{ text: 'Theoretical Background', collapsed: false, items: [
123+
{ text: 'Floquet expansions', link: '/background/harmonic_balance' },
124+
{ text: 'Stability and Linear Response', link: '/background/stability_response' },
125+
{ text: 'Limit Cycles', link: '/background/limit_cycles' }]
126+
},
127+
{ text: 'Tutorials', collapsed: false, items: [
128+
{ text: 'Steady States', link: '/tutorials/steady_states' },
129+
{ text: 'Classifying Solutions', link: '/tutorials/classification' },
130+
{ text: 'Linear Response', link: '/tutorials/linear_response' },
131+
{ text: 'Transient Dynamics', link: '/tutorials/time_dependent' },
132+
{ text: 'Limit Cycles', link: '/tutorials/limit_cycles' },
133+
{ text: 'Examples', collapsed: false, items: [
134+
{ text: 'Wave Mixing', link: '/examples/wave_mixing' },
135+
{ text: 'Parametric Three Wave Mixing', link: '/examples/parametric_via_three_wave_mixing' },
136+
{ text: 'Parametric Oscillator', link: '/examples/parametron' },
137+
{ text: 'State Dependent Perturbation', link: '/examples/state_dependent_perturbation' },
138+
{ text: 'Ab Initio Noise spectrum', link: '/examples/ab_initio_noise' },
139+
{ text: 'Adiabatic sweep', link: '/examples/steady_state_sweep' },
140+
{ text: 'Quantum Cumulants', link: '/examples/cumulants_KPO' },
141+
{ text: 'KB vs HB method', link: '/examples/harmonic_oscillator_KB_vs_HB' },
142+
{ text: 'Forward Transmission', link: '/examples/forward_transmission' }]
143+
}]
144+
},
145+
{ text: 'Resources', collapsed: false, items: [
146+
{ text: 'API', link: '/manual/API' },
147+
{ text: 'Bibliography', link: '/introduction/citation' },
148+
{ text: 'Manual', collapsed: false, items: [
149+
{ text: 'Entering Equations of Motion', link: '/manual/entering_eom' },
150+
{ text: 'Computing Effective System', link: '/manual/extracting_harmonics' },
151+
{ text: 'Computing Steady States', link: '/manual/methods' },
152+
{ text: 'Extract the Steady States', link: '/manual/analyse_solutions' },
153+
{ text: 'Plotting', link: '/manual/plotting' },
154+
{ text: 'Time Evolution', link: '/manual/time_dependent' },
155+
{ text: 'Linear Response', link: '/manual/linear_response' },
156+
{ text: 'SciML Extension', link: '/manual/SciMLExt' }]
157+
}]
158+
}
159+
]
160+
,
161+
editLink: { pattern: "https://github.com/QuantumEngineeredSystems/HarmonicBalance.jl/edit/master/docs/src/:path" },
162+
socialLinks: [
163+
{ icon: 'github', link: 'https://github.com/QuantumEngineeredSystems/HarmonicBalance.jl' },
164+
{ icon: 'twitter', link: 'https://x.com/Zilberberg_Phys' },
165+
],
166+
167+
footer: {
168+
message: 'Made with <a href="https://documenter.juliadocs.org/" 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/" target="_blank"><strong>DocumenterVitepress.jl</strong>',
169+
copyright: `© Copyright ${new Date().getUTCFullYear()}. Released under the MIT License.`
170+
},
171+
}
172+
})
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// adapter from https://github.com/orgs/vuepress-theme-hope/discussions/5178#discussioncomment-15642629
2+
// mathjax-plugin.ts
3+
// @ts-ignore
4+
import MathJax from '@mathjax/src'
5+
import type { Plugin as VitePlugin } from 'vite'
6+
import type MarkdownIt from 'markdown-it'
7+
import { tex as mdTex } from '@mdit/plugin-tex'
8+
9+
const mathjaxStyleModuleID = 'virtual:mathjax-styles.css'
10+
11+
interface MathJaxOptions {
12+
font?: string
13+
}
14+
15+
async function initializeMathJax(options: MathJaxOptions = {}) {
16+
const font = options.font || 'mathjax-newcm'
17+
18+
const config: any = {
19+
loader: {
20+
load: [
21+
'input/tex',
22+
'output/svg',
23+
'[tex]/boldsymbol',
24+
'[tex]/braket',
25+
'[tex]/mathtools',
26+
],
27+
paths: { mathjax: '@mathjax/src/bundle' },
28+
},
29+
tex: {
30+
tags: 'ams',
31+
packages: {
32+
'[+]': ['boldsymbol', 'braket', 'mathtools'],
33+
},
34+
},
35+
output: {
36+
font,
37+
displayOverflow: 'linebreak',
38+
mtextInheritFont: true,
39+
},
40+
svg: {
41+
fontCache: 'none', // critical: avoids async font loading
42+
},
43+
}
44+
45+
await MathJax.init(config)
46+
await MathJax.startup.document.outputJax.font.loadDynamicFiles()
47+
}
48+
49+
export function mathjaxPlugin(options: MathJaxOptions = {}) {
50+
let adaptor: any
51+
let initialized = false
52+
53+
async function ensureInitialized() {
54+
if (!initialized) {
55+
await initializeMathJax(options)
56+
adaptor = MathJax.startup.adaptor
57+
initialized = true
58+
}
59+
}
60+
61+
function renderMath(content: string, displayMode: boolean): string {
62+
if (!initialized) {
63+
throw new Error('MathJax not initialized')
64+
}
65+
66+
const node = MathJax.tex2svg(content, { display: displayMode })
67+
68+
// Prevent Vue from touching MathJax output
69+
adaptor.setAttribute(node, 'v-pre', '')
70+
71+
let html = adaptor.outerHTML(node)
72+
73+
// Preserve spaces inside mjx-break (SVG only)
74+
html = html.replace(
75+
/<mjx-break(.*?)>(.*?)<\/mjx-break>/g,
76+
(_: string, attr: string, inner: string) =>
77+
`<mjx-break${attr}>${inner.replace(/ /g, '&nbsp;')}</mjx-break>`,
78+
)
79+
80+
// Wrap only display equations (not inline math)
81+
html = html.replace(
82+
/(<mjx-container[^>]*display="true"[^>]*>)([\s\S]*?)(<\/mjx-container>)/,
83+
'<div class="mjx-scroll-wrapper">$1$2$3</div>'
84+
)
85+
86+
return html
87+
}
88+
89+
function getMathJaxStyles(): string {
90+
return initialized
91+
? adaptor.textContent(MathJax.svgStylesheet()) || ''
92+
: ''
93+
}
94+
95+
function resetMathJax(): void {
96+
if (!initialized) return
97+
MathJax.texReset()
98+
MathJax.typesetClear()
99+
}
100+
101+
function viteMathJax(): VitePlugin {
102+
const virtualModuleID = '\0' + mathjaxStyleModuleID
103+
104+
return {
105+
name: 'mathjax-styles',
106+
107+
resolveId(id) {
108+
if (id === mathjaxStyleModuleID) {
109+
return virtualModuleID
110+
}
111+
},
112+
113+
async load(id) {
114+
if (id === virtualModuleID) {
115+
await ensureInitialized()
116+
return getMathJaxStyles()
117+
}
118+
},
119+
}
120+
}
121+
122+
function mdMathJax(md: MarkdownIt): void {
123+
mdTex(md, {
124+
render: renderMath,
125+
})
126+
127+
const orig = md.render
128+
md.render = function (...args) {
129+
resetMathJax()
130+
return orig.apply(this, args)
131+
}
132+
}
133+
134+
const init = ensureInitialized()
135+
136+
return {
137+
vitePlugin: viteMathJax(),
138+
markdownConfig: mdMathJax,
139+
styleModuleID: mathjaxStyleModuleID,
140+
init,
141+
}
142+
}

0 commit comments

Comments
 (0)