1

My doxygen documentation shows the source-code of each class member function. My source code sometimes contains multiple blank lines between functions.

How can I get doxygen to compact or strip these multiple blank lines? (instead of showing them in the preview)

ANSWER (from below)

The answer below pointed me in the right direction: INPUT_FILTER (doxygen documentation)

The INPUT_FILTER tag can be used to specify a program that doxygen should invoke to filter for each input file. Doxygen will invoke the filter program by executing (via popen()) the command:

<filter> <input-file>

where is the value of the INPUT_FILTER tag, and is the name of an input file. Doxygen will then use the output that the filter program writes to standard output.

I quickly wrote a python script (I'm on Win7) that does the 'compacting':

import re
import sys

if len(sys.argv) != 2:
  exit()

with open(sys.argv[1]) as f:
  original = f.read()
  compact = re.sub('\n\n\n+', '\n\n', original)
  print(compact)

Then I added it to the filter:

INPUT_FILTER = "python ../DoxyCompact.py"

This also opens up A LOT of possibilities to modify the source before doxygen reads it!

albert
  • 8,285
  • 3
  • 19
  • 32
HWende
  • 1,705
  • 4
  • 18
  • 30
  • 1
    Is there a specific reason you don't want to use [Sphinx](http://sphinx.pocoo.org/)? – mensi Apr 13 '12 at 09:26
  • I use a Win7 64bit machine and I **really** tried hard to set it up. Finally I used doxygen and it works really well... – HWende Apr 13 '12 at 09:55

1 Answers1

1

The only way I can think of doing this is to define some preprocessor to strip the multiple blank lines before doxygen uses the source code in the documentation. To define an action (or filter) to perform on the source files use the INPUT_FILTER configuration file option.

Warning: The following has not been tested.

From the question How can I replace multiple empty lines with a single empty line in bash? it seems that one can use

sed /^$/d

to strip multiple blank lines, so in your configuration file, set

INPUT_FILTER = sed /^$/d
albert
  • 8,285
  • 3
  • 19
  • 32
Chris
  • 44,602
  • 16
  • 137
  • 156