Doxygen:强制记录未声明的功能 [英] Doxygen: Force undeclared functions to be documented

查看:78
本文介绍了Doxygen:强制记录未声明的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的C ++程序具有内置的脚本接口,并且能够在其中运行脚本。脚本可以访问C ++程序提供的便捷功能。

Our C++ program has a built-in script interface and is able to run scripts in it. The scripts have access to convenience functions provided by the C++ program.

现在,我们希望Doxygen创建脚本可以访问的功能的文档。这样的函数声明如下:

Now we would like Doxygen to create the documentation of the functions the script has access to. Such a function declaration looks like this:

void ScriptEngine::load_script(const QString &path) {       
//...

    /*! \fn sleep_ms(const unsigned int timeout_ms)
        \brief sleeps for timeout_ms milliseconds.
        \param timeout_ms 
    */
    (*lua)["sleep_ms"] = [](const unsigned int timeout_ms) {
        //sleep(timeout_ms)
    };

    //more convenience functions..
//...
}

显然Doxygen将不包含

Obviously Doxygen won't include a

sleep_ms(const unsigned int timeout_ms)

进入文档。有办法告诉Doxygen这样做吗?

into the documentation. Is there a way to to tell Doxygen to do so?

推荐答案

执行此操作:


  1. 在Doxyfile中添加以下行:

  1. Add the following line to your Doxyfile:

PREDEFINED = _DOXYGEN_


  • 确保 ENABLE_PREPROCESSING 标签在Doxyfile中设置为 YES

  • Make sure the ENABLE_PREPROCESSING tag in the Doxyfile is set to YES.

    将未声明函数的声明和文档放在 #ifdef _DOXYGEN _ 部分。

    Put your declarations and documentation for the undeclared functions inside an #ifdef _DOXYGEN_ section.

    #ifdef _DOXYGEN_
        /*! \fn sleep_ms(const unsigned int timeout_ms) 
            \brief sleeps for timeout_ms milliseconds.
            \param timeout_ms
        */
        void sleep_ms(const unsigned int timeout_ms);
    #endif
    


  • 不要将上述代码放在如先前尝试过的方法或函数(例如 ScriptEngine :: load_script())中。并且不要将其放在名称空间或类中,除非实际上声明的函数是该名称空间或类的成员。

    Don't put the above code inside a method or function such as ScriptEngine::load_script(), as you previously tried. And don't put it inside a namespace or class, unless in fact the function being declared is a member of that namespace or class.

    使用此方法,您的声明将不会在正常构建期间创建链接器错误,但Doxygen会看到它。

    With this method, your declarations will not create linker errors during a normal build, but will be seen by Doxygen.

    另请参见

    http://www.doxygen.nl/manual/config.html #cfg_predefined

    这篇关于Doxygen:强制记录未声明的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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