Doxygen:如何链接到用不受支持的语言编写的源文件?
我们正在使用 Doxygen 为跨语言项目生成 HTML 文档。在某些文档中,我想链接到以 Doxygen 不支持的语言编写的文件源(实际上,它是 Visual Studio T4 模板)。
目前,我只是在文档注释中写出文件名。
在 Doxyfile 中包含文件的扩展名可以使链接正常工作,但 Doxygen 完全误解了该文件,并链接到这个被误解的文档,而不是源文件,这正是我想要的。
但是,如果我排除文件的扩展名,Doxygen 根本不会占用该文件。
是否有任何 Doxygen 命令可以直接链接到文件的源代码,而不是其文档?
我并不关心 Doxygen 是否为该文件生成了不正确的文档:只要我可以直接链接到文件的源而不是文档,我就很高兴了。这些文档本身显然是不正确的,因此不会损害页面的生成和可能被发现。
有什么想法吗?
We are using Doxygen for generating HTML docs for a cross-language project. In some documentation, I would like to link to the source a of file written in a language not supported by Doxygen (actually, it's a Visual Studio T4 template).
Currently, I simply write out the file name inside the doc comment.
Including the file's extension in the Doxyfile makes the link work, but Doxygen completely misinterprets the file, and links to this misinterpreted documentation, instead of the source file, which is what I want.
If I exclude the file's extension, however, Doxygen does not take up the file at all.
Is there any Doxygen command to directly link to a file's source, instead of its documentation?
I don't really care that Doxygen is generating incorrect documentation for this file: as long as I can link directly to the file's source and not the documentation, I'll be happy enough. The docs themselves are so clearly incorrect that it does not harm that the page is generated and potentially could be found.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这是否是您正在寻找的答案,但以下是一些希望有用的要点:
您可以使用
\include
命令。来自 Doxygen 手册:<块引用>
\include <文件名>
此命令可用于将源文件作为代码块包含在内。该命令将包含文件的名称作为参数。可以使用 Doxygen 配置文件的
EXAMPLE_PATH
标签指定源文件或目录。使用
\include
命令相当于将文件插入到文档块中并用\code
和\endcode
命令包围它。此外,来自此页面
<块引用>
文件链接。
所有包含点 (.)(不是单词中最后一个字符)的单词都被视为文件名。如果该单词确实是记录的输入文件的名称,则会自动创建指向该文件的文档的链接。
最后,来自 Doxygen 常见问题解答:
<块引用>
11。 Doxygen 会自动在运行文本中的某个位置生成一个指向 MyClass 类的链接。如何在某个地方防止这种情况发生?
在类名前面加上
%
。像这样:%MyClass
。然后,Doxygen 将删除%
并保持单词未链接。从最后两点来看,如果 Doxygen 找到它认为是文件名的内容,它似乎会自动链接到文档文件。
%
字符将阻止 Doxygen 执行此操作,但是您需要找到一种方法来链接到\include
中包含的代码。另外,请参阅我对您的问题的评论,了解如何停止 Doxygen 为 Visual Studio T4 模板生成文档 - 我认为如果您遵循评论中的建议,那么 Doxygen 将不会自动添加指向该文件(不正确)文档的链接。
编辑:正如问题评论中所讨论的,一种可能的解决方案是为源代码创建一个新页面并将源代码直接包含到该页面上。例如,可以使用
这将在文档的“相关页面”选项卡下包含一个标题为“Visual Studio T4 Template”的页面,可以使用标签
src_code
引用该页面(即使用\ref src_code
链接到该页面/源代码)。最后,如果您要包含 C/C++ 代码,则可以将
\include
与\code
和\endcode
命令括起来以进行语法处理突出显示代码。I'm not sure if this is the answer you are looking for, but a few hopefully useful points follow:
You can include blocks of source code using the
\include
command. From the Doxygen manual:Also, from this page
and finally, from the Doxygen FAQ:
From the last two points, it seems that Doxygen will automatically link to a documented file if it finds what it thinks is a filename. The
%
character will prevent Doxygen from doing this, but then you will need to find a way to link to the code you included with\include
.Also, see my comment to your question for how to stop Doxygen generating documentation for your Visual Studio T4 template - I presume that if you followed the suggestion in the comment then Doxygen won't automatically put a link to that file's (incorrect) documentation.
Edit: As discussed in the comments to the question, one possible solution is to create a new page for the source code and to include the source directly onto this page. For example, one could use
This will include a page headed "Visual Studio T4 Template" under the "Related Pages" tab of the documentation, which can be referenced with the tag
src_code
(i.e. use\ref src_code
to link to that page/source code).As a final aside, if you are including C/C++ code you could enclose the
\include
with the\code
and\endcode
commands to syntax highlight the code.