我如何以适当的方式写代码注释和文档?有什么标准吗? [英] How do I write in-code comments and documentation in a proper way? Is there any standard for this?

查看:206
本文介绍了我如何以适当的方式写代码注释和文档?有什么标准吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过注释行在我的代码中添加文档。

这是否有任何标准格式?

I want to add documentation in my code by means of comment lines.
Is there any standard format for this?

考虑下面的代码:

class Arithmetic
{
    // This method adds two numbers, and returns the result.
    // dbNum1 is the first number to add, and dbNum2 is second.
    // The returning value is dbNum1+dbNum2.
    static double AddTwoNumbers(double dbNum1, double dbNum2);
}

对于这个示例代码,有没有更好的方式来写注释行?

For this example code, is there any better way of writing the comment lines?

推荐答案

对于c ++,没有像javadoc这样的标准,但某些文档工具是流行的,常用的。在我的头顶,我可以提到 doxygen

For c++ there isn't a standard, like javadoc, but certain documentation tools are popular and common to use. Off the top of my head, I can mention doxygen.

Doxygen还支持熟悉的javadoc风格,即:

Doxygen also supports the familiar javadoc style, ie:

/**
   This method adds two numbers, and returns the result.
   @param dbNum1 is the first number to add
   @param dbNum2 is second.
   @return The returning value is dbNum1+dbNum2.
*/
static double AddTwoNumbers(double dbNum1, double dbNum2);

这篇关于我如何以适当的方式写代码注释和文档?有什么标准吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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