Skip to content

Commit d20ba1d

Browse files
authored
Fix: Make @function override document type and allow standalone doc comments for @function (#167)
1 parent 4eca09d commit d20ba1d

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

packages/webdoc-parser/src/tag-parsers/parseSimple.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export function parseName(value: string, doc: $Shape<BaseDoc>): $Shape<NameTag>
123123
return {
124124
alias: value,
125125
type: "NameTag",
126+
value,
126127
};
127128
}
128129

packages/webdoc-parser/src/transformer/symbol-to-doc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const TAG_OVERRIDES: { [id: string]: string | any } = { // replace any, no lazy
122122
"typedef": "TypedefDoc",
123123
"namespace": "NSDoc",
124124
"event": "EventDoc",
125+
"function": "FunctionDoc",
125126
};
126127

127128
// Tags that end only when another tag is found or two lines are blank for consecutively

packages/webdoc-parser/test/parse.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,42 @@ describe("@webdoc/parser.parse", function() {
210210

211211
expect(docKeyEnum.members.length).to.equal(3);
212212
});
213+
214+
it("should parse method overloads in orphan doc comments", async function() {
215+
const documentTree = await parse(`
216+
/** Rectangle */
217+
class Rect {
218+
/**
219+
* Returns true if the rectangle contains the given rectangle
220+
* @name contains
221+
* @memberof Rect
222+
* @function
223+
* @param {Rect} rect
224+
* @returns {boolean} true if contains
225+
*/
226+
227+
/**
228+
* Returns true if the rectangle contains the given point
229+
* @name contains
230+
* @memberof Rect
231+
* @function
232+
* @param {number} x - x coordinate
233+
* @param {number} y - y coordinate
234+
* @returns {boolean} true if contains
235+
*/
236+
237+
/**
238+
* Returns true if the rectangle contains the given point
239+
* @name contains
240+
* @memberof Rect
241+
* @function
242+
* @param {Vector2d} point
243+
* @returns {boolean} true if contains
244+
*/
245+
contains() { }
246+
}
247+
`);
248+
249+
expect(findDoc("Rect", documentTree).members.length).to.equal(4);
250+
});
213251
});

0 commit comments

Comments
 (0)