使用Appledocs生成文档

8

非常抱歉我的问题很简单,但我正在尝试使用Appledocs(https://github.com/tomaz/appledoc#quick-install)生成文档。

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

  • 我克隆了GitHub存储库,然后使用终端中的安装脚本安装appledocs (我通过appledocs --help确认了这一点)

现在,我该如何实际使用它,以便将我的项目放在Xcode中:

  • 我该如何生成文档文件?
  • 它生成在哪里?
3个回答

15
我通常做的是向我的项目添加一个新目标,可以生成文档。您可以转到项目构建阶段,点击“添加目标”。在“其他”下选择“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" .

我使用忽略 *.m,因为我只在头文件中编写文档。*.m 文件中的文档仅供我个人使用(因此是私有的)。 当您构建此目标时,文档将生成为 XCode 文档集。可以通过 alt + 单击类名来访问它。请查看 AppleDoc 网站 以获取注释语法。 要了解命令行选项的说明,请查看 appledoc --help 命令。

我已经将 --project-name 设为动态的,但是我找不到其他两个字段的类似变量。求助 D: - Alexander

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

你如何在头文件注释中记录@property? - kervich
这种方式与 @interface 完全相同。 - holex

-1

推荐的方法是从GitHub克隆项目并从Xcode编译工具。由于克隆GitHub项目将创建到主存储库的链接,因此这大大简化了未来的升级。要安装,请在终端中键入以下内容:

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

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

可选:Appledoc是自包含的,并包含必要的模板文件。如果您想修改这些默认值,请将其从Templates子目录复制到预期位置之一:

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

欲了解更多信息请访问


这个答案似乎不是很有用,提问者已经找到了快速安装指南,而这似乎只是它的复制粘贴。 - Connor

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接