-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtypedoc.js
54 lines (47 loc) · 1.69 KB
/
typedoc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const { Renderer } = require('marked')
const highlightjs = require('highlight.js')
const path = require('path')
const escapeMap = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
}
function escapeForHTML(input) {
return input.replace(/(["&'<>])/g, (char) => escapeMap[char])
}
// Create your custom renderer.
const renderer = new Renderer()
renderer.code = (code, language) => {
// Check whether the given language is valid for highlight.js.
const validLang = !!(language && highlightjs.getLanguage(language))
// Highlight only if the language is valid.
// highlight.js escapes HTML in the code, but we need to escape by ourselves
// when we don't use it.
const highlighted = validLang
? highlightjs.highlight(language, code).value
: escapeForHTML(code)
// Render the highlighted code with `hljs` class.
return `<pre><code class="hljs ${language}">${highlighted}</code></pre>`
}
module.exports = {
entryPoints: [
path.resolve(__dirname, '../src/main.ts'),
path.resolve(__dirname, '../src/laika.ts'),
path.resolve(__dirname, '../src/createGlobalLaikaLink.ts'),
path.resolve(__dirname, '../src/createLazyLoadableLaikaLink.ts'),
path.resolve(__dirname, '../src/createLazyLoadableLink.ts'),
path.resolve(__dirname, '../src/typedefs.ts'),
],
tsconfig: path.join(__dirname, '../tsconfig.json'),
excludePrivate: true,
excludeInternal: true,
// Media can be linked to with media://file.jpg in doc comments.
media: path.resolve(__dirname, '../media'),
// Files can be injected into the generated documentation with [[include:file.md]] in a doc comment
includes: path.join(__dirname, 'docs-meta'),
markedOptions: {
renderer,
},
}