r/cpp • u/Abbix57 • Mar 15 '26
C/++ documentation generator - feedback wanted
Hi r/cpp, I'm building duck, a modern documentation generator for C and C++, inspired by Rust's rustdoc tool. I think it has finally reached a point where it is usable enough to be tested on real projects. See it used on a large C project here.
I’d love for anyone who’s interested to try it out on their codebase and report any bugs, edge cases, or feedback you encounter (as far as I'm aware, this mostly happens in name resolution edge cases). Your input will be very valuable and I will be happy to fix any bug you might encounter :)
Few notes:
- Doxygen comments are not supported, do not expect them to render properly! Comments are written in Markdown
- Concepts and modules are not supported, because libclang does not yet expose them.
- If you're seeing your type aliases be set to int, this is libclang's way of telling you that it couldn't resolve the type. This can typically be fixed by adding -I<your include directory> in your compiler flags in the duck.toml config file
Thank you!
15
u/Kronikarz Mar 15 '26
You write that "duck goes further", but your repo does not include any examples of how it does that. Except documentation tests, is there anything your generator does that Doxygen does not, or does it better?
4
u/gosh Mar 15 '26
What I think is a wanted feature is to generate documentation on the "fly", not this full documentation. Because that is almost never read if you do not have an extremely popular library.
So lets say that I have downloaded some repo and want to parse out documentation for a file or class or a couple of files to get feedback on how to use it. That would be a very good feature.
4
u/holyblackcat Mar 16 '26
Are rust bindings for libclang based on the C bindings? I learned the hard way that those are lacking features, I had to migrate to the C++ API (which exposes everything).
Ah, this makes ot a hard sell.
10
u/Agron7000 Mar 16 '26
Why?
I just did search doxygen vs rustdoc, and it seemed like rustdoc was a downgrade to doxygen.
With rustdoc I am loosing
You should have been inspired by Doxygen.
2
u/fluorihammastahna Mar 16 '26
Oh, exciting! This is an important part of development, and keeping docs in sync with source is a very desirable thing to have.
I am not sure if I get the difference. It is possible to write full documentation manuals with doxygen.
From the examples, it is not immediately obvious to me what is the advantage of duck. Using the same sample code, may I suggest two minimal examples: one that shows how duck syntax is nicer than doxygen, and one that shows something cool that can be achieved with duck and not with doxygen.
I understand supporting doxygen syntax was not viable, but porting a large-ish code base will never happen. I would even be weary to test it for any serious project, because I have no guarantees it is mature enough, and I will be forced to rewrite the whole documentation.
The main challenge with this project is not technical, but human: convincing people to use. Off the top of my hat, I would create a killer sample project (or port an existing project from doxygen to duck) and let the user base grow slowly.
What I would really need to create docs integrating the API would be full customization: being able to write a document and decide what goes where. For example, a page documenting a module and dropping the generated documentation for a class with a selected part of its properties. "This module does blah blah and it includes this class and here's are its main methods without boring constructors etc". The full documentation can go into a reference page. Does that make sense?
1
u/MH_Draen Mar 17 '26
This looks interesting! I haven’t looked at the repo in detail yet, but the question that comes to mind is: how easy it is to package the doc pages generated by duck in a Sphinx? In some projects I work on, we specifically don’t work with Doxygen because it’s too cumbersome to do cleanly, and we end up doing everything in Sphinx. This causes issues with syncing source code docs (for LSP) and the Sphinx web-published docs (for users). If duck could be easily integrated into a Sphinx generated static website, I’d be happy to try it in some of our projects :)
1
u/wiedereiner Mar 19 '26
It seems, that it does not support syntactically linking the parameters and return types to transport additional semantic information. Will you add support for that? Would be a highly valuable feature!