Arnt Gulbrandsen
Send me mailAbout meAbout this blog
2011-12-20

Comparing javadoc with qdoc and doxygen

Qdoc misses many features Javadoc has. This is intentional — well, mostly. Here's a braindump of the features I dropped or decided against adding.

@author is one thing Qt had, but I dropped it due to two problems. First, it misled users who used it to answer the question who should I ask about this problem?. The problem was typically about some recent change to the file, and the original author of the file was the wrong person to ask. Second, there was some reluctance within the team about editing someone else's code, which delayed bugfixes.

I didn't realize at the time, but we once had a real colour of the bikeshed discussion about who should be listed as author of some code. Other aspects of that code warranted lively discussion, but we actually talked about who should be considered its author.

Doxygen, since it started as a qdoc clone, is mostly identical with qdoc. It does support some javadoc misfeatures, but in every case you can do things the qdoc way.

Qt (qdoc) switched away from a @param-like strategy to an in-sentence tag when I observed that good function documentation doesn't explain parameters separately from the function.

Good function documentation talks about the function, and mentions all the parameters in doing so. Sometimes it also has separate paragraphs for one or more parameters, but it always mentions the parameters in the sentences that describe the function itself. Javadoc's own example talks about both name and url in the documentation for getImage(), and their @param blocks mostly repeat the earlier wording.

Javadoc's @param tag is designed for the sometimes case, whereas I changed qdoc to support the always case instead, and added a warning when you don't do what you always should. In javadoc such a warning would give too many false positives.

The same argument applies (mutatis mutandis) to @return as well. The same javadoc example applies here too.

Creation date (@since) is too simple. There is some value in knowing that a function/class was added in version x.y, but not much. Users who care have to test against the older version anyway, because quite often the function/class has been extended since @since.

Boilerplate like @since is easy to add but often not valuable enough to bother with. Well, unless you want to mask a lack of documentation with bulky boilerplate.

Javadoc's @see is called \sa in qdoc, or it was called \sa until I noticed that whenever I improved a documentation item to the point where I was happy about its quality, the \sa links became unnecessary. Qdoc added the same links on its own volition, based on the documentation text.

@deprecated has potential, but I never found a way to add such a tag that produces better results than just writing an explanation. In my opinion, the java way of doing it is more verbose than Qt's (which uses no syntax, just text), but Qt's resulting documentation is better.

@code is solved very different in qdoc: qdoc knows how to include explanatory code from real source files. Java's approach is susceptible to typoes, missing critical information and other problems like this ghastly example, while qdoc's has the virtues of always providing working, complete source code for all examples, and bidirectionally links each example to the classes and functions it uses.

@link exists in qdoc, and in udoc too, but it's hardly used. Qdoc adds sensible links automatically, so there's little point in typing manual links. The automatic links generally remain meaningful in print, too.

One final item: Included HTML. That's been added to qdoc since I left Trolltech. It can be used to get finegrained control over the HTML documentation, but IMO no documentation is so good that manual HTML work is worth doing. There's always something else that provides better results for the same amount of working time, and it complicates making good PDF files from the documentation.

Any differences not mentioned here may be unintentional, or I may have forgotten about them.

2010-07-13

Writing worthless documentation with zero effort

Those lucky enough to use Visual Studio need not work hard to document their code: Ghostdoc does it all automatically. No mental effort required. (more…)

2010-03-29

The inverted pyramid

The inverted pyramid is how journalists are taught to write typical news stories. It puts the most newsworthy information at the top, and then the remaining information follows in order of importance, with the least important at the bottom. (The quote is from Chip Scanlan.)

This is the right way to write most API documentation. (more…)

2010-03-26

Companion techniques

Another finding-my-thoughts posting. Documenting helps fix bugs early, but what are its companion techniques?

Polishing the code all the time. Make it look good. Beauty is truth, truth is beauty. (more…)

2010-03-24

Reading someone's documentation

Written with doxygen. It's funny to see how early qdoc syntax is still there. Features I added because they seemed to make sense, then discarded later, when I saw they didn't carry their load.

And there they are, still in use. Maybe funny isn't the right word.

2010-02-04

Udoc into clang

One of udoc's problems is that its error messages arrive towards the end of the build process. Often, when fifteen executables are being built, I wait for the interesting one to be finished and immediately switch to testing it. Later on udoc delivers some useful error messages, but I'm not looking any more. (more…)

2010-01-29

Javadoc

Javadoc is built in to Java, but I think they botched it. It's clear that they didn't care deeply: JLS3 grammar doesn't mention javadoc at all, and the JLS doesn't specify it, hardly even mentions it… the word stepchild sounds more appropriate than does builtin, in my oh-so-humble opinion.

There are many things I don't like about the result, and few things I do like.

There's too much typing for not enough benefit. (more…)

2009-11-24

Output formats for generated documentation

The four major output formats (long print, piecemeal print, ASCII on screen and hypertext) all have their fans, all have their uses, the ideal system would support all four, but it isn't possible to support all four really well.

Writing, designing or encoding for plain ASCII just isn't the same as writing for pages. One of the books I read ages ago had a very nice example, showing two pages of text vs. one screen of text. The pages allowed boxes that didn't intrude on reading the regular text, fine graphics, and easy overview of a lot of data. In all, around six times as much information in front of the reader's eyes. (more…)