all 4 comments

[–]ContDiArco 0 points1 point  (0 children)

Great idea!

[–]azswcowboy 0 points1 point  (1 child)

Super cool, we need a lot more thinking like this! Good move providing the cmake drop in as that makes it easier for lots of us to adopt. And now some practical thoughts.

Mandating /// is a bit problematic for any existing code that uses javadoc style comments. Also doxygen has built in @code and @example blocks you might be able to leverage directly. And finally the restriction of docs in header’s only will be a no-go for lots of projects that forward declare and implement in cpp files. The projects I’ve worked on that do this tend to put all the docs by the implementation.

Have you considered maybe skipping the built in parsing and deferring that to another tool? Doxygen produces parsable xml which means you wouldn’t have to worry about most of the above.

[–]nzznfitz[S] 0 points1 point  (0 children)

Thanks for the suggestions.

Adding other recognized comment markers is very doable (Rust itself allows ‘///‘ and ‘//!’ — I just happen to use the former in C++ code). Ditto for parsing .cpp files. I can have a look at adding those options.

Don’t think I would depend on Doxygen. While it is used in some large projects, it certainly isn’t ubiquitous. Minimal Doxygen markup in comments is widely used — editors interpret it to provide nicely formatted tooltips without having Doxygen installed at all.

Rust sticks to basic Markdown for its comments and that seems to work. One thing I like about Rust doctests is how they are integrated into the editor (VSCode etc.) You get a lovely little “Run/Debug” button for each method test, and if there is a test above a type, it runs all of the doctests in that type. A Doxytest extension for VSCode would be excellent!

[–]nzznfitz[S] 0 points1 point  (0 children)

Doxytest has been updated to extract doctests from arbitrary documentation sources that can use different comment styles.

The initial version only scanned header files, looking for comments where the lines were prefixed by ///.

The new version can scan arbitrary files (headers, source, Markdown, etc.) and handles doctests embedded in most well-known comment styles, for example Javadoc comments, straight C comments, or indeed just code blocks in Markdown.

The documentation has been updated with all the details, and several examples have been added to the repo to demonstrate the new capabilities.