8
8
EventDescriptor ,
9
9
ParamTag ,
10
10
ParamType ,
11
+ Tag ,
11
12
} from '../Documentation'
12
13
import getDocblock from '../utils/getDocblock'
13
14
import getDoclets from '../utils/getDoclets'
@@ -34,24 +35,31 @@ export default function eventHandler(
34
35
if ( ! args . length ) {
35
36
return false
36
37
}
38
+ // fetch the leading comments on the wrapping expression
39
+ const docblock = getDocblock ( pathExpression . parentPath )
40
+ const doclets = getDoclets ( docblock || '' )
41
+ let eventName : string
42
+ const eventTags = doclets . tags ? doclets . tags . filter ( d => d . title === 'event' ) : [ ]
43
+
44
+ // if someone wants to document it with anything else, they can force it
45
+ if ( eventTags . length ) {
46
+ eventName = ( eventTags [ 0 ] as Tag ) . content as string
47
+ } else {
48
+ let firstArg = pathExpression . get ( 'arguments' , 0 )
49
+ if ( bt . isIdentifier ( firstArg . node ) ) {
50
+ firstArg = resolveIdentifier ( astPath , firstArg )
51
+ }
37
52
38
- let firstArg = pathExpression . get ( 'arguments' , 0 )
39
- if ( bt . isIdentifier ( firstArg . node ) ) {
40
- firstArg = resolveIdentifier ( astPath , firstArg )
41
- }
42
-
43
- if ( ! bt . isStringLiteral ( firstArg . node ) ) {
44
- return false
53
+ if ( ! bt . isStringLiteral ( firstArg . node ) ) {
54
+ return false
55
+ }
56
+ eventName = firstArg . node . value
45
57
}
46
58
47
- const eventName = firstArg . node . value
48
-
49
59
// if this event is documented somewhere else leave it alone
50
60
const evtDescriptor = documentation . getEventDescriptor ( eventName )
51
61
52
- // fetch the leading comments on the wrapping expression
53
- const docblock = getDocblock ( pathExpression . parentPath )
54
- setEventDescriptor ( evtDescriptor , getDoclets ( docblock || '' ) )
62
+ setEventDescriptor ( evtDescriptor , doclets )
55
63
56
64
if ( args . length > 1 && ! evtDescriptor . type ) {
57
65
evtDescriptor . type = {
0 commit comments