Doxygen shortcuts in XCode4

Since I couldn’t find a good solution for creating a keyboard shortcut to create a doxygen snippet based on your selection in XCode4 I have to write a short and untypical technical blog post about how to get that.
We’re trying to document our code as good as possible. While well written code is self-explainatory, interfaces and functions in header files simply have to be documented correctly. To do so, we use Doxygen, here in the Broken Rules engine room. We’ve had a pretty good XCode integration for generating Doxygen snippets on the press of a button but XCode4 broke the scripting support. In order to get our comfortable scripts back I had to look at a nearly forgotten part of the OSX operating system: Services.

You need the following two things in order to install the Ruby-based doxygen generator script that I’m using:

  • Waffle Software’s ThisServices, a tool to quickly hook up your own scripted services in OSX’s “Services” menu.
  • Doxygen.rb based on Fred McCann’s doxygen script.

Then simply execute the following two steps in order to install the script and make it start on the press of a key.

First, start ThisService and create a new “Filter”-type service based on the above Ruby script. Simply select Ruby file and give it a name. Then select “Filter” as the type of service and leave the rest of the controls untouched. Your settings should look like this:

Press “Create Service” to create the service. Once that is done you can proceed to step two.

Next, open “System Preferences” and go to “Keyboard” > “Keyboard Shortcuts”. Select “Services” in the left pane. Browse for the name you gave your new service. It’s hidden somewhere in the huge list of services. Once you’ve found it you have to assign a keyboard shortcut and tick its checkbox, otherwise it will not show up in your “Services” menu:

Once you’ve set the shortcut, you’re done. Simply select any text in XCode and press your keyboard shortcut. The script will try its best at understanding your code but you might have to extend it in order to suite your coding habits. Have fun!

Posted on March 29, 2011
Filed under development, tech, Uncategorized
Tags , , ,
  • Tuan Nguyen Hoang

    Hi !

    Use this tool very good on Xcode 4.

    But in Xcode 5 it not good as below : can you update, thanks


    [""] * @brief

    [""] *

    [""] * @param _storeID

    [""] *

    [""] * @return

    [""] */

  • Tuan Nguyen Hoang

    Ah, I did it, remove @indent in the ruby file, thanks !