microsoft / microsoft/language-server-protocol

A generic method to get documentation string or `SignatureInformation`

Open
#2,031 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request help wanted new request
Dominant language
TypeScript
Stars
13k
Forks
1k
Avg merge
6d 1h
Merged PRs (30d)
10

Description

I need to build a feature that lists all functions, classes, and methods in a file (or workspace) including possible documentation strings.

Currently textDocument/documentSymbol returns documentSymbol that includes name, detail, and kind. But there's no way to get documentation strings.

In textDocument/signatureHelp, there already is support for docstrings: SignatureInformation includes all the necessary metadata about the signature, label, documentation, and parameters. However, as far as I understand, this request can only be triggered from a use (e.g., of a function), not via the function declaration itself.

There should be a generic way to obtain this information. I see three possibilities:

  1. A request for getting docstrings, similar to https://github.com/microsoft/language-server-protocol/issues/1034 or https://github.com/microsoft/language-server-protocol/issues/1508
  2. A request to get SignatureInformation from declaration or implementation location.
  3. Extend textDocument/documentSymbol to include SignatureInformation or documentation attribute.

In inclined to favor option 2. as it is generic and most backward compatible.

It seems that many LSP servers already support documentation strings (they're being included in hover results for example), so in most cases the server already has this information, it just cannot be easily accessed.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the existing textDocument/documentSymbol and textDocument/signatureHelp requests and their documented fields. Review the related discussions in issues 1034 and 1508, then evaluate the three proposed approaches. Done means selecting and specifying a generic, backward-compatible way to obtain documentation or SignatureInformation from declarations.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.