3 ms·
One of the most transformative features we added to the D language was Ddoc, which is a documentation generator for functions. It has a modestly standard format
by WalterBright 5y ago
One of the most transformative features we added to the D language was Ddoc, which is a documentation generator for functions. It has a modestly standard format. The result is it applies significant pressure on the coder to add the Ddoc comments, and a routine change request review of a PR is "please add function ddoc comment".
Before Ddoc, the D standard library was inadequate, totally wrong, or missing entirely. After Ddoc, it became reasonable (though no documentation is perfect). Further improvements were an ability to actually run the example code in the Ddoc comment as a unit test.
The end result is the entire documentation of the D runtime library is generated by Ddoc from the source code.
- sokoloff 5y agoI decided to go looking for this to check it out. To save someone else that websearch: https://dlang.org/phobos/index.html https://dlang.org/phobos/index.html
- ameliaquining 5y agoDoesn't every language have a feature like this these days? If not an official standard, then a commonly used third-party tool. Though embedding unit tests in API documentation is less common; the only other languages I'm aware of that support it out of the box are Python and Rust. A Google search turns up some implementations for other languages, like C++ and Haskell, but I don't know how widely used they are. Regardless, I definitely agree that it's a very important and useful feature.
- WalterBright 5y agoDOxygen existed for D at the time we developed Ddoc, and some people used it, and so I was constantly asked "Why not just use DOxygen?" The problem with DOxygen was, it wasn't installed automatically! It was extra work to go get it and install it, so it never happened. What a builtin Ddoc does is: 1. It's always installed 2. It's always matched to the current compiler (one never has a mismatched set) 3. It is standardized (code using DocX is not mismatched with other code using DocY) 4. It can take advantage of the compiler's available semantic information 5. Don't have to beg documentation tool vendor to add features we need. For example, Markdown support was recently added. Didn't have to ask or beg. A Ddoc user simply added it These advantages are enormous and transformative. Minimizing friction matters a great deal. C and C++ do not have builtin documentation generators. I ask you, of professional C/C++ code you've seen, how many consistently and properly documented the function interfaces? In my experience, it's rare. It's much more common in D, and that's entirely due to Ddoc.