1 | const fs = require('fs')
|
2 | const path = require('path')
|
3 | const markdownMagic = require('../index')
|
4 |
|
5 | const config = {
|
6 | matchWord: 'MD-MAGIC-EXAMPLE',
|
7 | transforms: {
|
8 |
|
9 | customTransform(content, options) {
|
10 | console.log('original content in comment block', content)
|
11 | console.log('options defined on transform', options)
|
12 |
|
13 | return `This will replace all the contents of inside the comment ${options.optionOne}`
|
14 | },
|
15 |
|
16 | RENDERDOCS(content, options) {
|
17 | const fileContents = fs.readFileSync(options.path, 'utf8')
|
18 | const docBlocs = require('doxxx').parseComments(fileContents, { raw: true, skipSingleStar: true })
|
19 | let updatedContent = ''
|
20 | docBlocs.forEach((data) => {
|
21 | updatedContent += `${data.description.full}\n\n`
|
22 | })
|
23 | return updatedContent.replace(/^\s+|\s+$/g, '')
|
24 | },
|
25 |
|
26 | pluginExample: require('./plugin-example')({ addNewLine: true }),
|
27 |
|
28 |
|
29 |
|
30 | }
|
31 | }
|
32 |
|
33 | const markdownPath = path.join(__dirname, '..', 'README.md')
|
34 | markdownMagic(markdownPath, config, () => {
|
35 | console.log('Docs ready')
|
36 | })
|