-
Notifications
You must be signed in to change notification settings - Fork 20
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
Initial completionItem/resolve
support
#284
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
The way to reference language features is now `full.module.path.Class` so for example the `roles` feature is now referred to as `esbonio.lsp.roles.Roles`. This removes allows us to be much more precise about referencing features going forward.
alcarney
force-pushed
the
completion-resolve
branch
3 times, most recently
from
February 12, 2022 12:07
de01f89
to
6ecd97d
Compare
This is to cope with directives like `.. rst:directive:option::`
The language server now advertises `completionItem/resolve` support. There is also a new `completion_resolve` method on `LanguageFeatures` that is called whenever a client asks for more details on a `CompletionItem` produced by that feature.
Since directive implementations can be overriden, the name of a directive is not a reliable way to identify them. So we now use the `detail` field on a `CompletionItem` to carry the fully qualified name of the class that implements them. With some additional metadata in the `data` field on a `CompletionItem`, the directives language feature now uses the `completionItem/resolve` request to provide documentation for a directive and its options. This relies on the langauge feature being loaded up with the documentation for the relevant items as it typically not available as docstrings on the implementation. This is done through the `add_documentation` method and by default the language server will look for the following files. - `esbonio/lsp/rst/directives.json` - `esbonio/lsp/sphinx/directives.json` Which should contain the documentation for `docutils` and `sphinx` directives respectively.
This adds the `scripts/generate_docutils_documentation.py` script which pulls the latest rst source files for the reference directive and roles documentation pages from the docutils docs site. Example usage: python scripts/generate_docutils_documentation.py -o lib/esbonio/esbonio/lsp/rst/ The script produces a file `directives.json` with the following structure ``` { "name(module.path.ClassName)": { "is_markdown": true, "description": [ "# Some title", "This is useful when...", ... ] "options": { "opt1": "...", ... } } } ``` As well as a file `roles.json` with a similar structure This corresponds with the dictionary structure expected by the `Directives` and `Roles` language features. This commit also adds the result of running the script.
This script uses the `objects.inv` file published by the Sphinx documentation site to discover and scrape the documentation for roles and directives added by Sphinx. The resulting documentation is then saved as a JSON file that can be loaded by the language server. It is far from perfect but its probably good enough for now and we can continue to refine it over time. This commit also adds the result of running the script.
alcarney
force-pushed
the
completion-resolve
branch
from
February 12, 2022 12:57
2d92e02
to
e0b4731
Compare
alcarney
force-pushed
the
completion-resolve
branch
from
February 12, 2022 13:24
f170ba1
to
926835c
Compare
alcarney
force-pushed
the
completion-resolve
branch
from
February 12, 2022 18:57
80fa41f
to
a5a7085
Compare
for more information, see https://pre-commit.ci
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.
completionItem/resolve
support to the language server, and for role, directive and directive options.Closes Investigate
completionItem/resolve
requests #274CompletionItems
during acompletionItem/resolve
request.Closes Better directive completions #36
This PR supersedes #251.