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 codeblock detection to catch blocks not on first lines #132821

Merged
merged 1 commit into from Oct 7, 2021

Conversation

Gerrit0
Copy link
Contributor

@Gerrit0 Gerrit0 commented Sep 10, 2021

This PR fixes #132820

@mjbvz
Copy link
Contributor

mjbvz commented Sep 10, 2021

Thanks for the PR! I think this makes sense but can you also add some tests to make sure we are doing the correct thing and don't regress this in the future:

@mjbvz mjbvz added this to the September 2021 milestone Sep 10, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Sep 10, 2021

One thing actually: we need to support @example without fenced code blocks: https://jsdoc.app/tags-example.html

For those cases, the text should be treated as if it was a code block even though there is no explicit fenced code block

@Gerrit0
Copy link
Contributor Author

Gerrit0 commented Sep 10, 2021

@mjbvz am I missing something obvious here? I tried to follow the instructions at https://github.com/microsoft/vscode/blob/main/test/unit/README.md to run the tests (with --grep typescript.previewer since there are entirely too many). This command can't seem to find the tests.
Running with yarn run mocha --ui tdd --run ./extensions/typescript-language-features/src/test/unit/previewer.test.ts can't find the file (it replaces the ts extension with js). If I try to run the built file in a way that I'd expect to work, yarn test .\extensions\typescript-language-features\out\test\unit\previewer.test.js, it can't find vscode

@mjbvz
Copy link
Contributor

mjbvz commented Sep 14, 2021

You can run them through VS Code's debug view:

Screen Shot 2021-09-14 at 11 59 55 AM

@mjbvz mjbvz removed this from the September 2021 milestone Sep 16, 2021
@Gerrit0
Copy link
Contributor Author

Gerrit0 commented Sep 18, 2021

Thanks! No wonder I didn't see that... have never really heavily used the debugger for tests.

Test cases:

/**
 * @example
 * foo();
 * 
 * @example
 * Caption
 * ```ts
 * foo();
 * ```
 */
function foo() {

}

image

/**
 * @example <caption>Caption</caption>
 * bar();
 * 
 * @example <caption>Caption</caption>
 * ```ts
 * bar();
 * ```
 */
function bar() {
    
}

image

@Gerrit0
Copy link
Contributor Author

Gerrit0 commented Sep 18, 2021

Disabled tests were failing, unrelated to my changes.

Copy link
Contributor

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

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

LGTM besides the comments

@mjbvz mjbvz added this to the October 2021 milestone Sep 27, 2021
@Gerrit0 Gerrit0 closed this Sep 29, 2021
@Gerrit0 Gerrit0 reopened this Sep 29, 2021
@mjbvz mjbvz merged commit 3629e68 into microsoft:main Oct 7, 2021
@mjbvz
Copy link
Contributor

mjbvz commented Oct 7, 2021

Thanks! This change will in the next VS Code 1.62 insiders build

@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TSDoc @example tag is improperly handled in previews
4 participants