If we type a method from Apple API, Xcode will display method functions below the auto-complete pop-up list. But typing a user-defined method, it shows nothing.
Is there a way to tell Xcode to display some descriptions that I defined by myself to show how to use the user-defined methods?
Thank you!!!
@HAS:
I follow your instruction till Step 12, and create a simple test class in .h file as:
#import <Foundation/Foundation.h>
@interface AMCAppleDocTest : NSObject
@property (nonatomic, retain) NSString *version;
+ (id) test;
/** @name Section title */
/** Method description */
- (void)doSomething;
@end
Then to Step 13, I run the script, but error occurred as picture below:
My .sh script:
#! /bin/sh
docsURL="http://www.AMC.com";
projectsPath="$2/../";
docsPath="/Users/AMC/Library/Developer/Documentations/$1";
# create AppleDocOutput folder if not exists
if [ ! -d $docsPath ];
then
mkdir "${docsPath}";
fi
/Users/AMC/Library/Developer/DocumentationStuff/appledoc \
--project-name "$1" \
--project-company "AMC" \
--company-id "com.AMC" \
--docset-atom-filename "$1.atom" \
--docset-feed-url "${docsURL}/%DOCSETATOMFILENAME" \
--output "/Users/AMC/Library/Developer/Documentations/$1" \
--docset-package-url "${docsURL}/%DOCSETPACKAGEFILENAME" \
--docset-fallback-url "${docsURL}/$1Doc/" \
--publish-docset \
--logformat xcode \
--keep-undocumented-objects \
--keep-undocumented-members \
--keep-intermediate-files \
--no-repeat-first-par \
--no-warn-invalid-crossref \
--ignore "*.m" \
--ignore "LoadableCategory.h" \
--index-desc "$2/readme.markdown" \
"$2" > "${docsPath}/AppleDoc.log"
And the .command file:
#!/usr/bin/osascript
tell application "Xcode"
tell first project
-- variables to export
set projectName to (get name)
set projectDir to (get project directory)
set company to (get organization name)
-- invoke script passing extracted variables
do shell script ("sh /Users/AMC/Library/Developer/DocumentationStuff/appledoc.generate.sh " & projectName & " " & projectDir & " " & company)
end tell
end tell
And besides, my Xcode version is 4.5.1 and OS X 10.8.
Xcode is not installed into /Applications folder but simply put at desktop. Does it matter?
@ HAS, again
I found what went wrong: the script was in dos format. I solved that in VI using :set ff=unix. Now every things goes perfectlly:
In my old answer I suggested appledoc (which is fantastic btw) but for what you want it is much easier with Xcode 5 to use its built-in documentation feature (for the old answer take a look at the edit history).
Let's say you have a method like:
- (NSString *)fooBar:(NSNumber *)foo bar:(NSArray *)bar {
return @"FooBar!";
}
All you have to add is
/**
* This is a demo method
*
* @param foo An NSNumber.
* @param bar An NSArray.
*
* @return Returns the NSString "FooBar!"
*/
- (NSString *)fooBar:(NSNumber *)foo bar:(NSArray *)bar {
return @"FooBar!";
}
When typing the method you can see the info at the bottom of the popover
If you alt-click the method you get all the information:
If you are lazy (like me) take a look at the wonderful plugin called VVDocumenter. All you have to do using the plugin is typing ///
above a method and it automagically generates the documentation structure for you.
Just download, compile, copy and start documenting! Thanks to onevcat for providing such an awesome tool!