如何生成rdoc样式的可折叠代码段? [英] How to generate rdoc-style collapsable code sections?
问题描述
我正在使用Doxygen为C ++项目创建内部文档.我让Doxygen包含了方法等的来源,但这使页面难以扫描.我希望它的行为像rdoc一样,并将源隐藏在默认情况下折叠的块中.
I am creating internal documentation for a C++ project using Doxygen. I am having Doxygen include the source for methods, etc., but this makes the page kind of hard to scan. I'd like it to behave like rdoc and hide the source in a block that is collapsed by default.
我以为HTML_DYNAMIC_SECTIONS
可能会让我这样做,但是可惜,变更日志说该选项只影响图表.
I thought that HTML_DYNAMIC_SECTIONS
might let me do this, but alas, the changelog says that option only affects diagrams and graphs.
也许我可以通过编辑LAYOUT_FILE
来做到这一点?
Maybe I could do it by editing the LAYOUT_FILE
?
无论如何,聪明的人,我如何强迫Doxygen生成可折叠的代码段?
Anyhow, smart people, how can I coerce Doxygen to generate collapsable code sections?
推荐答案
如果包含方法等的源代码,则[...]使得该页面难以扫描,为什么不直接链接到它( SOURCE_BROWSER = YES
)而不是包括( INLINE_SOURCES = YES
)?这将使页面更易于扫描并且加载速度更快,并且仍然可以访问源(以增加源页面的加载为代价).我想这取决于您实际上需要多久访问一次源.
if includ[ing] the source for methods, etc, [...] makes the page kind of hard to scan, why don't you just link to it (SOURCE_BROWSER = YES
) instead of including it (INLINE_SOURCES = YES
)? this would make the pages easier to scan and faster to load, and the source would still be accessible (at the expense of one more source page load). depends on how often you actually need to access the source, i guess.
话虽这么说, 是一种生成可折叠代码段的方法(不过,您将不得不修改源代码并重新编译Doxygen):
that being said, there is a way to generate collapsible code sections (you will have to modify the source and recompile Doxygen, though):
- collapsible sections in Doxygen's HTML output are marked with two nested
<div>
s like so:
<div class="dynheader"><div class="dynsection">
[collapsible section]
</div></div>
- 包含的代码段的标记如下:
<div class="fragment"><pre class="fragment">...</pre></div>
-
因此,要使包含的代码段可折叠,您必须要么
- included code sections are marked like so:
<div class="fragment"><pre class="fragment">...</pre></div>
thus, to make the included code sections collapsible, you have to either
- 修改生成
<div class="fragment"><pre class="fragment">...</pre></div>
生成<div class="dynheader"><div class="dynsection">...</div></div>
(可能会调整某些css)的代码,或者 - 更改 javascript
initDynSections()
函数,该函数扫描并折叠可折叠部分以将<div class="fragment"><pre class="fragment">
识别为其中之一.
- modify the code that generates the
<div class="fragment"><pre class="fragment">...</pre></div>
to generate<div class="dynheader"><div class="dynsection">...</div></div>
(and probably adjust some css), or - change the javascript
initDynSections()
function that scans and collapses the collapsible sections to recognize<div class="fragment"><pre class="fragment">
as one of them.
实现(或走
SOURCE_BROWSER
路线:)作为练习留给读者.祝你好运!the implementation (or going the
SOURCE_BROWSER
route :)) is left as an exercise for the reader. good luck!哦,如果您应该成功获得补丁,那么您可以将其提交给dimitri,以便他可以将其包括在以后的版本中.谢谢!
oh, and if you should succeed with a patch, it would be great if you could submit it to dimitri so that he can include it in a future version. thanks!
这篇关于如何生成rdoc样式的可折叠代码段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 修改生成
- included code sections are marked like so: