Skip to content

Commit

Permalink
Move documentation to Vitepress (#256)
Browse files Browse the repository at this point in the history
* Update to DocumenterVitepress backend

* Ignore Node packages

* Temporarily disable raw HTML image inclusion

* update alternatives

* big docs update

* more doc changes

* update type hierarchy diagram

* update

* format code

* configure vitepress

* split API into sections

* rename "alternatives" to "friends"

* comment `baseTemp`

* add icons for friends and api sections

* fix versioned docs

* try fix navigation bar

* fix path to versions.js

* add missing import
  • Loading branch information
mofeing authored Nov 22, 2024
1 parent 4247207 commit 26faef1
Show file tree
Hide file tree
Showing 30 changed files with 823 additions and 204 deletions.
147 changes: 138 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,6 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,julia,macos,windows

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
.vscode/settings.json
.julia
*.excalidraw
archive/
test/.CondaPkg/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -291,3 +282,141 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
.vscode/settings.json
.julia
*.excalidraw
archive/
test/.CondaPkg/
4 changes: 4 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/
node_modules/
package-lock.json
Manifest.toml
5 changes: 5 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
EinExprs = "b1794770-133b-4de1-afb4-526377e9f4c5"
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
Kroki = "b3565e16-c1f2-4fe9-b4ab-221c88942068"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a"
Tenet = "85d41934-b9cd-44e1-8730-56d86f15f3ec"

[sources]
Tenet = {path = "/Users/mofeing/Developer/Tenet.jl/docs/.."}

[compat]
Documenter = "1"
DocumenterCitations = "1.2"
53 changes: 33 additions & 20 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Pkg
Pkg.activate(@__DIR__)
Pkg.develop(; path=joinpath(@__DIR__, ".."))
Pkg.instantiate()

using Documenter
using DocumenterVitepress
using DocumenterCitations
using Tenet
using CairoMakie
Expand All @@ -18,28 +14,45 @@ makedocs(;
modules=[Tenet, Base.get_extension(Tenet, :TenetGraphMakieExt)],
sitename="Tenet.jl",
authors="Sergio Sánchez Ramírez and contributors",
pages=Any[
pages=[
"Home" => "index.md",
"Tensors" => "tensors.md",
"Tensor Networks" => "tensor-network.md",
"Contraction" => "contraction.md",
"Transformations" => "transformations.md",
"Quantum" => [
"Introduction" => "quantum.md",
"Ansatzes" => ["`Product` ansatz" => "ansatz/product.md", "`Chain` ansatz" => "ansatz/chain.md"],
"📖 Manual" => [
"Tensors" => "manual/tensors.md",
"Tensor Networks" => "manual/tensor-network.md",
"Contraction" => "manual/contraction.md",
"Transformations" => "manual/transformations.md",
"Quantum" => "manual/quantum.md",
"Ansatz" => [
"Introduction" => "manual/ansatz/index.md",
"Product ansatz" => "manual/ansatz/product.md",
"MPS/MPO ansatz" => "manual/ansatz/mps.md",
],
"Visualization" => "visualization.md",
],
"🫂 Friends" => "friends.md",
"🧭 API" => [
"Tensor" => "api/tensor.md",
"TensorNetwork" => "api/tensornetwork.md",
"Quantum" => "api/quantum.md",
"Ansatz" => "api/ansatz.md",
],
"⚒️ Developer Reference" => [
"Hypergraph representation of `TensorNetwork`" => "developer/hypergraph.md",
"Type Hierarchy" => "developer/type-hierarchy.md",
"Unsafe region" => "developer/unsafe-region.md",
"Cached field" => "developer/cached-field.md",
"Keyword Dispatch" => "developer/keyword-dispatch.md",
],
"Visualization" => "visualization.md",
"Alternatives" => "alternatives.md",
"References" => "references.md",
"⚒️ Developer Reference" => ["`TensorNetwork` type hierarchy" => "developer/type-hierarchy.md"],
],
pagesonly=true,
format=Documenter.HTML(;
prettyurls=false, assets=["assets/favicon.ico", "assets/citations.css", "assets/youtube.css"]
format=DocumenterVitepress.MarkdownVitepress(;
repo="https://github.com/bsc-quantic/Tenet.jl",
assets=["assets/favicon.ico", "assets/citations.css", "assets/youtube.css"],
# build_vitepress=false,
),
plugins=[bib],
checkdocs=:exports,
warnonly=true,
)

deploydocs(; repo="github.com/bsc-quantic/Tenet.jl.git", devbranch="master", push_preview=true)
deploydocs(; repo="github.com/bsc-quantic/Tenet.jl.git", target="build", devbranch="master", push_preview=true)
15 changes: 15 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"scripts": {
"docs:dev": "vitepress dev build/.documenter",
"docs:build": "vitepress build build/.documenter",
"docs:preview": "vitepress preview build/.documenter"
},
"dependencies": {
"@shikijs/transformers": "^1.1.7",
"markdown-it": "^14.1.0",
"markdown-it-footnote": "^4.0.0",
"markdown-it-mathjax3": "^4.3.2",
"vitepress": "^1.1.4",
"vitepress-plugin-tabs": "^0.5.0"
}
}
71 changes: 71 additions & 0 deletions docs/src/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { defineConfig } from 'vitepress'
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
import mathjax3 from "markdown-it-mathjax3";
import footnote from "markdown-it-footnote";

const baseTemp = {
base: 'REPLACE_ME_DOCUMENTER_VITEPRESS',// TODO: replace this in makedocs!
}

const navTemp = {
nav: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
}

const nav = [
...navTemp.nav,
{
component: 'VersionPicker'
}
]

// https://vitepress.dev/reference/site-config
export default defineConfig({
base: baseTemp.base,
title: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
description: 'Documentation of Tenet.jl library',
lastUpdated: true,
cleanUrls: true,
outDir: 'REPLACE_ME_DOCUMENTER_VITEPRESS', // This is required for MarkdownVitepress to work correctly...
head: [
['link', { rel: 'icon', href: 'REPLACE_ME_DOCUMENTER_VITEPRESS_FAVICON' }],
["script", { src: `/Tenet.jl/versions.js` }],
["script", { src: `${baseTemp.base}siteinfo.js` }],
],
ignoreDeadLinks: true,

markdown: {
math: true,
config(md) {
md.use(tabsMarkdownPlugin),
md.use(mathjax3),
md.use(footnote)
},
theme: {
light: "github-light",
dark: "github-dark"
}
},
themeConfig: {
outline: 'deep',
logo: {
light: '/logo.svg',
dark: '/logo-dark.svg',
},
search: {
provider: 'local',
options: {
detailedView: true
}
},
nav,
sidebar: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
editLink: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
socialLinks: [
{ icon: 'github', link: 'REPLACE_ME_DOCUMENTER_VITEPRESS' }
],
footer: {
message: 'Made with <a href="https://luxdl.github.io/DocumenterVitepress.jl/dev/" target="_blank"><strong>DocumenterVitepress.jl</strong></a><br>',
copyright: `© Copyright ${new Date().getUTCFullYear()} Barcelona Supercomputing Center - Centro Nacional de Supercomputación`
}
}
})
55 changes: 55 additions & 0 deletions docs/src/.vitepress/theme/VersionPicker.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!-- Adapted from https://github.com/MakieOrg/Makie.jl/blob/master/docs/src/.vitepress/theme/VersionPicker.vue -->

<script setup lang="ts">
import { computed, ref, onMounted } from 'vue'
import { useRoute } from 'vitepress'
import VPNavBarMenuGroup from 'vitepress/dist/client/theme-default/components/VPNavBarMenuGroup.vue'
import VPNavScreenMenuGroup from 'vitepress/dist/client/theme-default/components/VPNavScreenMenuGroup.vue'
const props = defineProps<{
screenMenu?: boolean
}>()
const route = useRoute()
const versions = ref([]);
const currentVersion = ref('Versions');
const waitForGlobalDocumenterVars = () => {
return new Promise((resolve) => {
const checkInterval = setInterval(() => {
if (window.DOC_VERSIONS && window.DOCUMENTER_CURRENT_VERSION) {
clearInterval(checkInterval);
resolve({
versions: window.DOC_VERSIONS,
currentVersion: window.DOCUMENTER_CURRENT_VERSION
});
}
}, 100); // Check every 100ms
});
};
onMounted(async () => {
const globalvars = await waitForGlobalDocumenterVars();
versions.value = globalvars.versions.map((v) => {
return { text: v, link: `${window.location.origin}/${v}/` }
});
currentVersion.value = globalvars.currentVersion;
});
</script>

<template>
<VPNavBarMenuGroup v-if="!screenMenu" :item="{ text: currentVersion, items: versions }" class="VPVersionPicker" />
<VPNavScreenMenuGroup v-else :text="currentVersion" :items="versions" class="VPVersionPicker" />
</template>

<style scoped>
.VPVersionPicker :deep(button .text) {
color: var(--vp-c-text-1) !important;
}
.VPVersionPicker:hover :deep(button .text) {
color: var(--vp-c-text-2) !important;
}
</style>
Loading

0 comments on commit 26faef1

Please sign in to comment.