最近在為文檔的書寫苦惱,本來想自己寫一個文檔解析程序,名字都想好了。后來竟然在找資料的過程中發(fā)現(xiàn)了一個很好的C/C++ java文檔生成器Doxygen,真是無心插柳柳成行,我的原則是不要重復(fù)發(fā)明車輪,所以就是用這個開源的項目。給大家一些學(xué)習(xí)的鏈接看看,很容易入門的。
http://www.shnenglu.com/richardzeng/archive/2006/03/23/4508.html
http://www.chinaitpower.com/A/2003-01-19/47536.html
如果你要看全面的介紹文檔,可以在它的主頁去看:http://www.stack.nl/~dimitri/doxygen/,不過都是英文的。
問題:我的一個C文檔的注釋在Eclipse里面是中文寫的,所以編碼格式為utf-8。無論我Doxygen改成english或者chinese都沒有辦法正確顯示。我查看了生成的html的編碼竟然不是utf-8編碼,我想解決的辦法就是要自己來定義生成的html文檔。
高興,Show我生成的文檔。下面是C語言寫得一個函數(shù)
/*
*
*@brief?read?string?in?initialization?file
*
*retrieves?a?string?from?the?specified?section?in?an?initialization?file
*@param?section?[name?of?the?section?containing?the?key?name]
*@param?key?[name?of?the?section?containing?the?key?name]
*@param?value?[pointer?to?the?buffer?that?receives?the?retrieved?string]
*@param?size?[size?of?value?buffer]
*@param?file?[name?of?the?initialization?file]
*@return?[1?:?read?success;?0?:?read?fail]
*/
int ?read_profile_string(? const ? char ? * section,? const ? char ? * key, char ? * value,?? int ?size,? const ? char ? * file)
{
???? char ?buf[MAX_FILE_SIZE] = { 0 };
???? int ?file_size;
???? int ?sec_s,sec_e,key_s,key_e,?value_s,?value_e;
???? // check?parameters
????assert(section? != ?NULL? && ?strlen(section));
????assert(key? != ?NULL? && ?strlen(key));
????assert(value? != ?NULL);
????assert(size? > ? 0 );
????assert(file? != NULL? && strlen(key));
???? if (? ! load_ini_file(file,buf, & file_size))
???????? return ? 0 ;
???? if ( ! parse_file(section,key,buf, & sec_s, & sec_e, & key_s, & key_e, & value_s, & value_e))
????{
???????? return ? 0 ;? // not?find?the?key
????}
???? else
????{
???????? int ?cpcount? = ?value_e? - value_s;
???????? if (?size - 1 ? < ?cpcount)
????????{
????????????cpcount? = ??size - 1 ;
????????}
????
????????memset(value,? 0 ,?size);
????????memcpy(value,buf + value_s,?cpcount?);
????????value[cpcount]? = ? ' \0 ' ;
???????? return ? 1 ;
????}
}
*@brief?read?string?in?initialization?file
*
*retrieves?a?string?from?the?specified?section?in?an?initialization?file
*@param?section?[name?of?the?section?containing?the?key?name]
*@param?key?[name?of?the?section?containing?the?key?name]
*@param?value?[pointer?to?the?buffer?that?receives?the?retrieved?string]
*@param?size?[size?of?value?buffer]
*@param?file?[name?of?the?initialization?file]
*@return?[1?:?read?success;?0?:?read?fail]
*/
int ?read_profile_string(? const ? char ? * section,? const ? char ? * key, char ? * value,?? int ?size,? const ? char ? * file)
{
???? char ?buf[MAX_FILE_SIZE] = { 0 };
???? int ?file_size;
???? int ?sec_s,sec_e,key_s,key_e,?value_s,?value_e;
???? // check?parameters
????assert(section? != ?NULL? && ?strlen(section));
????assert(key? != ?NULL? && ?strlen(key));
????assert(value? != ?NULL);
????assert(size? > ? 0 );
????assert(file? != NULL? && strlen(key));
???? if (? ! load_ini_file(file,buf, & file_size))
???????? return ? 0 ;
???? if ( ! parse_file(section,key,buf, & sec_s, & sec_e, & key_s, & key_e, & value_s, & value_e))
????{
???????? return ? 0 ;? // not?find?the?key
????}
???? else
????{
???????? int ?cpcount? = ?value_e? - value_s;
???????? if (?size - 1 ? < ?cpcount)
????????{
????????????cpcount? = ??size - 1 ;
????????}
????
????????memset(value,? 0 ,?size);
????????memcpy(value,buf + value_s,?cpcount?);
????????value[cpcount]? = ? ' \0 ' ;
???????? return ? 1 ;
????}
}
生成的HTML文檔如下:
函數(shù)文檔
int read_profile_string | ( | const char *? | section, | |
const char *? | key, | |||
char *? | value, | |||
int? | size, | |||
const char *? | file | ? | ||
) |
read string in initialization file
retrieves a string from the specified section in an initialization file
- 參數(shù):
section? [name of the section containing the key name] key? [name of the section containing the key name] value? [pointer to the buffer that receives the retrieved string] size? [size of value buffer] file? [name of the initialization file]
- 返回:
- [1 : read success; 0 : read fail]