You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Doxygen为Fortran模块内的interface接口编写文档

Doxygen识别Fortran interface文档的解决方案

1. 调整Doxyfile配置

打开项目对应的Doxyfile配置文件,修改以下参数:

  • OPTIMIZE_FOR_FORTRAN = YES 开启Fortran语法专项优化
  • FORTRAN_ADD_INTERFACES = YES 强制Doxygen扫描并解析interface块内容
  • 如果未开启EXTRACT_ALL = YES,需要确保模块和接口都有显式文档注释,否则会被判定为私有成员忽略

2. 调整代码注释写法

原有注释仅需要微调位置和补充外层模块注释即可生效,调整后的完整代码如下:

!> \brief 测试用模块,包含阶乘计算接口
module test_mod
    implicit none

    !> \brief
    !> Return the factorial for a whole integer input. This is basically `Gamma( intNum + 1 )`.
    !>
    !> \param[in]   positiveInteger :   The input positive integer whose factorial must be computed.
    !>
    !> \return
    !> `factorial`  :   The factorial.
    interface
        pure function getFactorial(positiveInteger) result(factorial)
            use iso_fortran_env, only: IK => int32, RK => real64
            implicit none
            integer(IK), intent(in) :: positiveInteger
            real(RK)                :: factorial
        end function getFactorial
    end interface

end module test_mod

核心调整点:

  • 给外层test_mod模块添加了基础文档注释,避免Doxygen跳过整个模块内容的解析
  • 接口注释紧跟在interface关键字的上一行,不要和interface块之间留空行

3. 验证效果

重新运行Doxygen生成文档,即可在模块的接口列表下看到getFactorial的完整文档说明。

内容的提问来源于stack exchange,提问作者Scientist

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 16:27:04