Writing multiple-line description in Xcode for parameters in Objective-C documentation - xcode

I am trying to do this:
/**
#param argumentString This is a multiline
comment
about
argumentString
*/
- (void)doSomething:(NSString *)argumentString;
But I don't think #param supports multiple lines describing the same parameter. I haven't been able to find out a way to do this yet; my end goal is to make all the text appear in the same section in the correct segment. With the above code the comment about argumentString part will be moved to the Description section instead. I've tried using #parblock but it doesn't seem to work.

It is very easy to do in Swift, but for Objective-C, there's a simple hack which can make a parameter description look like it is in multiple lines.
Simply add another param whose first word is a whitespace unicode character (other than space). In the following example, I have copied the unicode U+2007 in the 2nd line.
/**
This is the description
#param argumentString: This is a comment,
#param   which looks like a multiline comment
*/
- (void)doSomething:(NSString *)argumentString;
The second #param line in the example above is effectively this:
#param U+2007 <space> <comment-text>
The unicode which you could copy is :  
Result
This is how it renders in Xcode:

Try this:
/**
* #param argumentString This is a multiline
* comment
* about
* argumentString
*/

Related

80 character limit with ClangFormat works with comments starting with # but not \

I have a .clang-format with ColumnLimit: '80'. When I write doxygen blocks for functions like the following, they get neatly wrapped at 80 characters:
/**
* #brief Writes out the 80-byte header (in binary STL) for the STL representation of some geometry.
* #param[out] fileStream - The file to write the header to
*/
Becomes:
/**
* #brief Writes out the 80-byte header (in binary STL) for the STL
* representation of some geometry.
* #param[out] fileStream - The file to write the header to
*/
But if I do the same thing with \ instead of # it no longer automatically wraps if it goes over:
/**
* \brief Writes out the 80-byte header (in binary STL) for the STL representation of some geometry.
* \param[out] fileStream - The file to write the header to
*/
I should note that the following lines after a \, or just stray comment blocks work fine. IE, if I do
/**
* Here is a really long comment that is greater than 80 characters, notice how it gets wrapped?
*/
It becomes:
/**
* Here is a really long comment that is greater than 80 characters, notice
* how it gets wrapped?
*/
Why does this happen?
Clang version: 7.0.1
My IDE is QTCreator, version 4.7.2. I have it set to reformat files on saving them, which it does for everything. (Except comment lines starting with \)

PhpStorm Reformat Comments Automatically?

Is there any way for PhpStorm to automatically reformat all comments in my project? I've already changed the settings to use one-line comments but it doesn't seem to do anything when I run the code formatter.
For example, let's say I have the following comment:
/*
* Hello, I am a comment
*/
Is there any way for PhpStorm to auto-convert it to this:
// Hello, I am a comment
I'd also want it to work for multi-line comments i.e.:
/*
* Hello, I am a comment
* I'm on multiple lines
*/
Should become this:
// Hello, I am a comment
// I'm on multiple lines
Is it possible for PhpStorm to do this for my entire project automatically?
Just ended up doing a regex replace:
find: \/\*\n(.*)\* (.*)\n(.*)\*\/
replace: // $2
That worked for my first comment, the one with multiple lines I just changed manually.

How do you include a dot in names/events/callbacks with jsDoc?

The documentation for namepaths says you should escape special characters:
Above is an example of a namespace with "unusual" characters in its
member names (the hash character, dashes, even quotes). To refer to
these you just need quote the names: chat."#channel",
chat."#channel"."op:announce-motd", and so on. Internal quotes in
names should be escaped with backslashes:
chat."#channel"."say-\"hello\""
However, this doesn't work on dots. If I have an event called "cellClick.dt" that I want to document, jsDoc skips the documentation from the output, and generates an incorrect link in the table of contents. I have tried the following combinations:
myClass~event.namespace
'myClass~event.namespace'
myClass~event\.namespace
myclass~'event.namespace'
All of them generate broken docs in some way. The last one at least seem to generate correct links and docs, but the apostrophes are still here in the output. This makes it very cumbersome to document code that uses dots for namespace separators in events (like eg. jQuery plugins do by default).
What's the correct way to do this? Is there one? The version I'm using is 3.3.0-alpha9.
I would suggest doing this:
/**
* #class
*/
function myClass () {
}
/**
* #memberof myClass
* #event event.namespace
*/
The event is properly named and is a member of myClass. It's annoying to have to split off the full name in two parts but at least the result is not ugly.

Multilined commenting in vim using /** ... */

Note: When I'm describing /** ... */ comment blocks, I'm referring to the following types of comment blocks
/**
* This is a comment block that
* spans multiple lines.
*
* Each line is prefixed with a "\t* " string
*/
I'm used to the very automated commenting of comment blocks in IDEs, but it doesn't seem that vim supports these kinds of comments too well.
Specifically, I'm looking for this kind of automated functionality. Say you have the following comment
/**
* This is a comment and I plan to run to the next line.
In vim's insert mode, when my cursor is at the period and I hit "enter", I want another "\t* " string to be placed on the new line.
Furthermore, when I hit "/" to end the comment block on a brand new line starting with "\t* ", it would delete the space and place "/" on this new line.
For example, if I have
/**
* This is a comment and I plan to run to the next line.
*
(with a space after the '*' character), and I hit "/", I should produce
/**
* This is a comment and I plan to run to the next line.
*/
Any plug in or vimscript that would help me support this?
Note that I've looked at the nerd commenter already, but the comments created by the nerd commenter don't seem automated (ie: I have to press a keystroke or two to activate commenting.)
Also, whenever I make block comments, I always start with "/**".
Vim can do this by itself. Just add
filetype plugin indent on
to your vimrc.
After this is done the defualt ftplugins should enable it for you. If it doesn't I believe adding to ~/.vim/after/ftplugin/{filetype}.vim
setlocal formatoptions+=r
should enable it.

Are there any tools in IDEs to automatically fix comment formatting?

/* Suppose I have a multi-line comment with hard line-breaks
* that are roughly uniform on the right side of the text,
* and I want to add text to a line in order to make the
* comment a bit more descriptive.
*/
Now, most unfortunately, I need to add text to one of the top lines.
/* Suppose I have a multi-line comment with hard line-breaks (here is some added text for happy fun time)
* that are roughly uniform on the right side of the text,
* and I want to add text to a line in order to make the
* comment a bit more descriptive.
*/
It takes O(n) time (n being the number of lines) to fix each line so that they roughly line up again. The computer should do this, not me.
Are there tools to deal with this in our IDEs? What are they called?
emacs supports the command fill-paragraph which is typically mapped to meta-q.
Output from fill-paragraph on your second paragraph of text:
/* Suppose I have a multi-line comment with hard line-breaks (here is
* some added text for happy fun time) that are roughly uniform on the
* right side of the text, and I want to add text to a line in order
* to make the comment a bit more descriptive.
*/
Eclipse has this built in (at least, I think it's what you want). When you type a comment, you then type Ctrl+Shift+F and it will format either all your code, or just the section of code that you have highlighted.
I just tested it now and it aligned all my comments for me.

Resources