@@ -63,6 +63,12 @@ for (const file of files) {
6363
6464parse ( ) ;
6565
66+ /**
67+ * @typedef {Object } SeeObject
68+ * @property {String } text The text to display the link as
69+ * @property {String } [url] The link the text should have as href
70+ */
71+
6672/**
6773 * @typedef {Object } PropContext
6874 * @property {boolean } [isStatic] Defines wheter the current property is a static property (not mutually exlusive with "isInstance")
@@ -77,6 +83,7 @@ parse();
7783 * @property {string } [anchorId] Defines the Anchor ID to be used for linking
7884 * @property {string } [description] Defines the Description the property will be listed with
7985 * @property {string } [deprecated] Defines wheter the current Property is signaled as deprecated
86+ * @property {SeeObject[] } [see] Defines all "@see" references
8087 */
8188
8289function parse ( ) {
@@ -133,6 +140,40 @@ function parse() {
133140
134141 for ( const tag of prop . tags ) {
135142 switch ( tag . type ) {
143+ case 'see' :
144+ if ( ! Array . isArray ( ctx . see ) ) {
145+ ctx . see = [ ] ;
146+ }
147+
148+ // for this type, it needs to be parsed from the string itself to support more than 1 word
149+ // this is required because "@see" is kinda badly defined and mongoose uses a slightly customized way (longer text and different kinds of links)
150+
151+ // the following regex matches cases of:
152+ // "External Links http://someurl.com/" -> "External Links"
153+ // "External https://someurl.com/" -> "External"
154+ // "Id href #some_Some-method" -> "Id href"
155+ // "Local Absolute /docs/somewhere" -> "Local Absolute"
156+ // "No Href" -> "No Href"
157+ // "https://someurl.com" -> "" (fallback added)
158+ // "Some#Method #something" -> "Some#Method"
159+ // The remainder is simply taken by a call to "slice" (also the text is trimmed later)
160+ const textMatches = / ^ ( .* ? (? = # | \/ | (?: h t t p s ? : ) | $ ) ) / i. exec ( tag . string ) ;
161+
162+ let text ;
163+ if ( textMatches === null || textMatches === undefined ) {
164+ // warn because this most likely is a badly defined "@see"
165+ console . warn ( `No Text Matches found in @see for "${ ctx . constructor } .${ ctx . name } "` )
166+ break ;
167+ } else {
168+ text = textMatches [ 1 ] . trim ( ) ;
169+ }
170+
171+ const url = tag . string . slice ( text . length ) . trim ( ) ;
172+ ctx . see . push ( {
173+ text : text || 'No Description' , // fallback text, so that the final text does not end up as a empty element that cannot be seen
174+ url : url || undefined , // change to be "undefined" if text is empty or non-valid
175+ } ) ;
176+ break ;
136177 case 'receiver' :
137178 console . warn ( `Found "@receiver" tag in ${ ctx . constructor } ${ ctx . name } ` ) ;
138179 break ;
0 commit comments