狮身人面像:记录枚举的正确方法?

Jus*_*Sid 9 c++ restructuredtext python-sphinx

通过浏览Sphinx 的C和C++域,它似乎没有原始支持来记录枚举(以及更少的匿名枚举).截至目前,我cpp:type::用于枚举类型,然后是所有可能值及其描述的列表,但这似乎不是处理它的理想方式,特别是因为它使得引用某些值很痛苦(或者我仅引用类型,或在值前添加额外的标记).

有一个更好的方法吗?我将如何处理匿名枚举?

Ale*_*eys 5

关于Github的项目,spdylay,似乎有一种方法.https://github.com/tatsuhiro-t/spdylay/blob/master/lib/includes/spdylay/spdylay.h中的一个头文件的 代码如下:

/**
 * @enum
 * Error codes used in the Spdylay library.
 */
typedef enum {
  /**
   * Invalid argument passed.
   */
  SPDYLAY_ERR_INVALID_ARGUMENT = -501,
  /**
   * Zlib error.
   */
  SPDYLAY_ERR_ZLIB = -502,
} spdylay_error;
Run Code Online (Sandbox Code Playgroud)

https://github.com/tatsuhiro-t/spdylay/tree/master/doc上有一些关于他们如何做的描述,其中包括使用一个名为https://github.com/tatsuhiro的API生成器mkapiref.py. -t/spdylay /斑点/主/ DOC/mkapiref.py

它为此示例生成的RST是

.. type:: spdylay_error

    Error codes used in the Spdylay library.

    .. macro:: SPDYLAY_ERR_INVALID_ARGUMENT

        (``-501``) 
        Invalid argument passed.
    .. macro:: SPDYLAY_ERR_ZLIB

        (``-502``) 
        Zlib error.
Run Code Online (Sandbox Code Playgroud)

你可以看看它是否对你有用.


rsc*_*hn2 1

Sphinx 现在支持枚举

这是一个带有枚举值的示例:

.. enum-class:: partition_affinity_domain

   .. enumerator:: \        
      not_applicable
      numa
      L4_cache
      L3_cache
      L2_cache
      L1_cache
      next_partitionab
Run Code Online (Sandbox Code Playgroud)