Doxygen for C++使用说明——注释代码一

写这一节的时候,我在想网上有众多的参考文献,外加官网上的,要是我再将它们重复一遍,也没什么意思。网上资料很多,但是他们有一个共同的缺点是都是罗列用法,然后显示效果。这些都是比较散的,我想是不是可以结合一个具体的范例来讲解Doxygen的用法呢?这样大家既可以学习到语法,也可以直接拿这个模板来用。
我自己在网上下了个模板,并且加了一些内容。这是显示效果链接。下面我将具体来介绍:
先看test.h.

/*** \mainpage libtest** \section intro_sec oFono telephony client APIs.** This library provides easy to use APIs to use by hiding all details.** \section install_sec Installation** \subsection Download the RPM package** Go to download page to download the RPM package.** \subsection Install** Run the following command in terminal to install:* \code* $rpm -ivh libtest-api.rpm* \endcode** \section usage_sec How to use this library** \subsection source Include in file** To use this library, you must include the headers in your source file:* \code* #include <test.h>* \endcode* If you use other interfaces, you must include it too, like message:* \code* #include <test.h>* #include <test-helper.h>* \endcode** \subsection compile How to compile** To build with this library you can use pkg-config to get link options:* \code* $pkg-config --cflags --libs test-api* \endcode*/
/*** \file test.h* \brief API interface test is in charge of path management** It provides APIs to query path list and to query properties for a specific path.** \note* This interface requirs to run in main loop thread because some GLib dependency.** Besides, you should keep main loop idle for most of times in order to get callbacks and make sure* libtest-api process signals successfully. This means you should put business logic into a separate* thread.*/
#ifndef _TEST_H
#define _TEST_H/*** \enum API_RESULT_CODE Indicating whether API operation succeed or fail.*/
enum API_RESULT_CODE {API_SUCCESS, /**< API call is successfully */API_FAILED, /**< API call is failed */
};/*** \brief Initialize libtest-api.** This function should be the first one to call when using libtest-api. It does essential initializations.* This function is synchronous.** \return #API_RESULT_CODE indicating whether this call success or failed.** \see test_deinit** \par Sample code:* \code* if (test_init() != OFONO_API_SUCCESS) {*     printf("error occurred, failed to init test\n");*     return;* }* // operations goes here* if (test_deinit() != OFONO_API_SUCCESS) {*     printf("failed to deinit \n");*     return;* }* \endcode*/
int test_init();/*** \brief Finalize libtest-api** This function is designated to be called when no longer needs libtest-api to release resources in libtest* and do some finalization.** \note* It is an error to call any APIs after calling test_deinit()** \return #API_RESULT_CODE indicating whether this call success or failed.** \see test_init*/
int test_deinit();/*** \brief Obtain current list of path ** \param [out] paths a pointer to an array of strings* \param [out] count indicating the count of path.** \note* This function will allocate memory for path array. So caller must free the array, but should not free each item.** \return #API_RESULT_CODE indicating whether this call success or failed.** \par Sample code:* \code*    char **path = NULL;*    int count = 0;*    test_get_paths(&path, &count);*    // use the path*    free(path);*    path = NULL;* \endcode*/
int test_get_paths(char ***paths, int *count);#endif

以上为代码,下面我们将具体说说。

\mainpage

一般我们为一个C++项目建立一个说明文档,首先应该有个总的项目说明,简要介绍项目的背景、安装路径、使用方法等。这时我们可以在\mainpage中完成。它的语法为:
用法:

\mainpage [(title)]

Qt风格)示例:

/*! \mainpage My Personal Index Page** \section intro_sec Introduction** This is the introduction.** \section install_sec Installation** \subsection step1 Step 1: Opening the box** etc...*/

查看效果。
效果与上一模一样的(JavaDoc风格)的代码如下:

/** \mainpage My Personal Index Page** \section intro_sec Introduction** This is the introduction.** \section install_sec Installation** \subsection step1 Step 1: Opening the box** etc...*/

最上面我们给的源码实际上使用的是JavaDoc风格。
一般, JavaDoc以两个**开头:

/*** ... text ...*/

Qt 风格以*!开头

/*!* ... text ...*/

两种用法,注释块中间的星号是可选, 所以将注释块写成:

/*!... text ...
*/

\section

用法:

\section <section-name> (section title)

说明:
section-name为索引名,section title为章节的标题
我们再介绍一个和\mainpage相似的概念。

\page

用法:

\page <name> (title)

示例:

/*! \page page1 A documentation page\tableofcontentsLeading text.\section sec An example sectionThis page contains the subsections \ref subsection1 and \ref subsection2.For more info see page \ref page2.\subsection subsection1 The first subsectionText.\subsection subsection2 The second subsectionMore text.
*//*! \page page2 Another pageEven more info.
*/

