What should be the target format of our documentation. Can we get away with comments in the file? Will it become a website with linked information? A PDF? Is a wiki page sufficient? Or are we writing a book?
For files where there's only one of, like configuration files, its tempting to add documentation using comments in the file itself
(like the eXist conf.xml
example above). However, I don't think that works very well. Files are edited, and with the editing,
sections, including the documenting comments, will disappear or get duplicated. Your nicely formatted file will soon become a mess.
Another reason for not using XML comments is that your layout options are limited. Maintenance of nicely indented and formatted lists or
tables in comments is hard to keep consistent…
When things are easy and extensive documentation is not really necessary (or there is no time), just use what's at hand. Write it in Word and output it as PDF or HTML, use HTML directly, a Markdown readme file, a wiki page, etc.
When things get a little complicated, more than just a day or so of work and non-trivial, invest in a tool-chain that generates the documentation for you out of some medium-neutral source format. DocBook and DITA are good candidates, especially since IDEs like oXygen have such a splendid support for them. And once you have a medium-neutral source, the final format does not matter much anymore.
In designing such a tool-chain, begin with the narrative! So start by being able to create "just" text (like a DocBook or DITA structure) and pull in generated diagrams, tables an the likes from there. Not the other way around.