当前位置:  开发笔记 > 编程语言 > 正文

评论javascript对象和方法的首选方法是什么

如何解决《评论javascript对象和方法的首选方法是什么》经验,为你挑选了3个好方法。

我习惯使用atlas,首选(据我所知)方法是使用xml注释,例如:

/// 
///   Method to calculate distance between two points
/// 
///
/// First point
/// Second point
/// 
function calculatePointDistance(pointA, pointB) { ... }

最近我一直在寻找其他第三方JavaScript库,我看到的语法如下:

/*
 * some comment here
 * another comment here
 * ...
 */
 function blahblah() { ... }

作为奖励,如果有任何可以读取"首选"评论风格的JavaScript API生成器,请告诉我.



1> Chris MacDon..:

有JSDoc

/**
 * Shape is an abstract base class. It is defined simply
 * to have something to inherit from for geometric 
 * subclasses
 * @constructor
 */
function Shape(color){
 this.color = color;
}



2> molokoloco..:

越简越好,评论很好,使用它们:)

var something = 10; // My comment

/*
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
*/

function bigThing() {
    // ...
}

但对于自动生成的文档......

/**
 * Adds two numbers.
 * @param {number} num1 The first number to add.
 * @param {number} num2 The second number to add.
 * @return {number} The result of adding num1 and num2.
 */
function bigThing() {
    // ...
}


我不同意“越简单越好”的说法,您应该在IDE中安装一个注释加载项以自动生成第二种样式,因为它很有帮助

3> Chris MacDon..:

雅虎提供YUIDoc.

它有很好的文档,由雅虎支持,是一个Node.js应用程序.

它也使用了许多相同的语法,因此不需要进行很多更改就可以从一个转换到另一个.

推荐阅读
乐韵答题
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有