Skip to content

Commit

Permalink
Added custom publisher.
Browse files Browse the repository at this point in the history
  • Loading branch information
neogeek committed Sep 2, 2022
1 parent 362dd26 commit c5b9c43
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/dox.js
Expand Up @@ -406,9 +406,15 @@ exports.parseTagTypes = function(str, tag) {
}
return [];
}
var {parse, publish, NodeType} = require('jsdoctypeparser');
var {parse, publish, createDefaultPublisher, NodeType} = require('jsdoctypeparser');
var result = parse(str.substring(1, str.length - 1));

var customPublisher = Object.assign({}, createDefaultPublisher(), {
NAME(nameNode) {
return '<code>' + nameNode.name + '</code>';
}
});

var types = (function transform(type) {
if (type && type.type === NodeType.UNION) {
return [transform(type.left), transform(type.right)].flat();
Expand All @@ -428,7 +434,7 @@ exports.parseTagTypes = function(str, tag) {

if(tag) {
tag.types = types;
tag.typesDescription = '<code>' + publish(result) + '</code>';
tag.typesDescription = publish(result, customPublisher);
tag.optional = (tag.name && tag.name.slice(0,1) === '[') || result.type === NodeType.OPTIONAL;
tag.nullable = result.type === NodeType.NULLABLE;
tag.nonNullable = result.meta ? result.meta.syntax === 'SUFFIX_QUESTION_MARK' : false;
Expand Down

0 comments on commit c5b9c43

Please sign in to comment.