7

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.

eonil
  • 83,476
  • 81
  • 317
  • 516

5 Answers5

6

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
 */
eonil
  • 83,476
  • 81
  • 317
  • 516
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
4

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

Community
  • 1
  • 1
ataranlen
  • 138
  • 1
  • 9
1

I ended up with using @c.

This is an example @c code-style text.
eonil
  • 83,476
  • 81
  • 317
  • 516
1

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

<pre>@textblock
@/textblock</pre>
ctn
  • 2,887
  • 13
  • 23
1

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).

dvs
  • 12,324
  • 6
  • 38
  • 45