1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | 'use strict';
|
8 |
|
9 | var env = require('jsdoc/env');
|
10 |
|
11 | var config = env.conf.markdown || {};
|
12 | var defaultTags = [
|
13 | 'author',
|
14 | 'classdesc',
|
15 | 'description',
|
16 | 'exceptions',
|
17 | 'params',
|
18 | 'properties',
|
19 | 'returns',
|
20 | 'see'
|
21 | ];
|
22 | var hasOwnProp = Object.prototype.hasOwnProperty;
|
23 | var parse = require('jsdoc/util/markdown').getParser();
|
24 | var tags = [];
|
25 | var excludeTags = [];
|
26 |
|
27 | function shouldProcessString(tagName, text) {
|
28 | var shouldProcess = true;
|
29 |
|
30 |
|
31 | if ( (tagName === 'author' || tagName === 'see') && text.indexOf('[') === -1 ) {
|
32 | shouldProcess = false;
|
33 | }
|
34 |
|
35 | return shouldProcess;
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | function process(doclet) {
|
45 | tags.forEach(function(tag) {
|
46 | if ( !hasOwnProp.call(doclet, tag) ) {
|
47 | return;
|
48 | }
|
49 |
|
50 | if (typeof doclet[tag] === 'string' && shouldProcessString(tag, doclet[tag]) ) {
|
51 | doclet[tag] = parse(doclet[tag]);
|
52 | }
|
53 | else if ( Array.isArray(doclet[tag]) ) {
|
54 | doclet[tag].forEach(function(value, index, original) {
|
55 | var inner = {};
|
56 | inner[tag] = value;
|
57 | process(inner);
|
58 | original[index] = inner[tag];
|
59 | });
|
60 | }
|
61 | else if (doclet[tag]) {
|
62 | process(doclet[tag]);
|
63 | }
|
64 | });
|
65 | }
|
66 |
|
67 |
|
68 | if (config.tags) {
|
69 | tags = config.tags.slice();
|
70 | }
|
71 |
|
72 | if (config.excludeTags) {
|
73 | excludeTags = config.excludeTags.slice();
|
74 | }
|
75 | defaultTags.forEach(function(tag) {
|
76 | if (excludeTags.indexOf(tag) === -1 && tags.indexOf(tag) === -1) {
|
77 | tags.push(tag);
|
78 | }
|
79 | });
|
80 |
|
81 | exports.handlers = {
|
82 | |
83 |
|
84 |
|
85 |
|
86 | newDoclet: function(e) {
|
87 | process(e.doclet);
|
88 | }
|
89 | };
|