JavaScript是否具有评论功能的标准? [英] Does JavaScript have a standard for commenting functions?

查看:129
本文介绍了JavaScript是否具有评论功能的标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些客户端JavaScript代码,并想知道如何评论我的功能。



我来自C#背景,那里有一个官方推荐的评论风格我遵循的由Microsoft记录的,这允许编译器和其他工具自动生成文档。



同样,PHP的PHPDoc样式是无处不在的,正在成为PHP-FIG推荐的官方标准



JavaScript类似地具有普遍接受的工具链,标准或

解决方案

您可以使用 jsdoc 样式,让您稍后生成文档



如此

  / ** 
*添加两个数字
* @param {Number} a
* @param {Number} b
* @return {Number $ sum
* /
函数sum(a,b){
return a + b;
}

编辑:如果您使用AngularJS,您可以参考 http://google.github.io/styleguide/angularjs-google-style.html


I am currently writing some client side JavaScript code and wondering how to comment my functions.

I come from a C# background, where there is an officially recommended commenting style documented by Microsoft which I follow, which allows the compiler and other tools to auto-generate documentation.

Similarly, PHP's PHPDoc style is ubiquitous and on its way to becoming an official standard recommended by PHP-FIG.

Does JavaScript similarly have a universally accepted tool-chain, standard, or set of best practices that I can apply when commenting my functions?

解决方案

You can use jsdoc style which will let you generate documentation later

like so

/**
 * Adds two numbers
 * @param {Number} a 
 * @param {Number} b
 * @return {Number} sum
 */
 function sum(a,b) { 
   return a + b;
 }

EDIT: If you are using AngularJS, then you can refer http://google.github.io/styleguide/angularjs-google-style.html

这篇关于JavaScript是否具有评论功能的标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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