Is it possible to tell jsdoc to look in a file separate from the source code for documentation of that code?

回眸只為那壹抹淺笑 提交于 2019-12-05 06:01:58

With jsdoc3, I do not think there is a way to get what a perfect solution without having to write a new plugin. (I do not know of a plugin that would already do it.)

However, it is possible to abuse the jsdoc tags to get something which is not perfect but is functional.

/**
 * @module foo
 */


/**
 * Used when making an example of the argument.
 * @see {module:foo.example_type}
 */
function example(argument) {
    //...
}

/**
 * someotherplace
 * @typedef {function} module:foo.example_type
 * @param argument The victim
 * @since forever
 */

The key is to create a type definition with a unique name, and then use @see to link to that definition. @module and module: are just there to show it can be done with modules. They can just be stripped for cases where modules are not needed.

What about {@link} tag and tutorials {@tutorial} tags? From documentation:

{@tutorial} Tutorials

Tutorials mechanism allows you to include not only short code-related technical API documentation, but also longer, more explaining, full-page tutorials

The {@link} tag allows you to create a HTML link to some other documented symbol from within the text of any tag's description.

Usage:

@anyTag This is some text {@link otherSymbol}.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!