Skip to content

Commit

Permalink
Fix: Make @function override document type and allow standalone doc c…
Browse files Browse the repository at this point in the history
…omments for @function (#167)
  • Loading branch information
ShukantPal authored Jun 7, 2022
1 parent 4eca09d commit d20ba1d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/webdoc-parser/src/tag-parsers/parseSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function parseName(value: string, doc: $Shape<BaseDoc>): $Shape<NameTag>
return {
alias: value,
type: "NameTag",
value,
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/webdoc-parser/src/transformer/symbol-to-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const TAG_OVERRIDES: { [id: string]: string | any } = { // replace any, no lazy
"typedef": "TypedefDoc",
"namespace": "NSDoc",
"event": "EventDoc",
"function": "FunctionDoc",
};

// Tags that end only when another tag is found or two lines are blank for consecutively
Expand Down
38 changes: 38 additions & 0 deletions packages/webdoc-parser/test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,42 @@ describe("@webdoc/parser.parse", function() {

expect(docKeyEnum.members.length).to.equal(3);
});

it("should parse method overloads in orphan doc comments", async function() {
const documentTree = await parse(`
/** Rectangle */
class Rect {
/**
* Returns true if the rectangle contains the given rectangle
* @name contains
* @memberof Rect
* @function
* @param {Rect} rect
* @returns {boolean} true if contains
*/
/**
* Returns true if the rectangle contains the given point
* @name contains
* @memberof Rect
* @function
* @param {number} x - x coordinate
* @param {number} y - y coordinate
* @returns {boolean} true if contains
*/
/**
* Returns true if the rectangle contains the given point
* @name contains
* @memberof Rect
* @function
* @param {Vector2d} point
* @returns {boolean} true if contains
*/
contains() { }
}
`);

expect(findDoc("Rect", documentTree).members.length).to.equal(4);
});
});

0 comments on commit d20ba1d

Please sign in to comment.