本文介绍了如何在jsdoc上添加和使用标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将customTag添加到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;
        }
    });
};

然后我添加到 conf.json

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

现在我尝试在我的模板上获取此信息。我在method.tmpl。

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

我试过:

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

但它不起作用。我的代码出了什么问题?

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

推荐答案

jsDoc.defineTag 没有支持带有大写字符的标签...

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

虽然它们似乎是字典中的错误!

Though it seems to be a bug in their dictionary!

这篇关于如何在jsdoc上添加和使用标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 08:01