【问题标题】:Doxygen does not recognise function calls when the functions are passed as arguments to threads当函数作为参数传递给线程时,Doxygen 无法识别函数调用
【发布时间】:2020-02-12 05:51:25
【问题描述】:

简介

我使用 doxygen(版本 1.8.16)来记录一些 python 项目。主要进程之一将一些子进程称为线程。不幸的是,这在 doxygen 的调用图中没有被识别。我想这是因为这些函数作为参数传递(没有“()”)。

# functionA / functionB are not recognised as called functions by doxygen
t1 = Thread(target = functionA, args=(argA,argB))
t2 = Thread(target = functionB, args=(argC,argD))

t1.start()
t2.start()

t1.join()
t2.join()

当函数被间接调用时,有没有人为 doxygen 提供最佳实践或 hack 或过滤器来处理此类情况?

完整示例

要记录的示例 python 文件

## @file 
#@brief This is a simple doxygen test document.

## @brief A test function
# This is a simple test function for doxygen.
# It calls two functions, <em> functionA, functionB </em> by spawning threads, which is not recognised by doxygen.
def test():        
    t1 = Thread(target = functionA, args=(argA,argB))
    t2 = Thread(target = functionB, args=(argC,argD))
    t1.start()
    t2.start()
    t1.join()
    t2.join()

## @brief Another test function
# This is a simple test function for doxygen.
# It calls two functions, <em> <functionA, functionB> directly, which is recognised by doxygen and reflected in the callgraph.
def test_serial():        
    functionA()
    functionB()    

## @brief One test function
# @param testParA \b =1 A test constant
# @return \b str A test return
def functionA():
    testParA = 1
    testVarA = "test"
    return testVarA

## @brief Another test function
# @param testParB \b ="test" A test constant
# @return \b int Another test return
def functionB():
    testParB = "test"
    testVarB = 1
    return testVarB

doxygen 配置很长,无法在此处添加。您可以使用默认值并添加。 请注意,带有 dot 的 graphviz 需要安装且可查找(即添加到 PATH 环境中)

OPTIMIZE_OUTPUT_JAVA   = YES
EXTRACT_LOCAL_METHODS  = YES

REFERENCED_BY_RELATION = YES
REFERENCES_RELATION    = YES

HAVE_DOT               = YES
UML_LOOK               = YES

CALL_GRAPH             = YES
CALLER_GRAPH           = YES

【问题讨论】:

  • 您使用的是哪个版本的 doxygen?您能否从您的 sn-p 中举一个示例,其中还显示了缺少的功能(以及默认 doxygen 配置文件和您使用的配置文件之间的区别)?
  • 我添加了一个完整的例子。
  • 关于e&lt;functionA, functionB&gt; 用法的小注解/word,看来您误解了&lt; / &gt; 符号的含义,它们只是在doxygen 命令的文档表明只有一个词被用作参数,所以在这种情况下,这个词在 &lt;functionA, 之后终止,我想你要么想要:&lt;em&gt;&lt;functionA, functionB&gt;&lt;/em&gt; 要么 &lt;em&gt; functionA, functionB &lt;/em&gt;
  • 我试图重现这个问题,。但我什至没有看到test_serial 函数中的调用图,我也希望如此。有没有设置其他参数?当您使用 doxygen 1.8.16 时,您可以通过 doxygen -x Doxyfile 查看默认和使用的 Doxyfile 之间的差异。
  • 抱歉,回答延迟。我现在使用的一种 hack 解决方案是添加一个直接调用函数的 if False: 块,因此 doxygen 确实可以识别它。今天晚些时候我会再次检查代码@albert

标签: python multithreading doxygen


【解决方案1】:

在有人找到更好的答案之前,这里有一个对我有用的小技巧。只需将标准函数调用与线程版本一起包含在伪造的 if 块中。

def test():
  if False: #include in documentation, as doxygen does't recognise the threaded calls.
    functionA()
    functionB()        
  t1 = Thread(target = functionA, args=(argA,argB))
  t2 = Thread(target = functionB, args=(argC,argD))
  t1.start()
  t2.start()
  t1.join()
  t2.join()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-27
    • 2013-10-29
    • 2022-11-25
    • 2022-08-05
    • 2020-11-14
    • 1970-01-01
    相关资源
    最近更新 更多