40

Well I am creating a script to automatically generate documentation for my projects with Doxygen, which seems like an awesome tool.
What is not clear to me, is if the user can use specify directly parameters, such as project name, project description etc., by setting them besides command:

doxygen -g "parameter modification here"
doxygen Doxyfile

Any tips appreciated!

bluish
  • 26,356
  • 27
  • 122
  • 180
Potney Switters
  • 2,902
  • 4
  • 33
  • 51

3 Answers3

63

Look at the answer for question 17 in the FAQ: http://www.doxygen.nl/manual/faq.html#faq_cmdline, repeated below for convenience:

Can I configure doxygen from the command line?

Not via command line options, but doxygen can read from stdin, so you can pipe things through it. Here's an example how to override an option in a configuration file from the command line (assuming a UNIX environment):

( cat Doxyfile ; echo "PROJECT_NUMBER=1.0" ) | doxygen -

For Windows the following would do the same:

( type Doxyfile & echo PROJECT_NUMBER=1.0 ) | doxygen.exe -

If multiple options with the same name are specified then doxygen will use the last one. To append to an existing option you can use the += operator.

Karsten Koop
  • 2,475
  • 1
  • 18
  • 23
doxygen
  • 14,341
  • 2
  • 43
  • 37
  • 4
    It comes down to rtfm then :-) It's kind of weird that you cannot directly pass options to the script. I'll consider this as answer since it has a slightly more thorough example. – Potney Switters Jun 15 '12 at 09:30
  • @doxygen: thanks. Still, kind of a questionable design, since it requires one to go through hoops to make it work across different systems (as is proven quite nicely by the above example). Say in a make file that should work on Windows *and* Linux ... – 0xC0000022L Mar 30 '15 at 15:57
  • That's a nice solution to a missing feature. Unfortunately, it appears `doxygen` "forgets" other settings in the configuration file. For example, *`PROJECT_NAME`* was not used ("My Project" was used instead); *`PROJECT_NUMBER`* was not used (it was blank); and the setting I was trying to change (*`OUTPUT_DIRECTORY`*) has other paths appended to it... Why not just allow us to specify it on the command line? – jww Nov 06 '15 at 05:44
  • @jww For Unix: `( cat Doxyfile ; echo "PROJECT_NUMBER=1.0" ; echo "PROJECT_NAME="MyProjectName") | doxygen -` . Is this what you wanted? Works perfectly for me. – PiJ Mar 07 '17 at 12:37
20

(This is an alternative to the accepted answer - most likely above.)

My preferred solution is to use environmental variables in the config file. Let's take "QUIET" as an example: In the config file I replace

QUIET                  = NO

with

QUIET                  = $(DOXYGEN_QUIET)

I then call Doxygen as follows

DOXYGEN_QUIET=YES doxygen configfile

or

env DOXYGEN_QUIET=YES doxygen configfile

if used inside a (Bash) script. You could of course also export the variable DOXYGEN_QUIET so you don't have to type it for each run.

PS! I have a Bash script that run several Doxygen jobs, and it uses the standard -q option to run the jobs quietly by setting DOXYGEN_QUIET. I also set PROJECT_NAME using the same trick with an environmental variable.

hansfn
  • 530
  • 4
  • 18
  • See also the documentation paragraph "Can I configure doxygen from the command line?" – albert Mar 07 '18 at 10:32
  • Hm, I'm not sure what you are trying to say. The documentation paragraph you are pointing to is the accepted answer - with the exact paragraph repeated. I posted my answer, because I prefer it and though it might be useful for other people. – hansfn Mar 07 '18 at 11:44
  • Overlook the accepted answer, a reference from you to this accepted answer as an alternative solution might have been better. – albert Mar 07 '18 at 12:53
  • Note if an environment variable is not set or is empty, the setting will get its default value. GENERATE_HTML = $(GENERATE_HTML) defaults to YES, so running `GENERATE_MAN=YES doxygen configfile` will generate both html and man. – Mark Gates Jul 02 '23 at 14:59
7

As far as I know this is not possible: a doxygen build is configured through the configuration file or with the GUI (which is much easier than trying to remember command line option names). Typing doxygen --help at the command line and the documentation for the doxygen usage suggest that all the command line options do is set which configuration file to read (and allow the user to get layout files and the like).

One way to modify configuration options from the command line would be to append options to the configuration file using something like (untested):

echo "INPUT = some file" >> Doxyfile

This will append INPUT = some file to your Doxyfile and any earlier values of INPUT are ignored. If you want to append an item to INPUT you could use

echo "INPUT += some file" >> Doxyfile

Notice the +=. This respects INPUT values set earlier in the file.

Rather than appending to the configuration file you could always use sed to find and replace options.

albert
  • 8,285
  • 3
  • 19
  • 32
Chris
  • 44,602
  • 16
  • 137
  • 156
  • 1
    This what I ended up doing with sed. Doing text replacement e.g. sed -i 's/OPTIMIZE_OUTPUT_FOR_C = NO/OPTIMIZE_OUTPUT_FOR_C = YES/g' Doxyfile – Potney Switters Jun 14 '12 at 13:13