-
Notifications
You must be signed in to change notification settings - Fork 21
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 directives support #453
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, the "core" language server class has been responsible for indexing and generating completions for directives. This functionality has now been moved out into the `Directives` language feature which actually delegates this task to any of the `DirectiveLanguageFeatures` that have been registered. Additionally, up until now there has been no distinction made between indexing directives, generating completion suggestions and "rendering" these into `CompletionItem` instances. However, since the `function::` directive in the Python domain can be referenced through both `function` and `py:function` it's important recognise these as distinct steps. Therefore generating completions for directives is now split into the following steps. - indexing: Discovery of available directive implementations - suggesting: Suggesting the "names" that can be used for a given directive in a given context (e.g. `function` and `py:function`) - rendering: Taking the list of suggested names and converting them into `CompletionItem` objects to send to the client. `DirectiveLanguageFeatures` are responsible for the first two steps and can implement the `index_directives` and `suggest_directives` methods while the final rendering step is handled by the `Directives` language feature itself. The `RstLanguageServer.get_directives()` method has been deprecated in favour of the new method with the same name on the `Directives` language feature.
Since `DirectiveLanguageFeatures` are now responsible for discovering the available directives, they are also the best suited to determine which options a directive has. Subclasses can now implement the `suggest_options` method to provide this functionality. Additionally, in order to correctly determine the correct implementation given some name for a directive we need to be able to do the inverse of the index -> suggest step of generating completions. So `DirectiveLanguageFeatures` that provide directive implementations should also implement the `get_implementation` method.
This aligns docutils support to the new `DirectiveLanguageFeature` API.
This aligns support for Sphinx's domains to the new `DirectiveLanguageFeaure` API
This aligns support to the new `DirectiveLanguageFeature` API
The `DirectiveLanguageFeature` API introduces a few subtle changes, this aligns the test suite to match
This adds a how to guide on providing support for new directive registries using a `DirectiveLanguageFeature` This also introduces some doctests for the directive regular expressions.
alcarney
changed the title
[WIP] Refactoring domain support
Refactoring directive support
Oct 15, 2022
alcarney
changed the title
Refactoring directive support
Refactoring directives support
Oct 15, 2022
This was referenced Nov 27, 2022
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Building on the
DirectiveLanguageFeatures
introduced in #444, this PR introduces a number of new methods features can implementindex_directives
: used to discover available directive implementationssuggest_directives
: used to determine which directive names can be suggested in the current completion context (function
vspy:function
vsc:function
etc.)get_implementation
: used to go from a directive name (function
vspy:function
) to its implementationsuggest_options
: used to determine which directive options can be suggested in the current completion contextThis should also enable implementing other features such as #105, #312 , #414 etc.
Finally, both
<primary_domain>:function
andfunction
are offered as completion suggestions as they are both valid.Working towards #416