Search code examples
c++python-sphinxrestructuredtext

Sphinx: Correct way to document an enum?


Looking through the C and C++ domains of Sphinx, it doesn't appear to have native support for documenting enums (and much less anonymous enums). As of now, I use cpp:type:: for the enum type, and then a list of all possible values and their description, but that doesn't seem like an ideal way to deal with it, especially since it makes referencing certain values a pain (either I reference just the type, or add an extra marker in front of the value).

Is there a better way to do this? And how would I go about handling anonymous enums?


Solution

  • Sphinx now has support for enums

    Here is an example with enum values:

    .. enum-class:: partition_affinity_domain
    
       .. enumerator:: \        
          not_applicable
          numa
          L4_cache
          L3_cache
          L2_cache
          L1_cache
          next_partitionab