最近在为文档的书写苦恼,本来想自己写一个文档解析程序,名字都想好了。后来竟然在找资料的过程中发现了一个很好的C/C++ java文档生成器Doxygen,真是无心插柳柳成行,我的原则是不要重复发明车轮,所以就是用这个开源的项目。给大家一些学习的链接看看,很容易入门的。
http://www.cppblog.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语言写得一个函数
/*
*
*@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文档如下:
函数文档
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
- 参数:
| 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]
posted on 2007-01-16 13:41
天下无双 阅读(2856)
评论(4) 编辑 收藏 引用 所属分类:
C/C++