2018-10-30 18:43:45 +00:00
|
|
|
/* eslint-env node */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
plugins: ['plugins/markdown'],
|
|
|
|
markdown: {
|
2018-10-30 19:41:22 +00:00
|
|
|
// tags: ['examples']
|
|
|
|
/*
|
2018-10-30 18:43:45 +00:00
|
|
|
// "The highlighter function should escape the code block's contents and wrap them in <pre><code> tags"
|
|
|
|
highlight (code, language) {
|
|
|
|
function ret () {
|
|
|
|
// Default:
|
|
|
|
return '<pre><code>' + code + ' in this language: ' + language + '</code></pre>';
|
|
|
|
}
|
|
|
|
if (language !== 'js') { // E.g., we have one URL in some tutorial Markdown
|
2018-10-30 19:41:22 +00:00
|
|
|
// Seems to be only for full triple-backticked fences
|
|
|
|
// console.log('lll', code);
|
2018-10-30 18:43:45 +00:00
|
|
|
return ret();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api
|
|
|
|
const {CLIEngine} = require('eslint');
|
|
|
|
const cli = new CLIEngine({
|
|
|
|
useEslintrc: true,
|
|
|
|
rules: {
|
|
|
|
'no-undef': 0, // Many variables in examples will be undefined
|
|
|
|
'padded-blocks': 0 // Can look nicer
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Undo escaping done by node_modules/jsdoc/lib/jsdoc/util/markdown.js
|
|
|
|
code = code
|
|
|
|
.replace(/\s+$/, '')
|
|
|
|
.replace(/'/g, "'")
|
|
|
|
.replace(/(https?):\\\/\\\//g, '$1://')
|
|
|
|
.replace(/\{@[^}\r\n]+\}/g, function (wholeMatch) {
|
|
|
|
return wholeMatch.replace(/"/g, '"');
|
|
|
|
});
|
|
|
|
|
|
|
|
// lint the supplied text and optionally set
|
|
|
|
// a filename that is displayed in the report
|
|
|
|
const report = cli.executeOnText(code + '\n');
|
|
|
|
if (!report.errorCount && !report.warningCount) {
|
|
|
|
return ret();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Although we don't get the file, at least we can report the source code
|
|
|
|
const {messages} = report.results[0];
|
|
|
|
messages.forEach(({message, line, column, severity, ruleId}) => {
|
|
|
|
console.log(`${ruleId}: ${message} (Severity: ${severity}; ${line}:${column})`);
|
|
|
|
});
|
|
|
|
console.log('\n' + code);
|
|
|
|
|
|
|
|
return ret();
|
2018-10-30 19:41:22 +00:00
|
|
|
}
|
|
|
|
*/
|
2018-10-30 18:43:45 +00:00
|
|
|
},
|
|
|
|
recurseDepth: 10,
|
|
|
|
source: {
|
|
|
|
exclude: [
|
2020-04-02 05:12:30 +00:00
|
|
|
'cypress',
|
2018-10-30 18:43:45 +00:00
|
|
|
'node_modules',
|
|
|
|
'dist',
|
2020-07-18 11:21:41 +00:00
|
|
|
'external',
|
2018-10-30 18:43:45 +00:00
|
|
|
'screencasts',
|
|
|
|
'test'
|
|
|
|
],
|
2020-07-31 23:23:28 +00:00
|
|
|
// eslint-disable-next-line max-len
|
2020-01-05 09:58:50 +00:00
|
|
|
excludePattern: 'svgedit-config-*|build-html.js|rollup*|external/babel-polyfill|extensions/mathjax|imagelib/jquery.min.js|jspdf/jspdf.min.js|jspdf/underscore-min.js|jquery-ui|jquery.min.js|js-hotkeys'
|
2018-10-30 18:43:45 +00:00
|
|
|
},
|
|
|
|
sourceType: 'module',
|
|
|
|
tags: {
|
|
|
|
allowUnknownTags: false
|
|
|
|
},
|
|
|
|
templates: {
|
|
|
|
cleverLinks: true,
|
2018-10-30 19:41:22 +00:00
|
|
|
monospaceLinks: false /* ,
|
2018-10-30 18:43:45 +00:00
|
|
|
default: {
|
|
|
|
layoutFile: 'docs/layout.tmpl'
|
2018-10-30 19:41:22 +00:00
|
|
|
} */
|
2018-10-30 18:43:45 +00:00
|
|
|
},
|
|
|
|
opts: {
|
|
|
|
recurse: true,
|
|
|
|
verbose: true,
|
2018-11-08 06:48:01 +00:00
|
|
|
destination: 'docs/jsdoc',
|
2018-10-30 18:43:45 +00:00
|
|
|
tutorials: 'docs/tutorials'
|
|
|
|
}
|
|
|
|
};
|