microsoft/language-server-protocol

A generic method to get documentation string or `SignatureInformation`

开放

#2,031 创建于 2024年9月30日

 (4 条评论) (2 个反应) (0 位负责人)HTML (956 个派生)batch import
feature-requesthelp wantednew request

仓库指标

星标
 (12,810 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南