mirror of
https://github.com/documentationjs/documentation.git
synced 2025-12-08 18:23:43 +00:00
Also: * Moves reduction out of parsers so that they don't have awkward function signatures
78 lines
1.7 KiB
JavaScript
78 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
var extend = require('extend');
|
|
|
|
/**
|
|
* Normalizes synonymous tags to the canonical tag type listed on http://usejsdoc.org/.
|
|
*
|
|
* For example, given the input object:
|
|
*
|
|
* { tags: [
|
|
* { title: "virtual" },
|
|
* { title: "return", ... }
|
|
* ]}
|
|
*
|
|
* The output object will be:
|
|
*
|
|
* { tags: [
|
|
* { title: "abstract" },
|
|
* { title: "returns", ... }
|
|
* ]}
|
|
*
|
|
* The following synonyms are normalized:
|
|
*
|
|
* * virtual -> abstract
|
|
* * extends -> augments
|
|
* * constructor -> class
|
|
* * const -> constant
|
|
* * defaultvalue -> default
|
|
* * desc -> description
|
|
* * host -> external
|
|
* * fileoverview, overview -> file
|
|
* * emits -> fires
|
|
* * func, method -> function
|
|
* * var -> member
|
|
* * arg, argument -> param
|
|
* * prop -> property
|
|
* * return -> returns
|
|
* * exception -> throws
|
|
* * linkcode, linkplain -> link
|
|
*
|
|
* @name normalize
|
|
* @param {Object} comment parsed comment
|
|
* @return {Object} comment with normalized properties
|
|
*/
|
|
module.exports = function (comment) {
|
|
return extend({}, comment, {
|
|
tags: comment.tags.map(normalize)
|
|
});
|
|
};
|
|
|
|
var synonyms = {
|
|
'virtual': 'abstract',
|
|
'extends': 'augments',
|
|
'constructor': 'class',
|
|
'const': 'constant',
|
|
'defaultvalue': 'default',
|
|
'desc': 'description',
|
|
'host': 'external',
|
|
'fileoverview': 'file',
|
|
'overview': 'file',
|
|
'emits': 'fires',
|
|
'func': 'function',
|
|
'method': 'function',
|
|
'var': 'member',
|
|
'arg': 'param',
|
|
'argument': 'param',
|
|
'prop': 'property',
|
|
'return': 'returns',
|
|
'exception': 'throws',
|
|
'linkcode': 'link',
|
|
'linkplain': 'link'
|
|
};
|
|
|
|
function normalize(tag) {
|
|
var canonical = synonyms[tag.title];
|
|
return canonical ? extend({}, tag, { title: canonical }) : tag;
|
|
}
|