Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Every command is documented in the [CLI reference](https://craftpkg.github.io/cr

## 🤝 Contributing

Contributions are welcome! `make` runs formatting, lints and the full test suite. See [Contributing](https://craftpkg.github.io/craft/contributing/) for the architecture, the test suites and how to work on the docs.
Contributions are welcome! `make` runs formatting, lints and the full test suite. See the [developer docs](https://craftpkg.github.io/craft/developers/anatomy) for how craft works inside, the test suites and how to work on the docs.

## 📄 License

Expand Down
29 changes: 24 additions & 5 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,27 @@ export default defineConfig({
cleanUrls: true,
head: [['link', { rel: 'icon', type: 'image/png', href: '/craft/logo.png' }]],

markdown: {
config(md) {
const fence = md.renderer.rules.fence!
md.renderer.rules.fence = (tokens, index, options, env, renderer) => {
const token = tokens[index]
if (token.info.trim() === 'mermaid') {
return `<MermaidDiagram graph="${encodeURIComponent(token.content)}" />`
}
return fence(tokens, index, options, env, renderer)
}
},
},

themeConfig: {
logo: '/logo.png',

nav: [
{ text: 'Guide', link: '/guide/introduction', activeMatch: '/guide/' },
{ text: 'CLI', link: '/reference/cli', activeMatch: '/reference/' },
{ text: 'Benchmarks', link: '/guide/benchmarks' },
{ text: 'Contributing', link: '/contributing/', activeMatch: '/contributing/' },
{ text: 'Developers', link: '/developers/anatomy', activeMatch: '/developers/' },
],

sidebar: {
Expand Down Expand Up @@ -78,13 +91,19 @@ export default defineConfig({
],
},
],
'/contributing/': [
'/developers/': [
{
text: 'How craft works',
items: [
{ text: 'Anatomy', link: '/developers/anatomy' },
{ text: 'Architecture', link: '/developers/architecture' },
],
},
{
text: 'Contributing',
items: [
{ text: 'Overview', link: '/contributing/' },
{ text: 'Architecture', link: '/contributing/architecture' },
{ text: 'Testing', link: '/contributing/testing' },
{ text: 'Getting set up', link: '/developers/' },
{ text: 'Testing', link: '/developers/testing' },
],
},
],
Expand Down
117 changes: 117 additions & 0 deletions docs/.vitepress/theme/MermaidDiagram.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<script setup lang="ts">
import { useData } from 'vitepress'
import { onMounted, ref, useId, watch } from 'vue'

const props = defineProps<{ graph: string }>()

const { isDark } = useData()
const svg = ref('')
const renderId = `mermaid-${useId()}`

onMounted(render)
watch(isDark, render)

async function render() {
const { default: mermaid } = await import('mermaid')
await document.fonts.ready
mermaid.initialize({
startOnLoad: false,
theme: 'base',
fontFamily: FONT_FAMILY,
themeVariables: isDark.value ? DARK : LIGHT,
flowchart: { curve: 'basis', padding: 12, wrappingWidth: 420 },
sequence: {
mirrorActors: false,
width: 120,
actorMargin: 40,
actorFontSize: 14,
messageFontSize: 14,
noteFontSize: 13,
},
})
const rendered = await mermaid.render(renderId, decodeURIComponent(props.graph))
svg.value = rendered.svg
}

const FONT_FAMILY = 'Inter, ui-sans-serif, system-ui, sans-serif'

const LIGHT = {
fontFamily: FONT_FAMILY,
fontSize: '14px',
background: '#f6f6f7',
primaryColor: '#fff3ea',
primaryBorderColor: '#f07020',
primaryTextColor: '#3c3c43',
secondaryColor: '#ffffff',
secondaryBorderColor: '#c2c2c4',
tertiaryColor: '#ffffff',
lineColor: '#8e8e93',
textColor: '#3c3c43',
clusterBkg: '#ffffff',
clusterBorder: '#e2e2e3',
edgeLabelBackground: '#f6f6f7',
actorBkg: '#fff3ea',
actorBorder: '#f07020',
actorTextColor: '#3c3c43',
signalColor: '#3c3c43',
signalTextColor: '#3c3c43',
labelBoxBkgColor: '#ffffff',
noteBkgColor: '#ffffff',
noteBorderColor: '#e2e2e3',
noteTextColor: '#3c3c43',
activationBkgColor: '#ffe2cc',
activationBorderColor: '#f07020',
}

const DARK = {
...LIGHT,
background: '#202127',
primaryColor: '#3a2414',
primaryTextColor: '#dfdfd6',
secondaryColor: '#1b1b1f',
secondaryBorderColor: '#3c3f44',
tertiaryColor: '#1b1b1f',
lineColor: '#98989f',
textColor: '#dfdfd6',
clusterBkg: '#1b1b1f',
clusterBorder: '#3c3f44',
edgeLabelBackground: '#202127',
actorBkg: '#3a2414',
actorTextColor: '#dfdfd6',
signalColor: '#dfdfd6',
signalTextColor: '#dfdfd6',
labelBoxBkgColor: '#1b1b1f',
noteBkgColor: '#1b1b1f',
noteBorderColor: '#3c3f44',
noteTextColor: '#dfdfd6',
activationBkgColor: '#5a3317',
}
</script>

<template>
<div class="mermaid-diagram" v-html="svg" />
</template>

<style scoped>
.mermaid-diagram {
display: flex;
justify-content: center;
margin: 24px 0;
padding: 20px 16px;
min-height: 80px;
overflow-x: auto;
border: 1px solid var(--vp-c-divider);
border-radius: 12px;
background: var(--vp-c-bg-soft);
}

.mermaid-diagram :deep(svg) {
max-width: 100%;
height: auto;
}

.mermaid-diagram :deep(foreignObject p) {
margin: 0;
line-height: 1.5;
}
</style>
2 changes: 2 additions & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import DefaultTheme from 'vitepress/theme'
import type { Theme } from 'vitepress'

import BenchmarkChart from './BenchmarkChart.vue'
import MermaidDiagram from './MermaidDiagram.vue'

export default {
extends: DefaultTheme,
enhanceApp({ app }) {
app.component('BenchmarkChart', BenchmarkChart)
app.component('MermaidDiagram', MermaidDiagram)
},
} satisfies Theme
Loading
Loading