Skip to content

Add documentation to LSP#5267

Merged
muglug merged 10 commits intovimeo:masterfrom
joehoyle:lsp-documentation
Feb 24, 2021
Merged

Add documentation to LSP#5267
muglug merged 10 commits intovimeo:masterfrom
joehoyle:lsp-documentation

Conversation

@joehoyle
Copy link
Copy Markdown
Contributor

This adds documentation to several features of the LSP. Specifically:

Functions, methods, classes, class constants and class properties will now display their documentation/description in the IDE's Hover information, Autocomplete lists and Signature Information.

Here's some examples:

Autocomplete documentation:

Hover documentation:

Documentation in function param signature

I mostly modeled these off the default TypeScript documentation in VS Code.

--

This is blocked on felixfbecker/php-language-server-protocol#17

Personally I am bullish on including documentation on all the PHP inbuilt functions, this reflects what the Typescript / JS LSP by default also does.

I didn't yet add guards around all documentation collection for the LSP only -- I wasn't quite sure how to do that (I imagine that is stored in the config object?), though I wasn't sure how difficult it would be to get the scope/context of that value at each point.

As a comparison, I ran ./vendor/bin/psalm --no-cache --no-reflection-cache --no-file-cache . on a pretty large WordPress project (which makes a lot of use of phpdocumentation)

master
Checks took 5.19 seconds and used 552.723MB of memory

lsp-documentation
Checks took 5.19 seconds and used 554.804MB of memory

@muglug
Copy link
Copy Markdown
Collaborator

muglug commented Feb 22, 2021

This is blocked on felixfbecker/php-language-server-protocol#17

I've just bumped that package version, so you can bump that here and all should be good

@joehoyle
Copy link
Copy Markdown
Contributor Author

@muglug I've updated that dev, thanks! Currently the listing is failing on a long line with a @param array{... doc block. I don't think Psalm supports breaking this on to multiple lines? Not sure how to get that to pass.

@muglug muglug merged commit e59670e into vimeo:master Feb 24, 2021
@muglug
Copy link
Copy Markdown
Collaborator

muglug commented Feb 24, 2021

Thanks! Psalm does indeed support docblocks on multiple lines, thankfully.

@joehoyle joehoyle deleted the lsp-documentation branch February 25, 2021 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants