sakemoto-san

ITエンジニアがWebサービス全般について書いていきます。

Documentating codes

Source codeの中にドキュメントを書く各種の方法.だいたい統一されている. 結局,javaならjavadocに沿って,pythonならpydocに沿って書けば あとはdoxygenが自動的に生成してくれる. ただし,C++とかpython/pydocはあまりいい記述方式がないので, 全部javadoc形式に合わせるのが得策だ ろう.

Sample

念のためサンプルを置いておく

#include <iostream>

/** /class Mother2
* /brief This is BRIEF!!!
*
* I have a good cup.
*/
class Mother {
public:
/** Constructor!
*
* This is constructor, you know. This function does 
* - get the age from args
* - set the age to local var.
* -# hoge
* -# foo
* -# bar
* - hoge
*/
Mother(int age_=0){
age = age_;
} 
int Age(){return age;}

/**
* @author Masahiko Kitamura
* @param a first parameter to be processed
* @param b sencond parameter to be processed
* @return return (a+b)
*/
int Plus(int a, int b){ return a+b;}
private:
int age; ///< This is your age!
protected:

};

int main(){
std::cout << "Hello, world! " << std::endl;
Mother m;
std::cout << "m.Age(): " << m.Age() << std::endl;
return 0;
}

その他

ドキュメント化は,このインライン方式と,あとはusageヘルプ(コマンドをオプション無し実行した時のヘルプ表示)の2通りで書いておいたほうが良いだろう.

ドキュメント以外にテストコードもinline化できるので,ソースコードにいろいろ含まれそう.

Reference