How to mark code snippet in Headerdoc?

1k Views Asked by At

I usually need to write many short code in code comment like this. Is this possible to use in Apple's Headerdoc? Because this type of code notation is generally used heavily, so i believe there's a convenient way to do this instead of marking HTML tags.

5

There are 5 best solutions below

0
On BEST ANSWER

I ended up with using @c.

This is an example @c code-style text.
0
On

You need to format a block of code use: @code &@endcode tags like:

/**
 * @code
 * [myObj myMethod];
 * @endcode
 */

If you want to format a single word @c is enough, like:

/**
 * @c is enough
 */
1
On

Within your HeaderDoc, you can use this formatting:

 @code
// code text
while (someCondition) {
    NSLog(@"Hello");
    doSomething();
}@endcode
 Last line text.

Source: https://stackoverflow.com/a/19169271/1736056

0
On

I'm on Xcode 6.4/HeaderDoc 8.9 and neither @code nor @c work. <pre>code</pre> works but adds newlines.

I ended up being able to produce inline code snippets by using <tt>code</tt> (teletype text).

1
On

@code and @c don't seem to work as of Headerdoc 8.9. I ended up using:

<pre>@textblock
@/textblock</pre>