当函数作为参数传递给线程时,Doxygen 无法识别函数调用

Doxygen does not recognise function calls when the functions are passed as arguments to threads

简介

我使用 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()

当函数被间接调用时,是否有人有最佳实践或 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 配置太长,无法在此处添加。您可以使用默认值并添加。 请注意,带点的 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

在有人找到更好的答案之前,这里有一个对我有用的小技巧。只需将标准函数调用与线程版本一起包含在伪造的 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()