xcode 使用 Appledocs 生成文档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15205704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:54:05  来源:igfitidea点击:

Using Appledocs to generate documentation

iosobjective-cxcodedocumentation-generationcode-documentation

提问by David West

I apologize for the simplicity of my question, but I was trying to generate documentation using Appledocs (https://github.com/tomaz/appledoc#quick-install)

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

I'm not sure how exactly to get it setup. The way I do it is:

我不确定如何设置它。我的做法是:

  • I clone the github repo and then install appledocs using the install script (I confirm this using appledocs --help)in the terminal.
  • 我克隆了 github 存储库,然后在终端中使用安装脚本(我使用 appledocs --help 确认)安装了 appledocs 。

However, now how do I actually use this in the sense that I have my project in xcode:

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

  • how do I generate the documentation file
  • where is it generated?
  • 我如何生成文档文件
  • 它在哪里生成?

回答by Robin van Dijke

What I always do is add a new target to my project which can generate documentation. You can go to your project build phases and click on 'Add Target'. Choose Aggregate under Other and give it some name (e.g. ProjectDocumentation).

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

Still on the build phases tab go to 'Add build phase' and click 'Add run script'. You can now paste the following and adjust it to your own settings:

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

/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" .

I use the ignore *.m because I only only write documentation in my header files. Documentation in my *.m files is for myself only (and thus private). When you build this target, the documentation is generated as a XCode docset. This is accessible by alt-click on a class name. Check out the AppleDoc websitefor commenting syntax.

我使用 ignore *.m 是因为我只在头文件中编写文档。我的 *.m 文件中的文档仅供我自己使用(因此是私有的)。构建此目标时,文档将生成为 XCode 文档集。这可以通过在类名上单击 alt 来访问。查看AppleDoc 网站以了解注释语法。

For explanation of the command-line options checkout the appledoc --help command.

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

回答by holex

for instance, like this, it is a valid header with source code documentation for the latests Appledoc.

例如,像这样,它是带有最新 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

回答by Ravindra Bagale

The recommended way is to clone GitHub project and compile the tool from Xcode. As cloning GitHub project will create the link to the main repository, it greatly simplifies future upgrading too. To install, type the following in the Terminal:

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

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

This creates appledoc directory. Within you can find appledoc.xcodeproj Xcode project; open it and compile appledoc target - this should work out of the box, however your system must meet minimum system requirements, see below. I recommend you copy resulting appledoc executable from build directory to one of the directories in your path (echo $PATH) to make it easily accessible.

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

Optional: Appledoc is selfcontained and contains the necessary template files. IF you want to modify these default from Templates subdirectory to one of the expected locations:

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

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

for more information visit

了解更多信息,请访问