2021-03-08 12:22:01 +00:00
|
|
|
const path = require('path');
|
2021-06-25 09:41:41 +00:00
|
|
|
|
2021-03-08 12:22:01 +00:00
|
|
|
const autolinkHeadings = require('remark-autolink-headings');
|
|
|
|
const refractor = require('refractor');
|
|
|
|
const prism = require('@mapbox/rehype-prism');
|
|
|
|
|
2021-06-25 09:41:41 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
const read = fs.readFileSync;
|
|
|
|
const exists = fs.existsSync;
|
|
|
|
const chalk = require('chalk'); // comes with ember
|
|
|
|
|
|
|
|
// allow extra docfy config
|
|
|
|
let user = {sources: [], labels: {}};
|
|
|
|
const $CONSUL_DOCFY_CONFIG = process.env.CONSUL_DOCFY_CONFIG || '';
|
|
|
|
if($CONSUL_DOCFY_CONFIG.length > 0) {
|
|
|
|
try {
|
|
|
|
if(exists($CONSUL_DOCFY_CONFIG)) {
|
|
|
|
user = JSON.parse(read($CONSUL_DOCFY_CONFIG));
|
|
|
|
} else {
|
|
|
|
throw new Error(`Unable to locate ${$CONSUL_DOCFY_CONFIG}`);
|
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
console.error(chalk.yellow(`Docfy: ${e.message}`));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-08 12:22:01 +00:00
|
|
|
refractor.alias('handlebars', 'hbs');
|
|
|
|
refractor.alias('shell', 'sh');
|
|
|
|
|
2021-06-25 09:41:41 +00:00
|
|
|
|
2021-03-08 12:22:01 +00:00
|
|
|
module.exports = {
|
|
|
|
remarkHbsOptions: {
|
|
|
|
escapeCurliesCode: false
|
|
|
|
},
|
|
|
|
remarkPlugins: [
|
|
|
|
autolinkHeadings,
|
|
|
|
{
|
|
|
|
behavior: 'wrap'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
rehypePlugins: [
|
|
|
|
prism
|
|
|
|
],
|
|
|
|
sources: [
|
2021-03-17 15:58:17 +00:00
|
|
|
{
|
|
|
|
root: path.resolve(__dirname, 'docs'),
|
|
|
|
pattern: '**/*.mdx',
|
|
|
|
urlSchema: 'auto',
|
|
|
|
urlPrefix: 'docs',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
root: path.resolve(__dirname, 'app/modifiers'),
|
|
|
|
pattern: '**/*.mdx',
|
|
|
|
urlSchema: 'auto',
|
|
|
|
urlPrefix: 'docs/modifiers',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
root: path.resolve(__dirname, 'app/helpers'),
|
|
|
|
pattern: '**/*.mdx',
|
|
|
|
urlSchema: 'auto',
|
|
|
|
urlPrefix: 'docs/helpers',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
root: path.resolve(__dirname, 'app/services'),
|
|
|
|
pattern: '**/*.mdx',
|
|
|
|
urlSchema: 'auto',
|
|
|
|
urlPrefix: 'docs/services',
|
|
|
|
},
|
2021-03-08 12:22:01 +00:00
|
|
|
{
|
|
|
|
root: path.resolve(__dirname, 'app/components'),
|
2021-03-17 15:58:17 +00:00
|
|
|
pattern: '**(!consul)/README.mdx',
|
2021-03-08 12:22:01 +00:00
|
|
|
urlSchema: 'auto',
|
|
|
|
urlPrefix: 'docs/components',
|
2021-03-17 15:58:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
root: path.resolve(__dirname, 'app/components/consul'),
|
|
|
|
pattern: '**/README.mdx',
|
|
|
|
urlSchema: 'auto',
|
|
|
|
urlPrefix: 'docs/consul',
|
2021-03-08 12:22:01 +00:00
|
|
|
}
|
2021-06-25 09:41:41 +00:00
|
|
|
].concat(user.sources),
|
2021-03-17 15:58:17 +00:00
|
|
|
labels: {
|
2021-06-25 09:41:41 +00:00
|
|
|
"consul": "Consul Components",
|
|
|
|
...user.labels
|
2021-03-17 15:58:17 +00:00
|
|
|
}
|
2021-03-08 12:22:01 +00:00
|
|
|
};
|