简体   繁体   中英

How to add and use a tag on jsdoc?

I am trying to add a customTag to jsdoc. I have created a file in the plugins directory like this:

method.js

exports.defineTags = function(dictionary) {
    dictionary.defineTag("methodHttp", {
        mustHaveValue: true,
        canHaveType: false,
        canHaveName: true,
        onTagged: function(doclet, tag) {
            doclet.methodHttp = tag.value;
        }
    });
};

Then I added to my conf.json :

{
    "tags": {
        "allowUnknownTags": true
    },
    "source": {
        "includePattern": ".+\\.js(doc)?$",
        "excludePattern": "(^|\\/|\\\\)_"
    },
    "plugins": [ "plugins/method" ],
    "templates": {
        "cleverLinks": false,
        "monospaceLinks": false,
        "default": {
            "outputSourceFiles": true
        }
    },
    "jsVersion": 180
}

And now I try to get this on my template. I'm on method.tmpl.

I tried:

self.find('methodHttp')[0]
data.methodHttp[0]
data.methodHttp

But it doesn't work. What is wrong with my code?

jsDoc.defineTag does not support tags with uppercase char...

Though it seems to be a bug in their dictionary!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM