Skip to content

Commit ce7921b

Browse files
committed
local.js: Move man paths out of local config file
1 parent 63d0208 commit ce7921b

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

.vitepress/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export default defineConfig({
107107

108108
/* Dovecot VitePress paths. */
109109
dovecot: {
110+
man_includes: [
111+
'docs/core/man/include/*.inc'
112+
],
113+
man_paths: [
114+
'docs/core/man/*.[[:digit:]].md'
115+
],
110116
watch_paths: [
111117
'docs/**/*.md',
112118
'docs/**/*.inc',

.vitepress/local.js.dist

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ export const data_paths = {
1313
// doveadm: '../data/doveadm.js',
1414
}
1515

16-
// A listing of paths containing man files.
17-
// Paths are relative to project base.
18-
//
19-
// Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax
20-
//
21-
// Default: [ 'docs/core/man/*.[[:digit:]].md' ]
22-
export const man_paths = []
23-
2416
// A listing of paths containing plugin files.
2517
// Paths are relative to project base.
2618
//

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,18 @@ Additional configuration options required for VitePress static generation are
164164
defined using the `dovecot` object in the `themeConfig` VitePress
165165
configuration setting.
166166

167+
#### man_includes
168+
169+
A list of additional paths (other than the `include/` directory of the man
170+
folder) where include files can live.
171+
172+
#### man_paths
173+
174+
A listing of paths containing man files.
175+
Paths are relative to project base.
176+
177+
Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax
178+
167179
#### watch_paths
168180

169181
An array of file patterns to watch to refresh data loaders in dev mode.

lib/markdown.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fg from 'fast-glob'
33
import deflistPlugin from 'markdown-it-deflist'
44
import path from 'path'
55
import { createMarkdownRenderer } from 'vitepress'
6-
import { frontmatterIter, loadData, manFiles, markdownExtension, pluginFiles, resolveURL } from './utility.js'
6+
import { dovecotSetting, frontmatterIter, loadData, markdownExtension, pluginFiles, resolveURL } from './utility.js'
77

88
let md_conf = null
99
export async function initDovecotMd(base) {
@@ -17,12 +17,6 @@ export async function initDovecotMd(base) {
1717
doveadm: (await loadData('doveadm')).doveadm,
1818
events: (await loadData('events')).events,
1919
linkoverrides: (await loadData('links_overrides')).links_overrides,
20-
man: (await manFiles()).flatMap((x) => {
21-
return fg.sync(x).map((y) => {
22-
const str = path.basename(y)
23-
return str.substring(0, str.indexOf('.'))
24-
})
25-
}),
2620
plugins: (await pluginFiles()).flatMap((x) =>
2721
fg.sync(x).map((y) => path.basename(y, '.md'))
2822
),
@@ -219,6 +213,8 @@ function dovecot_markdown(md, opts) {
219213
hash = parts[2] ? parts[2] : false;
220214
env.args = parts[3] ? parts[3] : 1;
221215

216+
initManFiles()
217+
222218
if (!opts.man.includes(env.inner)) {
223219
handle_error('man link missing: ' + env.inner)
224220
return '<a><code>'
@@ -426,6 +422,17 @@ function dovecot_markdown(md, opts) {
426422
opts.dovecotlinks = { ...links, ...opts.linkoverrides }
427423
}
428424

425+
function initManFiles() {
426+
if (!opts.man) {
427+
opts.man = dovecotSetting('man_paths').flatMap((x) => {
428+
return fg.sync(x).map((y) => {
429+
const str = path.basename(y)
430+
return str.substring(0, str.indexOf('.'))
431+
})
432+
})
433+
}
434+
}
435+
429436
md.inline.ruler.after('emphasis', 'dovecot_brackets', process_brackets)
430437
md.renderer.rules.dovecot_open = dovecot_open
431438
md.renderer.rules.dovecot_body = dovecot_body

util/generate_man.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import matter from 'gray-matter'
1414
import pdc from 'pdc'
1515
import path from 'path'
1616
import { VFile } from 'vfile'
17-
import { manFiles, manIncludes } from '../lib/utility.js'
17+
import { dovecotSetting } from '../lib/utility.js'
1818
import remarkDeflist from 'remark-definition-list'
1919
import remarkMan from 'remark-man'
2020
import remarkParse from 'remark-parse'
@@ -126,8 +126,8 @@ const main = async (component, outPath) => {
126126
}
127127

128128
/* Generate list of man files. */
129-
const files = (await manFiles()).flatMap((x) => fg.sync(x))
130-
const includes = (await manIncludes()).flatMap((x) => fg.sync(x))
129+
const files = dovecotSetting('man_paths').flatMap((x) => fg.sync(x))
130+
const includes = dovecotSetting('man_includes').flatMap((x) => fg.sync(x))
131131

132132
/* Get hash of last git commit. */
133133
const gitHash = gitCommitInfo().shortHash

0 commit comments

Comments
 (0)