5

我正在使用 Doxygen 来记录用 Objective-C 编写的 API。
Doyxygen 无法理解 NS_ENUM typedef。

我找到了这个解决方案,但它对我不起作用。

ENABLE_PREPROCESSING   = YES 
MACRO_EXPANSION        = YES 
EXPAND_ONLY_PREDEF     = YES 
PREDEFINED             = NS_ENUM(x,y)=y 

Regards, 
  Dimitri 

这是我的输入文件:

/**
 *  Represent the possible states.
 */
typedef NS_ENUM(NSInteger, ABEnumType)
{
    /**
     *  State A.
     */
    StateA = 0,
    /**
     *  State B.
     */
    StateB
};

这是我得到的输出:

Preprocessing /src/ABEnumType.h...
error: /src/ABEnumType.h:17:17: error: C++ requires a type specifier for all declarations [clang]
error: /src/ABEnumType.h:17:28: error: unknown type name 'ABEnumType' [clang]
error: /src/ABEnumType.h:18:1: error: function definition is not allowed here [clang]
error: /src/ABEnumType.h:17:9: error: C++ requires a type specifier for all declarations [clang]
Parsing file /src/ABEnumType.h...
4

3 回答 3

5

以下设置对我们有用:

 ENABLE_PREPROCESSING   = YES 
 MACRO_EXPANSION        = YES 
 EXPAND_ONLY_PREDEF     = YES 
 PREDEFINED             = NS_ENUM(x,y)=enum y 

有了这个,我们看到所有 NS_ENUM 结构都出现在我们的 doxygen 生成的文档中

于 2014-08-26T07:35:34.377 回答
2

如果 Doxygen 失败,您可以随时尝试HeaderDocs

编辑:我尝试了带有测试类的 headerdocs,我认为它确实提供了对 NS_ENUM 的良好支持。

//
//  VLTTestClass.h
//  VPNLoginTest
//

#import <Foundation/Foundation.h>

/*!
 Test class type description.
 */
typedef NS_ENUM(NSInteger, VLTestClassType) {
    /*!
     Description for type 1.
     */
    VLTestClassType1,
    /*!
     Description for type 2.
     */
    VLTestClassType2
};

/*!
 Description for test class
 */
@interface VLTTestClass : NSObject

@end

这是 headerdoc2html:http ://pastebin.com/q6RsR0tU

于 2014-04-16T07:53:03.440 回答
2

gyurisc 的回答有所帮助,但我们还需要启用EXTRACT_ALL. 所以以下设置对我们有用:

 EXTRACT_ALL            = YES
 ENABLE_PREPROCESSING   = YES 
 MACRO_EXPANSION        = YES 
 EXPAND_ONLY_PREDEF     = YES 
 PREDEFINED             = NS_ENUM(x,y)=enum y
于 2015-08-10T11:31:19.040 回答