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 .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ cnf
cnrilrgfclra
codahale
codinghorror
coi
CONDSTORE
convertpw
copybox
Expand Down Expand Up @@ -247,6 +246,7 @@ gethosterror
getmail
getscript
gitlab
gitrev
Gluster
gmatch
gno
Expand Down
46 changes: 35 additions & 11 deletions .vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,42 @@ import gitCommitInfo from 'git-commit-info'
import { defineConfig } from 'vitepress'
import { pagefindPlugin } from 'vitepress-plugin-pagefind'
import { generateSidebar } from 'vitepress-sidebar'
import { dovecotMdExtend, initDovecotMd } from '../lib/markdown.js'
import { dovecotMdExtend } from '../lib/markdown.js'
import { getExcludes } from '../lib/utility.js'

const base = '/2.4'

// Need to bootstrap configuration for Dovecot markdown driver (specifically,
// loading all data files to allow existence checking), or else the markdown
// processing will begin before Dovecot link markup is enabled
await initDovecotMd(base)
export const dovecotConfig = {
data_paths: {
doveadm: '../data/doveadm.js',
event_categories: '../data/event_categories.js',
event_reasons: '../data/event_reasons.js',
events: '../data/events.js',
links_overrides: '../data/links_overrides.js',
lua: '../data/lua.js',
settings: '../data/settings.js',
updates: '../data/updates.js',
},
gitrev: {
align: 'right',
hash: gitCommitInfo().shortHash,
},
man_includes: [
'docs/core/man/include/*.inc'
],
man_paths: [
'docs/core/man/*.[[:digit:]].md'
],
plugin_paths: [
'docs/core/plugins/*.md'
],
url_rewrite: false,
watch_paths: [
'docs/**/*.md',
'docs/**/*.inc',
'data/**/*'
]
}

