views:

221

answers:

1

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.

I thought that HTML_DYNAMIC_SECTIONS might let me do this, but alas, the changelog says that option only affects diagrams and graphs.

Maybe I could do it by editing the LAYOUT_FILE?

Anyhow, smart people, can Doxygen generate collapsable code sections? And if so, how's it done?

+1  A: 

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.

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>
    
  • 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

    • 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.

the implementation (or going the SOURCE_BROWSER route :)) is left as an exercise for the reader. good luck!

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!

ax
> why don't you just link to it (SOURCE_BROWSER = YES) instead of including it (INLINE_SOURCES = YES)?Because I like the way rdoc works, I guess. Partly I think that's because with INLINE_SOURCES you still have to scroll to the function definition.> you will have to modify the source and recompile Doxygen, thoughSo I suppose the answer is, "no, doxygen can't do that unless you write it in yourself." Good enough. And thanks for the really detailed instructions on *how* to add it myself ... if I do make that modification I'll be sure and submit it.
Matthew Lowe