查看效果。
注意:里面的 \ref 是索引的意思。

\code

用法:

 \code [ '{'<word>'}']

示例:

\code{.py}class Python:pass\endcode\code{.cpp}class Cpp {};\endcode

\brief

用法:

/*! \brief Brief description.**  Detailed description starts here.*/

如果JAVADOC_AUTOBRIEF 被设置为 YES,则JavaDoc风格将注释块中的第一个句子视为简要描述, 这个句子可以以句号’.’、空格或者空行来结束:
用法:

/** Brief description which ends at this dot. Details follow*  here.*/

类的注释

如下为使用Qt风格的C++代码注释。

//!  A test class. 
/*!A more elaborate class description.
*/
class Test
{public://! An enum./*! More detailed enum description. */enum TEnum { TVal1, /*!< Enum value TVal1. */  TVal2, /*!< Enum value TVal2. */  TVal3  /*!< Enum value TVal3. */  } //! Enum pointer./*! Details. */*enumPtr, //! Enum variable./*! Details. */enumVar;  //! A constructor./*!A more elaborate description of the constructor.*/Test();//! A destructor./*!A more elaborate description of the destructor.*/~Test();//! A normal member taking two arguments and returning an integer value./*!\param a an integer argument.\param s a constant character pointer.\return The test results\sa Test(), ~Test(), testMeToo() and publicVar()*/int testMe(int a,const char *s);//! A pure virtual member./*!\sa testMe()\param c1 the first argument.\param c2 the second argument.*/virtual void testMeToo(char c1,char c2) = 0;//! A public variable./*!Details.*/int publicVar;//! A function variable./*!Details.*/int (*handler)(int a,int b);
};

查看效果。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/259095.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

DevOps的前世今生

2019独角兽企业重金招聘Python工程师标准>>> 目前在国外&#xff0c;互联网巨头如Google、Facebook、Amazon、LinkedIn、Netflix、Airbnb&#xff0c;传统软件公司如Adobe、IBM、Microsoft、SAP等&#xff0c;亦或是网络业务非核心企业如苹果、沃尔玛、索尼影视娱乐…

【转】最牛B的编码套路

最近&#xff0c;我大量阅读了Steve Yegge的文章。其中有一篇叫“Practicing Programming”&#xff08;练习编程&#xff09;&#xff0c;写成于2005年&#xff0c;读后令我惊讶不已&#xff1a; 与你所相信的恰恰相反&#xff0c;单纯地每天埋头于工作并不能算是真正意义上的…

ecshop 广告设置

最近公司准备做个商城&#xff0c;让我从JAVA转过去&#xff0c;好吧&#xff0c;先看下吧&#xff0c;反正也得做。接到手里的是一套已经成型的模板&#xff0c;但是二次开发必须得了解下机制、文件、响应、设置什么的&#xff0c;也是个新手&#xff0c;写点东西给后面更新的…

linux 信号_Linux信号机制

信号就是一条消息&#xff0c;通知进程系统中发生了什么事&#xff0c;每种信号都对应着某种系统事件。一般的底层硬件异常是由内核的异常处理程序处理的&#xff0c;它对用户进程来说是透明的。而信号机制&#xff0c;提供了一种方法通知用户进程发生了这些异常。例如&#xf…

DOxygen for C++使用说明——添加数学公式

公式 Doxygen允许你把 公式显示在最终的输出中&#xff08;这个功能仅限于HTML和输出&#xff09;.为了可以在HTML documentation显示公式&#xff08;转化为图片&#xff09;&#xff0c;你必须安装以下软件&#xff1a; latex: 编译器, 被用来解析公式, 首先提取公式写到一…

VC2010下Qt5的中文乱码问题

要搞清楚这个问题&#xff0c;先要弄明白编码。但是编码问题实在太复杂&#xff0c;这里肯定讲不开。 我先找一个例子&#xff0c;比如&#xff1a;“中文” 的 Unicode 码点/UTF8编码/GBK 分别是多少。 先去这个网站&#xff0c;输入 “中文” 查询对应的 Unicode 码点/UTF8编…

Tomcat 的 DefaultServlet

问题描述&#xff1a; 群里有人测试 Spring MVC&#xff0c;没有配置任何Controller&#xff0c;只配置了一个view resolver&#xff0c;指定了前缀后缀。 然后&#xff0c;他问的是 当访问 localhost:8080/test 的时候&#xff0c;为什么会被重定向到 localhost:8080/test/ &a…

Python学习(七)面向对象 ——封装

Python 类的封装 承接上一节&#xff0c;学了Student类的定义及实例化&#xff0c;每个实例都拥有各自的name和score。现在若需要打印一个学生的成绩&#xff0c;可定义函数 print_score() 该函数为类外的函数&#xff0c;如下&#xff1a; 1 class Student(object):2 def …