export default defineConfig({
title: "Dovecot CE",
Expand Down Expand Up @@ -99,15 +126,12 @@ export default defineConfig({
{ icon: 'github', link: 'https://github.com/dovecot/' },
],

/* Dovecot specific config: return gitrev for this build. */
gitrev: {
align: 'right',
hash: gitCommitInfo().shortHash,
}
/* Dovecot config. */
dovecot: dovecotConfig,
},

markdown: {
config: (md) => dovecotMdExtend(md),
config: async (md) => await dovecotMdExtend(md),
image: {
lazyLoading: true,
},
Expand Down
58 changes: 0 additions & 58 deletions .vitepress/local.js.dist

This file was deleted.

4 changes: 2 additions & 2 deletions .vitepress/theme/DovecotLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const { Layout } = DefaultTheme
<Layout>
<template #doc-footer-before>
<div class="edit-info">
<div :class="'edit-rev edit-rev-' + theme.gitrev.align">
<div :class="'edit-rev edit-rev-' + theme.dovecot.gitrev.align">
<div>
<p class="edit-updated">Revision: {{ theme.gitrev.hash }}</p>
<p class="edit-updated">Revision: {{ theme.dovecot.gitrev.hash }}</p>
</div>
</div>
</div>
Expand Down
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,95 @@ The data files live in the base `/data` directory. Each file attempts to be
self-documenting, but they are all essentially large JSON objects. Developers
should need to know basically no JavaScript to be able to edit the files.

### Dovecot VitePress Configuration

Additional configuration options required for VitePress static generation are
defined using the `dovecot` object in the `themeConfig` VitePress
configuration setting.

#### data_paths

Allows custom mapping of data sources.

It is used by the VitePress data loaders to determine what data to
load for export.

Keys are data identifiers, Values are location RELATIVE TO `<base>/lib`
DIRECTORY.

#### gitrev

Configures how the current git revision information is displayed in the
page footer.

##### align

Alignment of the text. Either `left` or `right`.

##### hash

The git hash of the branch tip.

#### man_includes

A list of additional paths (other than the `include/` directory of the man
folder) where include files can live.

#### man_paths

A listing of paths containing man files.
Paths are relative to project base.

Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax

#### markdown_extend

An object containing callbacks that enable additional labels to support in
Dovecot-specific markdown processing (i.e. [[xyz,...]]).

##### open

Opening tag function. Returns opening tag.

The opts argument contains a "resolveURL" key that allows access to the
internal Dovecot Markdown `resolveURL()` function.

Example: `open: (mode, parts, opts, env) => { return '' }`

##### body

Body function. Returns body text.

Example: `body: (mode, env) => { return '' }`

##### close

Close tag function. Returns closing tag.

Example: `close: (mode, env) => { return '' }`

#### plugin_paths

A listing of paths containing plugin files.
Paths are relative to project base.

Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax

#### url_rewrite

A callback where Markdown generated URLs can be rewritten.
Function is called the original URL and returns the (modified) URL.

Example: `url_rewrite: (url) => { return url + '.foo' }`

#### watch_paths

An array of file patterns to watch to refresh data loaders in dev mode.
See: https://vitepress.dev/guide/data-loading#data-from-local-files
Paths are relative to project base.

Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax

### Dovecot Markdown Extensions

Markdown has been extended to allow various Dovecot-specific tasks to be
Expand Down
7 changes: 3 additions & 4 deletions lib/data/doveadm.data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { doveadm_arg_types, doveadm_flag_types, getDoveadmCmdLine } from '../doveadm.js'
import { getVitepressMd } from '../markdown.js'
import { loadData, normalizeArrayData, watchFiles } from '../utility.js'
import { addWatchPaths, loadData, normalizeArrayData } from '../utility.js'
import slugify from '@sindresorhus/slugify'

const doveadm_userargs = {
Expand Down Expand Up @@ -147,11 +147,10 @@ async function normalizeDoveadm(doveadm) {
}
}

export default {
watch: await watchFiles(),
export default addWatchPaths({
async load() {
return await normalizeDoveadm(
structuredClone((await loadData('doveadm')).doveadm)
)
}
}
})
7 changes: 3 additions & 4 deletions lib/data/event_categories.data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getVitepressMd } from '../markdown.js'
import { loadData, watchFiles } from '../utility.js'
import { addWatchPaths, loadData } from '../utility.js'

async function normalizeEventCategories(categories) {
const md = await getVitepressMd()
Expand All @@ -11,11 +11,10 @@ async function normalizeEventCategories(categories) {
return categories
}

export default {
watch: await watchFiles(),
export default addWatchPaths({
async load() {
return await normalizeEventCategories(
structuredClone((await loadData('event_categories')).categories)
)
}
}
})
7 changes: 3 additions & 4 deletions lib/data/event_reasons.data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getVitepressMd } from '../markdown.js'
import { loadData, watchFiles } from '../utility.js'
import { addWatchPaths, loadData } from '../utility.js'

async function normalizeEventReasons(reasons) {
const md = await getVitepressMd()
Expand All @@ -11,11 +11,10 @@ async function normalizeEventReasons(reasons) {
return reasons
}

export default {
watch: await watchFiles(),
export default addWatchPaths({
async load() {
return await normalizeEventReasons(
structuredClone((await loadData('event_reasons')).reasons)
)
}
}
})
7 changes: 3 additions & 4 deletions lib/data/events.data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadData, normalizeArrayData, watchFiles } from '../utility.js'
import { addWatchPaths, loadData, normalizeArrayData } from '../utility.js'
import { getVitepressMd } from '../markdown.js'

/* Take the events list and normalize entries and process inheritance. */
Expand Down Expand Up @@ -124,8 +124,7 @@ async function normalizeEvents(events, global_inherits, inherits) {
return events
}

export default {
watch: await watchFiles(),
export default addWatchPaths({
async load() {
const data = await loadData('events')
return await normalizeEvents(
Expand All @@ -134,4 +133,4 @@ export default {
structuredClone(data.inherits)
)
}
}
})
7 changes: 3 additions & 4 deletions lib/data/lua.data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getVitepressMd } from '../markdown.js'
import { loadData, watchFiles } from '../utility.js'
import { addWatchPaths, loadData } from '../utility.js'

async function normalizeLuaConstants(lua) {
const md = await getVitepressMd()
Expand Down Expand Up @@ -62,8 +62,7 @@ async function normalizeLuaVariables(lua) {
return out
}

export default {
watch: await watchFiles(),
export default addWatchPaths({
async load() {
const data = await(loadData('lua'))

Expand All @@ -73,4 +72,4 @@ export default {
variables: await normalizeLuaVariables(data.lua_variables)
}
}
}
})
7 changes: 3 additions & 4 deletions lib/data/settings.data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadData, normalizeArrayData, watchFiles } from '../utility.js'
import { addWatchPaths, loadData, normalizeArrayData } from '../utility.js'
import { getVitepressMd } from '../markdown.js'

async function normalizeSettings(settings) {
Expand Down Expand Up @@ -69,11 +69,10 @@ async function normalizeSettings(settings) {
return data
}

export default {
watch: await watchFiles(),
export default addWatchPaths({
async load() {
return await normalizeSettings(
structuredClone((await loadData('settings')).settings)
)
}
}
})
Loading