jnikula / hawkmoth

Hawkmoth - Sphinx Autodoc for C
https://jnikula.github.io/hawkmoth/
BSD 2-Clause "Simplified" License
74 stars 12 forks source link

Option to show macro's value #236

Open amykyta3 opened 6 months ago

amykyta3 commented 6 months ago

Thanks for the great plugin! Not sure if this is already supported or not, but it could be useful in some situations to also show the macro's value in the rendered documentation.

Something like:

.. c:automacro:: MY_MACRO
    :file: example.h
    :show_value: True

I'm in a situation where I need to document a cross-language API, and there are several constants defined in macros that would be useful to propagate to the docs. For now, I'm working around by duplicating the macro value in the docstring comment.

jnikula commented 6 months ago

Thanks for the feedback! I understand the use case, and I'll look into it, but there are a few downsides:

I'm not outright rejecting this, though, need to look into how it could be implemented. Using an enum might be a workaround in some cases.