Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix github links for @typedef comments #1024

Merged
merged 6 commits into from
Mar 1, 2018

Conversation

boblannon
Copy link
Contributor

Unlike other comment blocks, @typedef blocks are usually not directly associated with any lines of code.

eg, from usejsdoc:

/**
 * A number, or a string containing a number.
 * @typedef {(number|string)} NumberLike
 */

/**
 * Set the magic number.
 * @param {NumberLike} x - The magic number.
 */
function setMagicNumber(x) {
}

Currently, the github link that's produced for a @typedef block points to the nearest AST node, which would be the function in this case. This change uses the comment block's location instead.

@boblannon
Copy link
Contributor Author

I've been having a lot of difficulty with testing. I'm not familiar with jest, and the error messages I'm seeing seem obviously not true.

@coveralls
Copy link

coveralls commented Feb 28, 2018

Coverage Status

Coverage increased (+0.05%) to 86.115% when pulling c36ab61 on boblannon:github-typedef-link into 487336f on documentationjs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 86.115% when pulling c36ab61 on boblannon:github-typedef-link into 487336f on documentationjs:master.

'-' +
'L' +
comment.context.loc.end.line,
urlPrefix + fileRelativePath + '#L' + startLine + '-' + 'L' + endLine,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't intend to re-format this, fwiw. Looks like a commit hook re-formatted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's the intended way - we use husky to add a commit hook and then lint-staged to run run prettier on source files. It's a mouthful but it totally eliminates stylistic eslint rules, the computer decides what's best in terms of formatting. And since this changes comment.context.loc.end.line to endLine, the computer decided that it's short enough to fit on one line, so it did :)

@tmcw
Copy link
Member

tmcw commented Mar 1, 2018

👍 Great, thanks Bob! Merging and rolling a release in a bit.

@tmcw tmcw merged commit 37a91b2 into documentationjs:master Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants