Skip to content

Commit ed6430e

Browse files
author
Documenter.jl
committed
build based on 2b83c1d
1 parent 8a15523 commit ed6430e

351 files changed

Lines changed: 13806 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/PR479/',// 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: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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+
},
28+
tex: {
29+
tags: 'ams',
30+
packages: {
31+
'[+]': ['boldsymbol', 'braket', 'mathtools'],
32+
},
33+
},
34+
output: {
35+
font,
36+
displayOverflow: 'linebreak',
37+
mtextInheritFont: true,
38+
},
39+
svg: {
40+
fontCache: 'none', // critical: avoids async font loading
41+
},
42+
}
43+
44+
await MathJax.init(config)
45+
46+
const fontData = MathJax.config.svg?.fontData
47+
48+
if (fontData?.dynamicFiles) {
49+
const dynamicFiles = fontData.dynamicFiles
50+
const dynamicPrefix: string =
51+
fontData.OPTIONS?.dynamicPrefix || fontData.options?.dynamicPrefix
52+
53+
if (dynamicPrefix) {
54+
await Promise.all(
55+
Object.keys(dynamicFiles).map(async (name) => {
56+
try {
57+
await import(/* @vite-ignore */ `${dynamicPrefix}/${name}.js`)
58+
dynamicFiles[name]?.setup?.(MathJax.startup.output.font)
59+
} catch {
60+
// Silently ignore missing dynamic files
61+
}
62+
}),
63+
)
64+
}
65+
}
66+
}
67+
68+
export function mathjaxPlugin(options: MathJaxOptions = {}) {
69+
let adaptor: any
70+
let initialized = false
71+
72+
async function ensureInitialized() {
73+
if (!initialized) {
74+
await initializeMathJax(options)
75+
adaptor = MathJax.startup.adaptor
76+
initialized = true
77+
}
78+
}
79+
80+
function renderMath(content: string, displayMode: boolean): string {
81+
if (!initialized) {
82+
throw new Error('MathJax not initialized')
83+
}
84+
85+
const node = MathJax.tex2svg(content, { display: displayMode })
86+
87+
// Prevent Vue from touching MathJax output
88+
adaptor.setAttribute(node, 'v-pre', '')
89+
90+
let html = adaptor.outerHTML(node)
91+
92+
// Preserve spaces inside mjx-break (SVG only)
93+
html = html.replace(
94+
/<mjx-break(.*?)>(.*?)<\/mjx-break>/g,
95+
(_: string, attr: string, inner: string) =>
96+
`<mjx-break${attr}>${inner.replace(/ /g, '&nbsp;')}</mjx-break>`,
97+
)
98+
99+
// Wrap only display equations (not inline math)
100+
html = html.replace(
101+
/(<mjx-container[^>]*display="true"[^>]*>)([\s\S]*?)(<\/mjx-container>)/,
102+
'<div class="mjx-scroll-wrapper">$1$2$3</div>'
103+
)
104+
105+
return html
106+
}
107+
108+
function getMathJaxStyles(): string {
109+
return initialized
110+
? adaptor.textContent(MathJax.svgStylesheet()) || ''
111+
: ''
112+
}
113+
114+
function resetMathJax(): void {
115+
if (!initialized) return
116+
MathJax.texReset()
117+
MathJax.typesetClear()
118+
}
119+
120+
function viteMathJax(): VitePlugin {
121+
const virtualModuleID = '\0' + mathjaxStyleModuleID
122+
123+
return {
124+
name: 'mathjax-styles',
125+
126+
resolveId(id) {
127+
if (id === mathjaxStyleModuleID) {
128+
return virtualModuleID
129+
}
130+
},
131+
132+
async load(id) {
133+
if (id === virtualModuleID) {
134+
await ensureInitialized()
135+
return getMathJaxStyles()
136+
}
137+
},
138+
}
139+
}
140+
141+
function mdMathJax(md: MarkdownIt): void {
142+
mdTex(md, {
143+
render: renderMath,
144+
})
145+
146+
const orig = md.render
147+
md.render = function (...args) {
148+
resetMathJax()
149+
return orig.apply(this, args)
150+
}
151+
}
152+
153+
const init = ensureInitialized()
154+
155+
return {
156+
vitePlugin: viteMathJax(),
157+
markdownConfig: mdMathJax,
158+
styleModuleID: mathjaxStyleModuleID,
159+
init,
160+
}
161+
}

0 commit comments

Comments
 (0)