使用Appledocs生成文档

时间:2013-03-04 16:01:25

标签: ios objective-c xcode documentation-generation code-documentation

我为我的问题的简单性道歉,但我试图使用Appledocs(https://github.com/tomaz/appledoc#quick-install)生成文档

我不确定如何设置它。我这样做的方式是:

  • 我克隆了github repo,然后使用安装脚本(我在appledocs --help中确认了这个)在终端中安装了appledocs。

但是,现在我如何在xcode中使用我的项目实际使用它:

  • 如何生成文档文件
  • 它在哪里生成?

3 个答案:

答案 0 :(得分:15)

我一直在做的是为我的项目添加一个可以生成文档的新目标。您可以转到项目构建阶段并单击“添加目标”。在Other下选择Aggregate并为其命名(例如ProjectDocumentation)。

仍然在构建阶段选项卡上转到“添加构建阶段”并单击“添加运行脚本”。您现在可以粘贴以下内容并将其调整为您自己的设置:

/usr/local/bin/appledoc \
--project-name HereProjectName \
--project-company "HereProjectCompany" \
--company-id com.companyName \
--keep-undocumented-objects \
--keep-undocumented-members \
--search-undocumented-doc \
--exit-threshold 2 \
--ignore .m \
--output "AppleDoc" .

我使用ignore * .m因为我只在头文件中编写文档。我的* .m文件中的文档仅供我自己使用(因此也是私有的)。 构建此目标时,文档将作为XCode docset生成。可以通过alt-单击类名来访问它。查看AppleDoc website的评论语法。

有关命令行选项的说明,请检查appledoc --help命令。

答案 1 :(得分:3)

例如,像这样,它是一个有效的标题,包含最新的Appledoc的源代码文档。

//
//  GSUserDefaults.h
//
//  Created by Gabor Szabo on 30/01/2013.
//
//

#import <Foundation/Foundation.h>


/*!
 @discussion This class manages the user defaults on the device with some extra convenient methods.

 ## Version information

 __Version__: 1.0

 __Found__: 2013-01-30

 __Last update__: 2013-01-30

 __Developer__: Gabor Szabo, TMTI Ltd.

 */

#pragma mark - Interface

@interface GSUserDefaults : NSObject {

}

#pragma mark - Class Methods

#pragma mark - Getters

/// @name Getter methods

/*!
 @abstract Returns the value for the key.
 @discussion It reads the values from the `NSUserDefaults`.
 @param key The key, it must be not `nil`.
 @return The value object for the key.
 @exception NSException Thrown when the key is `nil`.
 @since 1.0+
 */
+ (id)valueForKey:(NSString *)key;

/*!
 @abstract Returns a value collection for the keys.
 @discussion It reads the values from the `NSUserDefaults`.
 @param keys The set of keys, which are affected.
 @return The value collection for the desired keys.
 @exception NSException Thrown when the key is `nil`.
 @since 1.0+
 */
+ (NSDictionary *)valuesForKeys:(NSSet *)keys;

#pragma mark - Setters

/// @name Setter methods

/*!
 @abstract Sets a value for the selected key.
 @discussion The value always will be overridden. It sets the value to the `NSUserDefaults`.
 @param value The value object, it can be `nil`, in case of `nil` the key will be removed from the `NSUserDefaults`.
 @param key The key for the value, it cannot be `nil`.
 @exception NSException Thrown when the key is `nil`.
 @since 1.0+
 */
+ (void)setValue:(id)value forKey:(NSString *)key;

/*!
 @abstract Sets `nil` values for the selected keys.
 @discussion The value always will be overridden. It removs the from the `NSUserDefaults`.
 @param keys The set of keys, which are affected.
 @since 1.0+
 */
+ (void)setNilValueForKeys:(NSSet *)keys;

/*!
 @abstract Sets a default value for the selected keys.
 @discussion It the key already exists, it won't be overridden, if the value was `nil` for the key, the key gets the value. It sets the values to the `NSUserDefaults`.
 @param defaultValue The value object, it could be `nil`, in case of the `nil` just nothing will happen, the keys won't be removed.
 @param keys The set of keys, which are affected.
 @since 1.0+
 */
+ (void)setDefaultValue:(id)defaultValue forKeys:(NSSet *)keys;

/*!
 @abstract Sets the value for the selected keys.
 @discussion The values always will be overridden, if the value was `nil` for the key, the key gets the value. It sets the values to the `NSUserDefaults`.
 @param value The value object, it can be `nil`, in case of `nil` the key will be removed from the `NSUserDefaults`.
 @param keys The set of keys, which are affected.
 @since 1.0+
 */
+ (void)setValue:(id)value forKeys:(NSSet *)keys;

@end

答案 2 :(得分:-1)

推荐的方法是clone GitHub project and compile the tool from Xcod e。克隆GitHub项目将创建到主存储库的链接,它也大大简化了将来的升级。要安装,请在终端中键入以下内容:

git clone git://github.com/tomaz/appledoc.git

这会创建appledoc目录。你可以在其中找到appledoc.xcodeproj Xcode项目;打开它并编译appledoc目标 - 这应该是开箱即用的,但是你的系统必须满足最低系统要求,见下文。我建议您将生成的appledoc可执行文件从build目录复制到路径中的一个目录(echo $ PATH),以便于访问。

可选:Appledoc是自包含的,包含必要的模板文件。如果要将这些默认值从Templates子目录修改为其中一个预期位置:

~/Library/Application Support/appledoc
~/.appledoc

了解更多信息visit