How do you include a dot in names/events/callbacks

2019-06-26 01:25发布

问题:

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.

回答1:

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.