【问题标题】:Using Appledocs to generate documentation使用 Appledocs 生成文档
【发布时间】:2013-02-18 18:51:38
【问题描述】:

对于我的问题的简单性,我深表歉意,但我正在尝试使用 Appledocs (https://github.com/tomaz/appledoc#quick-install) 生成文档

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

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

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

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

【问题讨论】:

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


    【解决方案1】:

    我总是在我的项目中添加一个可以生成文档的新目标。您可以转到您的项目构建阶段并单击“添加目标”。在 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" .
    

    我使用忽略 *.m 因为我只在我的头文件中编写文档。我的 *.m 文件中的文档仅供我自己使用(因此是私人的)。 当您构建此目标时,文档将生成为 XCode 文档集。这可以通过 alt 键单击类名来访问。查看AppleDoc website 以获取注释语法。

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

    【讨论】:

    • 我将 --project-name 设为动态,但我找不到其他 2 个字段的任何类似变量。帮助 D:
    【解决方案2】:

    例如,像这样,它是一个有效的标头,带有最新 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
    

    【讨论】:

    • 如何在标头 cmets 中记录 @property?
    • 这种方式与@interface 完全相同。
    【解决方案3】:

    推荐的方式是clone GitHub project and compile the tool from 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
    

    更多信息visit

    【讨论】:

    • 这个答案似乎不是很有用,提问者已经找到了快速安装指南,这似乎只是一个复制粘贴而已。
    猜你喜欢
    • 1970-01-01
    • 2014-05-01
    • 2011-06-22
    • 2011-11-11
    • 2016-05-11
    • 2011-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多