1
- import { ConstructorMirror , DocComment , MethodMirror } from '@cparra/apex-reflection' ;
1
+ import { ConstructorMirror , DocComment } from '@cparra/apex-reflection' ;
2
2
import { MarkdownFile } from '../markdown-file' ;
3
3
import { ParameterMirror } from '@cparra/apex-reflection/index' ;
4
4
import { addCustomDocCommentAnnotations } from './doc-comment-annotation-util' ;
5
+ import { MethodMirrorWithInheritance } from '../inheritance' ;
5
6
6
7
export function declareMethod (
7
8
markdownFile : MarkdownFile ,
8
- methods : ConstructorMirror [ ] | MethodMirror [ ] ,
9
+ methods : ConstructorMirror [ ] | MethodMirrorWithInheritance [ ] ,
9
10
startingHeadingLevel : number ,
10
11
className = '' ,
11
12
) : void {
12
13
methods . forEach ( ( currentMethod ) => {
13
- const signatureName = isMethod ( currentMethod ) ? ( currentMethod as MethodMirror ) . name : className ;
14
+ const signatureName = isMethod ( currentMethod ) ? ( currentMethod as MethodMirrorWithInheritance ) . name : className ;
14
15
markdownFile . addTitle ( `\`${ buildSignature ( signatureName , currentMethod ) } \`` , startingHeadingLevel + 2 ) ;
16
+
17
+ // Inheritance tag
18
+ if ( isMethod ( currentMethod ) ) {
19
+ const asMethodMirror = currentMethod as MethodMirrorWithInheritance ;
20
+ if ( asMethodMirror . inherited ) {
21
+ markdownFile . addBlankLine ( ) ;
22
+ markdownFile . addText ( '*Inherited*' ) ;
23
+ markdownFile . addBlankLine ( ) ;
24
+ }
25
+ }
26
+
15
27
currentMethod . annotations . forEach ( ( annotation ) => {
16
28
markdownFile . addBlankLine ( ) ;
17
29
markdownFile . addText ( `\`${ annotation . type . toUpperCase ( ) } \`` ) ;
@@ -28,7 +40,7 @@ export function declareMethod(
28
40
}
29
41
30
42
if ( isMethod ( currentMethod ) ) {
31
- addReturns ( markdownFile , currentMethod as MethodMirror , startingHeadingLevel ) ;
43
+ addReturns ( markdownFile , currentMethod as MethodMirrorWithInheritance , startingHeadingLevel ) ;
32
44
}
33
45
34
46
addThrowsBlock ( markdownFile , currentMethod , startingHeadingLevel ) ;
@@ -53,8 +65,8 @@ type DocCommentAware = {
53
65
54
66
function buildSignature ( name : string , parameterAware : ParameterAware ) : string {
55
67
let signature = `${ name } (` ;
56
- if ( isMethod ( parameterAware ) && ( parameterAware as MethodMirror ) . memberModifiers . length ) {
57
- signature = ( parameterAware as MethodMirror ) . memberModifiers . join ( ' ' ) + ' ' + signature ;
68
+ if ( isMethod ( parameterAware ) && ( parameterAware as MethodMirrorWithInheritance ) . memberModifiers . length ) {
69
+ signature = ( parameterAware as MethodMirrorWithInheritance ) . memberModifiers . join ( ' ' ) + ' ' + signature ;
58
70
}
59
71
const signatureParameters = parameterAware . parameters . map ( ( param ) => `${ param . type } ${ param . name } ` ) ;
60
72
signature += signatureParameters . join ( ', ' ) ;
@@ -63,7 +75,7 @@ function buildSignature(name: string, parameterAware: ParameterAware): string {
63
75
64
76
function addParameters (
65
77
markdownFile : MarkdownFile ,
66
- methodModel : MethodMirror | ConstructorMirror ,
78
+ methodModel : MethodMirrorWithInheritance | ConstructorMirror ,
67
79
startingHeadingLevel : number ,
68
80
) {
69
81
if ( ! methodModel . docComment ?. paramAnnotations . length ) {
@@ -83,7 +95,11 @@ function addParameters(
83
95
markdownFile . addBlankLine ( ) ;
84
96
}
85
97
86
- function addReturns ( markdownFile : MarkdownFile , methodModel : MethodMirror , startingHeadingLevel : number ) {
98
+ function addReturns (
99
+ markdownFile : MarkdownFile ,
100
+ methodModel : MethodMirrorWithInheritance ,
101
+ startingHeadingLevel : number ,
102
+ ) {
87
103
if ( ! methodModel . docComment ?. returnAnnotation ) {
88
104
return ;
89
105
}
@@ -127,6 +143,8 @@ function addExample(markdownFile: MarkdownFile, docCommentAware: DocCommentAware
127
143
markdownFile . addBlankLine ( ) ;
128
144
}
129
145
130
- function isMethod ( method : MethodMirror | ConstructorMirror | ParameterAware ) : method is ConstructorMirror {
131
- return ( method as MethodMirror ) . type !== undefined ;
146
+ function isMethod (
147
+ method : MethodMirrorWithInheritance | ConstructorMirror | ParameterAware ,
148
+ ) : method is ConstructorMirror {
149
+ return ( method as MethodMirrorWithInheritance ) . type !== undefined ;
132
150
}
0 commit comments