[英]How do you document a description for a custom class in Objective-C/Swift?
我知道您可以使用///(三斜杠)來注釋變量,甚至可以使用/**
來對函數等進行doxygen樣式的注釋,但是有沒有辦法記錄自定義類本身? 因此,如果有人選擇在Xcode中單擊它,將會有描述嗎?
我遇到了同樣的問題,找到了解決方案。
要使用Doxygen對自定義類進行注釋時,可以使用@file標記(或\\ file標記)。 (這是Doxygen文檔站點中的推薦方法,但通常被忽略。)
用標簽寫評論
而已。
例如 :
/*!
@file CustomViewController.h
*/
#import <UIKit/UIKit.h>
/*!
@brief The CustomViewController Header file
@discussion CustomVC
@superclass SuperClass: UIViewController
@classdesign No special design is applied here.
@coclass AppDelegate
@helps It helps no other classes.
@helper No helper exists for this class.
@author dakeshi
@version 1.0
*/
@interface CustomViewController : UIViewController
**我使用Xcode 6.2測試了此代碼
您可以識別@file標記是分開的。 如果在第二個注釋塊中移動了@file標記,Doxygen將無法生成所需的文檔。 它只能正常工作@file標簽是單獨描述的。(我找不到原因。)
您可以在第二個注釋塊中使用@ class,@ protocol標記,但需要非常小心地使用它。 有些標簽必須與換行符一起使用(例如@ discussion,@ class),因為Apple保留了與某些標簽同名的關鍵字。 如果在上面的示例中使用@class標記而不使用換行符,則只能看到有關UIViewController的常規Apple文檔。
您可以使用不同的方式進行記錄,例如
/*!
* @discussion <#description#>
* @param <#param description#>
* @return <#return description#>
*/
在下面的鏈接中查看@discussion
關鍵字的詳細說明以及如何通過代碼片段快速使用這些注釋
http://www.raywenderlich.com/66395/documenting-in-xcode-with-headerdoc-tutorial
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.