spss练习数据_SPSS篇——如何在成千上百万个数据中标识重复个案

本文就带大家来学习一个小技巧&#xff0c;如何运用SPSS标识重复个案。我们都知道在Excel中&#xff0c;通常会用到“筛选”功能来选出指定条件相同的单元格。那么在SPSS中&#xff0c;如何在成千上百万个数据中筛选出重复的个案呢&#xff1f; 小编就是要告诉你&#xff0c;几…

DOxygen for C++使用说明——Markdown支持

自Doxygen 版本1.8.0&#xff0c;Markdown被引进。 接下来&#xff0c;我们将先简单介绍标准的Markdown语法&#xff0c;读者可以进入Markdown官网查询更详细的细节。然后讨论一下Doxygen支持的Markdown扩展&#xff0c;最后讨论一下Doxygen对Markdown标准的实现细节。 Stand…

方程式漏洞之复现window2008/win7 远程命令执行漏洞

前几天就想写的&#xff0c;因为一些缘故就没写。此次是在外网环境下进行的。大家在内网中也一个样。 方法&#xff1a; 使用Eternalblue模块&#xff0c;剑测是否有漏洞然后msf生成一个dll直接反弹shell. PS&#xff1a;win版本的不知道缘何生成出来的dll是0kb 我就在自己本地…

C++空类和string类

1. 空类 1.1 空类默认哪六个成员函数。 1 class Empty2 {3 public:4 Empty(); //缺省构造函数 Empty e;5 Empty( const Empty& ); //拷贝构造函数 Empty e2(e1);6 ~Empty(); //析构函数7 Empty& operator( const Empty& ); //赋值运算符…

客服会话 小程序 如何发起_小程序、公众号、App三者如何融合布局?这里有一份避坑指南...

对产品经理来说&#xff0c;小程序无疑是2020年最火爆的词之一了。我们能看到&#xff0c;就在今年疫情期间&#xff0c;小程序DAU达到4.5亿&#xff0c;而超市、生鲜果蔬、社区购物等都同比增长100个点左右&#xff0c;小程序的商业价值很明显地在快速释放。小程序如此火爆&am…

DOxygen for C++使用说明——注释代码二

这一次我在谷歌搜索中检索到了Doxygen在github的仓库&#xff0c;进去一看&#xff0c;令人大喜&#xff0c;github仓库里含有了一个Doxygen的官方配置文件Doxyfile,于是下载下来&#xff0c;发现Doxyfile已经配置了将仓库中的\src文件编译成Documentation,并且将结果放在了dox…

python super()(转载)

一、问题的发现与提出 在Python类的方法&#xff08;method&#xff09;中&#xff0c;要调用父类的某个方法&#xff0c;在Python 2.2以前&#xff0c;通常的写法如代码段1&#xff1a; 代码段1&#xff1a; class A:def __init__(self):print "enter A"print "…

Swagger+Spring mvc生成Restful接口文档

2019独角兽企业重金招聘Python工程师标准>>> Swagger 是一个规范和完整的框架&#xff0c;用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。总体目标是使客户端和文件系统作为服务器以同样的速度来更新。文件的方法&#xff0c;参数和模型紧密集成到服务器端…

JavaScript——变量与基本数据类型

前言 JavaScript中的变量为松散类型&#xff0c;所谓松散类型就是指当一个变量被申明出来就可以保存任意类型的值&#xff0c;就是不像SQL一样申明某个键值为int就只能保存整型数值&#xff0c;申明varchar只能保存字符串。一个变量所保存值的类型也可以改变&#xff0c;这在Ja…

vscode可以打开jupyternotebook吗_刚刚,官方宣布 VS Code 支持 Python 全开发了!

关注Python高校每天早上23:10准时推送北京时间 2019 年 9 月 21 日&#xff0c;PyCon China 2019 在上海举行。在下午的演讲中&#xff0c;来自微软开发工具事业部的资深研发工程师韩骏做了主题为《Python 与 Visual Studio Code 在人工智能应用中的最佳 Azure 实践》的演讲。在…

C++类的内联成员函数应放在哪

今天复习C Primer的时候&#xff0c;看到了关于C类的内联成员函数的放置&#xff0c;应该放在头文件中。那么这到底是为什么 呢&#xff1f;仅仅是一种代码规范问题还是必须这样做呢&#xff1f; 下面我就来讲讲我自己的理解吧。要彻底理解这个问题&#xff0c;首先就要了解下函…

python selenium自动化(三)Chrome Webdriver的兼容

当一个自动化测试被实现在一个浏览器之后&#xff0c;我们会希望我们的测试能够覆盖到尽量多的别的浏览器。通过跨平台的测试来保证我们的程序在多个浏览器下都能正常工作。 在安装了selenium之后&#xff0c;firefox webdriver和IE webdriver就已经是ready to use的了&#xf…