JSDoc继承参数文档 [英] JSDoc inheriting parameter documentation

查看:185
本文介绍了JSDoc继承参数文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个功能,其中一个扩展了另一个功能.

Let's say I have two functions, where one extends the other.

/**
* @abstract
* @param {Object} settings
* @param {Number} settings.x
* @param {Number} settings.y
* 
*/
function Base(settings) {
    this.x = settings.x;
    this.y = settings.y;
}

/**
* @extends Base
*/
function Foo(settings) {
    Base.call(this, settings);    
}

这两个函数位于两个单独的文件中.有什么方法可以从Foo函数的Base函数继承参数文档,还是必须两次编写文档?

These two functions are in two separate files. Is there any way I can inherit the parameter documentation from the Base function in my Foo function, or do I have to write the documentation twice?

我曾尝试将settings设为@typedef:

/**
 * @typedef {Object} BaseSettings
 * @property {Number} x
 * @property {Number} y
 *
 */

/**
* @extends Base
* @param {BaseSettings} settings
*/
function Foo(settings) {
    Base.call(this, settings);    
}

但这只是链接到全局类型定义,我希望参数与函数记录在同一页上.但这是否有可能,而无需两次编写文档?

But this just links to a global Type Definitions, and I want the parameter documented on the same page as the function. But is this even possible, without writing the documentation twice?

推荐答案

我认为无法做到这一点.您可以像在问题中一样通过@typedef对其进行文档记录,但它只会将类型链接到其定义.我不知道内联已定义类型的方法.

I don't think this can be done. You can document it via @typedef as in your question but it will just link the type to it's definition. I'm not aware of a way of inlining a defined type.

这篇关于JSDoc继承参数文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