一扣泊、安裝過程
- 第一步:下載安裝
git clone git://github.com/tomaz/appledoc.git
cd ./appledoc
sudo sh install-appledoc.sh
稍等一會浆洗,安裝OK催束。
- 第二步:安裝驗證:
appledoc --version
二、使用
- 第一步:進入代碼所在文件夾:(你忘了伏社?好吧我告訴你怎么進)泣崩,進入終端:
cd + “文件夾目錄”
- 第二步:
name:項目名稱
company:公司名稱
這倆個自己可以替換一下
appledoc --project-name MyProject --project-company ibireme ./
之后你會看到你的文件夾下會多出一個文件,稍后會說這個文件的作用:
如果想了解更多洛口,可以查看幫助:
appledoc --help
- 第三步:集成進我們自己的工程
-
1矫付、在你的工程中創(chuàng)建新的 Target,注意這里要選擇 Other 中的 Aggregate第焰,如圖
- 2买优、在我們新創(chuàng)建的 Target 中的 Buid Phases 中添加 Run Script,
- 3挺举、 打開Run Script杀赢,Shell 下面的文檔區(qū)域添加這樣的模板:
-
#appledoc Xcode script
# Start constants
company="ACME";
companyID="com.ACME";
companyURL="http://ACME.com";
target="iphoneos";
#target="macosx";
outputPath="~/help";
# End constants
/usr/local/bin/appledoc \
--project-name "${PROJECT_NAME}" \
--project-company "${company}" \
--company-id "${companyID}" \
--docset-atom-filename "${company}.atom" \
--docset-feed-url "${companyURL}/${company}/%DOCSETATOMFILENAME" \
--docset-package-url "${companyURL}/${company}/%DOCSETPACKAGEFILENAME" \
--docset-fallback-url "${companyURL}/${company}" \
--output "${outputPath}" \
--publish-docset \
--docset-platform-family "${target}" \
--logformat xcode \
--keep-intermediate-files \
--no-repeat-first-par \
--no-warn-invalid-crossref \
--exit-threshold 2 \
"${PROJECT_DIR}"
- 4、Xcode 左上方選擇這個 Target 湘纵,然后 Build 編譯脂崔。
- 5、文檔就會編譯好并且自動安裝進 Xcode 了(重啟Xcode生效)梧喷。
注意:這里我遇到了個稀里糊涂的坑砌左,就是第一次編譯的時候報錯了,說我的第二行代碼有了問題铺敌,之后我就將上述代碼中的第二行去掉了汇歹,然后編譯運行就 OK 了。之后寫文章的時候我想重現(xiàn)這個bug偿凭,又將這句話加了回去产弹,編譯發(fā)現(xiàn)通過了,如果大家遇到了弯囊,就像我一樣嘗試去改一下痰哨,應該就沒問題了胶果,當然一次性編譯通過最好。之后我重新拿一個項目試驗了一下斤斧,第一次編譯又報出了同樣的錯稽物,之后又編譯了一下就沒問題了≌矍罚坑贝或。
- 6、那么編譯之后我們就可以去查看它了锐秦,那么在哪里可以看到呢咪奖?這時我們就可以用之前生成的 docset-installed.txt文件啦,打開它:看到以一個 Path 了吧:直接復制酱床,然后在 Finder 中前往文件夾:
- 7羊赵、如果順利的話我們就會看到這里啦:這個就是你生成的包文件,右鍵 --> 顯示包內(nèi)容你就會看到你的注釋文件們啦扇谣,自己好好找嘍昧捷。
![Uploading 內(nèi)容_278572.png . . .]
三、關(guān)于 appledoc 的一些問題
- appledoc 支持的注釋類型
/// 這是單行注釋罐寨。
/** 這也是單行注釋 */
/*! 同樣是單行注釋 */
/** 這也是單行注釋靡挥,
* 第二行會接上第一行。
*/
- 用法示例
/** 第一行是類的簡介
在簡介的下面,就是類的詳細介紹了鸯绿。
沒有間隔換行會被消除跋破,就像Html那樣。
下面是常用的markdown語法
- - -
無序列表: (每行以 '*'瓶蝴、'-'毒返、'+' 開頭):
* this is the first line
* this is the second line
* this is the third line
有序列表: (每行以 1.2.3、a.b.c 開頭):
a. this is the first line
b. this is the secode line
多級列表:
* this is the first line
a. this is line a
b. this is line b
* this is the second line
1. this in line 1
2. this is line 2
標題:
# This is an H1
## This is an H2
### This is an H3
#### This is an h4
##### This is an h5
###### This is an H6
鏈接:
普通URL直接寫上舷手,appledoc會自動翻譯成鏈接: http://blog.ibireme.com
[這個](http://example.net/) 鏈接會隱藏實際URL.
表格:
| header1 | header2 | header3 |
|---------|:-------:|--------:|
| normal | center | right |
| cell | cell | cell |
引用:
這里會引用到方法 `someMethod:`拧簸,這里會引用到類 `YYColor`
這里會引用到一個代碼塊
void CMYK2RGB(float c, float m, float y, float k,
float *r, float *g, float *b) {
*r = (1 - c) * (1 - k);
*g = (1 - m) * (1 - k);
*b = (1 - y) * (1 - k);
}
@since iOS5.0
*/
@interface AppledocExample : NSObject
///這里是屬性的說明
@property (nonatomic, strong) NSString *name;
/**
@brief 這里是方法的簡介。該Tag不能放到類注釋里男窟。
@exception UIColorException 這里是方法拋出異常的說明
@see YYColor
@see someMethod:
@warning 這里是警告盆赤,會顯示成藍色的框框
@bug 這里是bug,會顯示成黃色的框框
@param red 這里是參數(shù)說明1
@param green 這里是參數(shù)說明2
@param blue 這里是參數(shù)說明3
@return 這里是返回值說明
*/
- (UIColor *)initWithRed:(int)red green:(int)green blue:(int)blue;
- (void)someMethod:(NSString *)str;
@end