简答
似乎至少在当前版本(1.8.9)中增加了行号:
详情
Python 代码格式化程序
如果g_sourceFileDef 评估为TRUE,则Python 代码格式化程序包括行号:
/*! start a new line of code, inserting a line number if g_sourceFileDef
* is TRUE. If a definition starts at the current line, then the line
* number is linked to the documentation of that definition.
*/
static void startCodeLine()
{
//if (g_currentFontClass) { g_code->endFontClass(); }
if (g_sourceFileDef)
(https://github.com/doxygen/doxygen/blob/Release_1_8_9/src/pycode.l#L356
)
如果提供(非零),则从 FileDef *fd 传递到 parseCode/parsePythonCode 初始化,否则从 new FileDef(<...>) 初始化:
g_sourceFileDef = fd;
<...>
if (fd==0)
{
// create a dummy filedef for the example
g_sourceFileDef = new FileDef("",(exName?exName:"generated"));
cleanupSourceDef = TRUE;
}
(https://github.com/doxygen/doxygen/blob/Release_1_8_9/src/pycode.l#L1458)
所以似乎所有 Python 代码都包含行号
C 代码格式化程序
C 代码格式化程序有一个附加变量 g_lineNumbers,如果 g_sourceFileDef 和 g_lineNumbers 评估为 TRUE,则包括行号:
/*! start a new line of code, inserting a line number if g_sourceFileDef
* is TRUE. If a definition starts at the current line, then the line
* number is linked to the documentation of that definition.
*/
static void startCodeLine()
{
//if (g_currentFontClass) { g_code->endFontClass(); }
if (g_sourceFileDef && g_lineNumbers)
(https://github.com/doxygen/doxygen/blob/Release_1_8_9/src/code.l#L486)
它们的初始化方式如下:
g_sourceFileDef = fd;
g_lineNumbers = fd!=0 && showLineNumbers;
<...>
if (fd==0)
{
// create a dummy filedef for the example
g_sourceFileDef = new FileDef("",(exName?exName:"generated"));
cleanupSourceDef = TRUE;
}
(https://github.com/doxygen/doxygen/blob/Release_1_8_9/src/code.l#L3623)
请注意,g_lineNumbers 仍然是 FALSE,如果提供的 fd 值为 0
HtmlDocVisitor
在parseCode 调用HtmlDocVisitor::visit 中,只有一个(对于DocInclude::IncWithLines,对应于\includelineno)通过非零fd:
https://github.com/doxygen/doxygen/blob/Release_1_8_9/src/htmldocvisitor.cpp#L540
所以这似乎是唯一会导致 C 代码列表中包含行号的命令