1

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:

Community
  • 1
  • 1
Andrew Chang
  • 1,289
  • 1
  • 18
  • 38
  • May be this link will help you :) [1]: http://stackoverflow.com/questions/10530695/show-method-definition-description-in-xcode-4 – Mahesh Apr 25 '13 at 06:37
  • 1
    Sorry for the long delay but I just saw your edit now, I don't get any message unless you post a comment ... Are you sure you made the script executable (step 6)? – HAS Apr 27 '13 at 20:04
  • 1
    If you did so try repairing permissions in `Disk Utility` – HAS Apr 27 '13 at 20:22
  • 1
    Oh, I solve that. Thaaaaaaaaank you veeeeeeeeery much !!!!!! Now everything goes smoothly. I updated that in my post. – Andrew Chang Apr 28 '13 at 01:40
  • :) That's nice! :) Thanks for the method description! :) I like that :) – HAS Apr 28 '13 at 09:15

1 Answers1

1

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

Info with code completion

If you alt-click the method you get all the information:

Method documentation by alt-clicking

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!

HAS
  • 19,140
  • 6
  • 31
  • 53
  • Oh, seems my question duplicate a little bit. Thanks! I think I may try appledoc. Also thank to Mahesh!! – Andrew Chang Apr 25 '13 at 07:57
  • 1
    I am just editing this question to make it a little tutorial ;) If you encounter any problems let me know! Could take a little while to finish it because I am having lecture right now but I'll do my best to make the edit asap! – HAS Apr 25 '13 at 08:01
  • 1
    I have read the introduction briefly and understandood that it may take a while, too. Actually, as it seemes not to be an easy job enough, I will do that later. But still, thank you very much! – Andrew Chang Apr 25 '13 at 08:34
  • 1
    @AndrewChang I've edited my post, if you have any question let me know! :) – HAS Apr 25 '13 at 11:09
  • 1
    Wow!!! So detailed!!! Thanks a looooooooooot!! You make me want to try appledoc right NOW!!! I will try that now! – Andrew Chang Apr 25 '13 at 11:44
  • 1
    Yeah, I hope it's detailed enough. When I installed and configured it I spent hours with it. So I hope that it helps saving someone (at least you) some time ;) – HAS Apr 25 '13 at 11:52
  • Step 11: "Enter a name and shortcut". I entered a behavior and named it "appledoc", also choose the .command file. But what "shortcut" is? – Andrew Chang Apr 27 '13 at 02:40
  • 1
    "docsURL" is used for the download feed, you actually don't really need that. You can choose whatever shortcut you want. In Xcode when you add the behavior click on the right of that `TableViewCell`. I added a picture to step 11 ;) – HAS Apr 27 '13 at 03:45
  • 1
    There is also an `@author` parameter that can be used to attribute the code. – siannopollo Dec 15 '13 at 02:18
  • @siannopollo Thank you! I didn't know that! I knew that such a keyword exists but I tested all those with Xcode 5 Beta a long time ago and they we're not working, but now they are! This is great! Thanks so much again! – HAS Dec 15 '13 at 10:24
  • Take a look at [this answer](http://stackoverflow.com/a/19169271/1489885). This sums up all available keywords. – HAS Dec 15 '13 at 11:13