Doxygen@代码行号

Doxygen@代码行号,doxygen,Doxygen,有没有办法在@code中显示代码行号@endcode块?从doxygen手册中的屏幕截图来看,似乎有,但我找不到doxygen本身的选项,也找不到实现这一点的标记语法 我需要这样才能在代码块后编写类似“在上面的代码中,第3行”的内容 还测试了防护代码块,仍然没有得到数字。简短回答 似乎至少在当前版本(1.8.9)中添加了行号: 仅当使用 任何Python代码 细节 Python代码格式化程序 如果g_sourceFileDef的计算结果为TRUE,则Python代码格式化程序包含行号: /

有没有办法在
@code
中显示代码行号<代码>@endcode块?从doxygen手册中的屏幕截图来看,似乎有,但我找不到doxygen本身的选项,也找不到实现这一点的标记语法

我需要这样才能在代码块后编写类似“在上面的代码中,第3行”的内容

还测试了防护代码块,仍然没有得到数字。

简短回答 似乎至少在当前版本(1.8.9)中添加了行号:

  • 仅当使用
  • 任何Python代码

细节 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)
/*! 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)
( )

如果提供了它(非零),则从传递到
parseCode
/
parsePythonCode
FileDef*fd
初始化,否则从
new FileDef()
初始化:

g_sourceFileDef = fd;
<...>
if (fd==0)
{
  // create a dummy filedef for the example
  g_sourceFileDef = new FileDef("",(exName?exName:"generated"));
  cleanupSourceDef = TRUE;
}
()

它们按以下方式初始化:

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;
}
g_sourceFileDef=fd;
g_lineNumbers=fd=0&&showlinenumber;
如果(fd==0)
{
//为示例创建一个虚拟filedef
g_sourceFileDef=newfiledef(“,(exName?exName:“已生成”);
cleanupSourceDef=TRUE;
}
()

请注意,如果提供的
fd
值为0,则
g_线号
将保持
FALSE

HtmlDocVisitor 在
HtmlDocVisitor::visit
中的
parseCode
调用中,只有一个(对于
DocInclude::IncWithLines
,对应于
\includelineno
)传递非零
fd
: 因此,这似乎是唯一一个将导致行号包含在C代码清单中的命令



我想到了两个问题。1.您需要哪些“行号”-文件中doxygen注释的行号,或注释中引用的源的相对行号?2.您在doxygen手册的何处看到这些屏幕截图?我正在看在线手册的
\code
部分,但没有看到任何内容。@Cheeseminer:我对后面的行号(相对的行号)感兴趣。关于我的意思的一个例子,请查看手册的这一部分:嗯,出于兴趣,您正在记录什么代码语言?这个例子在Markdown部分和注释python代码中非常明显;而等效的C代码示例中没有它们。我想知道这是否是doxygen使用任何解释器进行降价的结果。这不是标准的降价。对不起,我没有建议了+对于这个问题,我确实在使用C代码。我不认为将{.py}添加到我的@代码中会很好地工作。。。看起来你是对的,但是-显然C不支持代码行,这是奇怪的任意性。