12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- const env = require('jsdoc/env');
- const config = env.conf.markdown || {};
- const defaultTags = [
- 'author',
- 'classdesc',
- 'description',
- 'exceptions',
- 'params',
- 'properties',
- 'returns',
- 'see',
- 'summary'
- ];
- const hasOwnProp = Object.prototype.hasOwnProperty;
- const parse = require('jsdoc/util/markdown').getParser();
- let tags = [];
- let excludeTags = [];
- function shouldProcessString(tagName, text) {
- let shouldProcess = true;
-
- if ( (tagName === 'author' || tagName === 'see') && !text.includes('[') ) {
- shouldProcess = false;
- }
- return shouldProcess;
- }
- function process(doclet) {
- tags.forEach(tag => {
- if ( !hasOwnProp.call(doclet, tag) ) {
- return;
- }
- if (typeof doclet[tag] === 'string' && shouldProcessString(tag, doclet[tag]) ) {
- doclet[tag] = parse(doclet[tag]);
- }
- else if ( Array.isArray(doclet[tag]) ) {
- doclet[tag].forEach((value, index, original) => {
- const inner = {};
- inner[tag] = value;
- process(inner);
- original[index] = inner[tag];
- });
- }
- else if (doclet[tag]) {
- process(doclet[tag]);
- }
- });
- }
- if (config.tags) {
- tags = config.tags.slice();
- }
- if (config.excludeTags) {
- excludeTags = config.excludeTags.slice();
- }
- defaultTags.forEach(tag => {
- if (!excludeTags.includes(tag) && !tags.includes(tag)) {
- tags.push(tag);
- }
- });
- exports.handlers = {
-
- newDoclet({doclet}) {
- process(doclet);
- }
- };
|