-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Refactoring documentation contribution point #86788
Comments
I don't know that I have the data to populate this, though the idea sounds good to me. I think there many other places that exposing docs would be great - I opened #71541 previously, but there it was resolved as a dupe of another case that never got a concensus on the fix (which is a shame, because I think it's a tiny change with a large impact for users). |
I'm in favor of the contribution point, but both approaches work. |
While the static contribution point would work perfectly, the
This also allows the language server to generate more precise documentation according to the context. So I prefer the LSP way. |
My preference is for something static but similar to the previous approaches we need to make sure that extensions can provide this - tho the approach seems to have the right amount of indirection for this. I am wondering if there are synergies with the work we are doing around extensions adding "getting started" or "playground parts" etc? |
@DanTup If you have a webpage that documents refactorings, you could link users to that. It doesn't need to be anything fancy to start off, just a list and a quick description of what each refactoring does @akaroml Good points about the LSP support. One other consideration with using code actions to return documentation is that other editors would likely not know what to do with the returned @jrieken I also like the idea of idea of integrating this with our other documentation exploration but worry that may take a while to finalize. Maybe we should try delivering a scoped solution that only handles code actions so that Java and others can play around with the idea, and then look into how this would fit with our larger documentation/getting started experiences? |
@jrieken Thank you for bringing up the synergy idea! I do see those three approaches sharing similar goals. As an extension author, I really appreciate the platform providing a clear picture of how those UI elements can work together and serve different use cases! And here to share some of the challenges and use cases. Code Actions Challenges
Getting Started
Rich Tutorial ExperienceStudents are a large group in our user base. And tutorials are great for them to learn and practice. Now the best we can do is to show the documentation and an editor side by side. It's already working but it could be even better if the documentation can interact with the editor, and I see that a playground. @mjbvz Agreed. We'll always happy to try new APIs and see how they work. |
@jrieken I've changed the contribution point proposal to be more generic to better support that:
Here's how this is rendered in the editor: |
@jdneo This is an enhancement to the documentation of refactoring features. Let's try it. |
We are trying to improve the discoverability of code actions. To do this, we need to have a baseline of how often people are applying actions such as refactorings so that we can measure if changes like adding documentation have an impact on their usage rates. Ref #86788
I'm going to push the following changes:
The telemetry was added to provide a baseline so that we can understand if documentation entry improves refactoring usage (we have had js/ts specific refactoring telemetry for a long time, but now we can measure other languages/extensions as well). To measure if the documentation entry improves refactoring usage, we probably want to do an A/B test. There are a few options we are interest in comparing:
|
@jdneo could you help put this on deck so we can track it? |
@akaroml Sure. |
@mjbvz @jrieken I'm thinking that if this cool feature could work together with the refactor preview The What if the user wants to learn more about one specific refactoring? Maybe we could list multiple document actions in the list for different refactorings, but that could be too noisy to me. While in the preview UI, since the kind of refactoring is already determined, which might be a good place to put a document entry to let the user lean more details about the triggered refactoring. |
Thanks I've And I'm wondering if it's best to rather make this strictly about documentation... we make it more generic. "This CodeAction appears every time for this CodeActionProvider" |
Hi @mjbvz I was trying this new contribution point, but the when clause seems not working if I set it to Other conditions like |
@jdneo In VS Code, we've update the proposal to use a |
Thank you @mjbvz In our case, the Java language server will directly return the code actions to the client so we do not have a code action provider at the client side. I tried to registered a dummy provider like following: export class RefactorDocumentProvider implements CodeActionProvider {
provideCodeActions() {
return [];
}
public static readonly metadata: CodeActionProviderMetadata = {
providedCodeActionKinds: [
CodeActionKind.Refactor,
],
documentation: [
{
kind: CodeActionKind.Refactor,
command: {
command: Commands.LEARN_MORE_ABOUT_REFACTORING,
title: 'Learn more about Java refactorings.'
}
}
]
}
} No matter I return I have set the |
@jdneo Your provided needs to return one or more code actions of the given type (such as refactoring) for the documentation to show up. |
Thank you @mjbvz I've tried to return a valid code action, like |
@mjbvz ping... I tried the latest Insider today but still cannot see the document command entry in the menu. Not sure if I did anything wrong. BTW, since in our case, the Thank you for your time. |
I've update our code action example to show how to use the Our eventual goal is to integrate |
Thank you @mjbvz for the sample. I made a mistake that I forgot to pass the metadata when registering the code action provider. Now everything works great! And the document command can show-up even I return an empty array in the code action provider. Then we can avoid using the contribution point in the package.json. Thank you for your help! |
Hi @mjbvz, another question about the document: Let's say I have a code action provider defined as below: export class RefactorDocumentProvider implements CodeActionProvider {
provideCodeActions() {
return [];
}
public static readonly metadata: CodeActionProviderMetadata = {
providedCodeActionKinds: [
CodeActionKind.RefactorExtract,
CodeActionKind.Refactor,
],
documentation: [
{
kind: CodeActionKind.RefactorExtract,
command: {
command: Commands.LEARN_MORE_ABOUT_EXTRACT_REFACTORING,
title: 'Learn more about Java extract refactorings.'
}
},
{
kind: CodeActionKind.Refactor,
command: {
command: Commands.LEARN_MORE_ABOUT_REFACTORING,
title: 'Learn more about Java refactorings.'
}
}
]
}
} It won't return any code action. But registered document command for both I tried from my side and found that, even if the code action listed are all |
Some findings: In the above case, the client code action provider won't return any code action but registered different kinds of document. The real code action is resolved at the Language Server side. If the refactoring list is popped up by click the If the refactoring list is popped up by triggering the keyboard shortcut of command |
@mjbvz Just noticed the release target update to April release. Does that mean the API will have some changes? |
@mjbvz This change was pushed several times. Can we expect the release in June? |
@akaroml We were kinda waiting for you feedback to know if the proposed API change is sufficient for your need? |
@jrieken @mjbvz Just FYI we've already proposed a draft PR for this new API (Attached a gif in that PR). So far so good! Just one question: When user clicks |
Problem
Many language/extension implement really cool refactorings, but many users never discover these or figure out how to reliably trigger them.
Proposal
Add a way for an extension to contribute documentation for their refactorings. Our goal here would be to help users reach the documentation and leave the presentation of the documentation up to extensions themselves.
Target UX
Let users explicitly request to see the refactoring documentation from the existing code action refactor menu. This could be as simple as a
Learn more
entry at the bottom of the refactoring menu.The
learn more
action would do the following:API
Current proposal
The current proposal is the add a
documentation
field toCodeActionProviderMetadata
that let's extension surface a command that shows documentation:original proposal
I see two possible ways this could be implemented:
Through a contribution point
Create a new
documentation.refactoring
contribution point that lets extension define a command that shows the documentation:Through a new
refactor.documentation
code action kindDefine a special code action kind called
refactor.documentation
. If an extension returns a code action with this kind, then we could surface this using some special UI in the refactor menu(extensions would be expected to return the
refactor.documentation
action whenever refactorings are requested)/cc @kieferrm
/cc @jrieken for api
/cc @misolori for ux
The text was updated successfully, but these errors were encountered: