Take the 2-minute tour ×

I would like to use doxygen to generate code documentation (of functions) in .c or .cc files with Emacs. I found doxymacs, but it seems not to be maintained anymore (latest version 2007) and I also did not find a way to update the documentation of a function if I change the name of one of the parameters of the function ("unfortunately", I'm used to the great Roxygen for .R scripts which can do all nice things, even inserting a documentation right before a function when the point is somewhere in the function).

I found this, but it seems not very useful. However, there is an example here how to use yasnippets. Has anyone written a yasnippet for doxygen headers? Still, it would not update the parameters if the function name changes. Is there any "better" way to work with doxygen in Emacs? I would assume there are quite a lot of C/C++ programmers that work with Emacs and I would guess that there should be a good tool/approach for code documentation.


I also found this. It's purely based on yasnippet (haven't tried it yet, though).

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

I use the following:

# -*- mode: snippet -*-
# name: cc-doxygen
# key: dox
# type: command
# contributor: Jonathan Kotta <jpkotta@gmail.com>
# --
(let* ((next-func-alist (doxymacs-find-next-func))
       (func-name (cdr (assoc 'func next-func-alist)))
       (params-list (cdr (assoc 'args next-func-alist)))
       (return-name (cdr (assoc 'return next-func-alist)))
       (snippet-text "")
       (idx 1))
  (setq snippet-text (format "/**\n * ${1:%s}\n * \n" func-name))
  (setq idx 2)
  (dolist (param params-list)
    (unless (string= param "this")
      (setq snippet-text (concat snippet-text
                                 (format " * \\param %s ${%d:}\n" param idx)))
      (setq idx (+ 1 idx))))
  (when (and return-name (not (string= return-name "void")))
    (setq snippet-text (concat snippet-text
                               (format " * \\return ${%d:%s}\n" idx return-name))))
  (setq snippet-text (concat snippet-text " */"))
  (yas/expand-snippet snippet-text))
share|improve this answer
Dear Jonathan, thanks for helping. That looks good. At the top of permalink.gmane.org/gmane.emacs.yasnippet.devel/555 there is a version which does not require doxymacs. Haven't tried it, though. –  Marius Hofert Jul 4 '12 at 22:52
add comment

1. Generate doxygen from Emacs

Which kind of tool are you using for compiling? CMake? Autotools? Scons?

Once I worked with CMake and we created a target to generate documentation with doxygen.

Something like this.

Then you will have to compile like this:

make doc

But this only covers the first part of your question, the documentation before each function it will be made manually. I will try to integrate this solution with yasnippet.

share|improve this answer
Thanks for helping. I don't compile the files myself. I use them within R and R compiles the files for me. –  Marius Hofert Jul 4 '12 at 22:44
add comment

Your Answer


