Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift documentation comment @code equivalent.

I am aware about Swift documentation comment and many of its tags that are used to document code like :param:, :return: etc.

But I am not able to find or figure out @code Objective-C documentation comment equivalent for Swift. I want to include some code example in the description of some class in my open source project but I am not sure how to do that.

Could anyone please shed some light on how to do that or that is even possible at this stage?

like image 371
Abdullah Avatar asked Feb 01 '26 23:02

Abdullah


1 Answers

Using appledoc, you just need to indent your code 4 spaces

/*!
Documentation for the class.

Here is a code sample

    func code()
    {
        //code
    }
*/

You'll notice that a lot of the formatting options are similar to Stack Overflow! They both use Markdown for formatting.

I just happen to have documented a project using appledoc for the first time so I have a few of the pages in recent history. The code feature is documented here


Regarding your question about :code: @code syntax options. Appledoc directives accept any non-whitespace-character followed by a keyword. To Xcode, documenation is just a comment.

Directives prefix: Although all directives in examples above use "@" sign as a prefix, you can actually use any non-whitespace char instead, for example \param, $param, %param and so on...

[Source]

It does seem however, that the common @code isn't supported by appledoc the way it is by other documentation tools like doxygen.

like image 179
James Webster Avatar answered Feb 03 '26 12:02

James Webster