Skip to content

Quick documentation look-up for packages #60123

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

Open
RepliedSage11 opened this issue Feb 9, 2025 · 9 comments
Open

Quick documentation look-up for packages #60123

RepliedSage11 opened this issue Feb 9, 2025 · 9 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-server Issues related to some aspect of the analysis server P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@RepliedSage11
Copy link

RepliedSage11 commented Feb 9, 2025

There is functionality in IntelliJ and VS Code that allows to get quick package documentation from a package.json file.

Image

I think this would be a useful addition to the Pub IDE extensions.

My main use case is package upgrades. Right now I have to run flutter pub outdated and then manually lookup every package on pub.dev to find its changelog. I would like to be able to see the outdated packages right in the pubspec.yaml file with quick access to the changelog and documentation.

This will also promote good practices of keeping your dependencies up to date if you can just take a glimpse at your pubspec instead of running a console command each time, which some folks might not do very often.

Here are the IntelliJ capabilities when working with package.json

@lrhn lrhn transferred this issue from dart-lang/pub Feb 13, 2025
@lrhn lrhn added the legacy-area-analyzer Use area-devexp instead. label Feb 13, 2025
@lrhn
Copy link
Member

lrhn commented Feb 13, 2025

This is a tooling issue, not something controlled by Pub.
It might be the analysis server. (Or it might be the IDE plugin, I don't know who provides what for pubspec.yaml files.)

@srawlins srawlins added P3 A lower priority bug or feature request devexp-server Issues related to some aspect of the analysis server type-enhancement A request for a change that isn't a bug labels Feb 18, 2025
@sigurdm
Copy link
Contributor

sigurdm commented Feb 18, 2025

cc @DanTup would this be the lsp server or the vscode plugin providing this?

@DanTup
Copy link
Collaborator

DanTup commented Feb 18, 2025

It depends on the specifics, but most likely if we did something here it would be in the analysis server (it's slightly more restricted for VS Code, but means all LSP clients get the functionality instead of only VS Code). It's not clear to me exactly what the UI is in the screenshot above, but the analysis server can provide hovers, inlay hints and CodeLens for pubspecs (although none of those are currently implemented).

There's also a similar/related issue at Dart-Code/Dart-Code#1977.

@bwilkerson
Copy link
Member

It's not clear to me exactly what the UI is in the screenshot above ...

Me either. @RepliedSage11 could you provide more information about how you'd like to be able to see this information, both in VS Code and in IntelliJ?

@RepliedSage11
Copy link
Author

RepliedSage11 commented Feb 18, 2025

The UI in the screenshot is the tooltip displayed when hovering over one of the dependencies in a package.json file. It is rendering the readme file of the package with additional info from npm like the latest available version.

I suspect for the pub extension it would be sufficient to show links to pub.dev and the latest version of the package, as well as some quick actions like upgrading an individual package or upgrading all packages.

@bwilkerson

@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
@DanTup
Copy link
Collaborator

DanTup commented Feb 24, 2025

Ah, thanks - I think I was thrown by the rounded corners.

I think there are probably two parts to this:

  1. Show documentation about a package when hovering
  2. Show notifications when pub packages can be updated

I think the first one would either need a request to the Pub API during computing of the hover, or reading directly from the readme.

The second, we might already have some of the data for - we run pub outdated to get version numbers to use in the code completion. There are multiple version numbers that might be interesting though - because there may be newer versions that you can update to without changing any other constraints, or newer versions that require changing other packages. It might be better to encourage running something like pub upgrade (or pub upgrade --major-versions) instead of updating individual packages (although currently these commands are client-side in VS Code, and not part of the server).

@bwilkerson
Copy link
Member

I think the first one would either need a request to the Pub API during computing of the hover, or reading directly from the readme.

Or, per the comment above, just include a link to the package's site on pub.dev.

If we can read the comment directly from the readme then I suspect that would be faster, and would work without a network connection.

It might be better to encourage running something like pub upgrade ...

I agree.

We could add a banner in the hover stating that there are newer version that might be compatible that includes the suggestion to run pub upgrade.

@FMorschel
Copy link
Contributor

Or, per the comment above, just include a link to the package's site on pub.dev

This is done now after Dart-Code/Dart-Code#2785 got closed. Not on hover but you can CTRL + Click on the package name.

@RepliedSage11
Copy link
Author

encourage running something like pub upgrade (or pub upgrade --major-versions) instead of updating individual packages

This makes more sense in Dart's case since AFAIK in npm you can't have incompatible dependency constrains since every package can just download a copy of a dependency with whatever version they need, so you can update individual dependencies while ignoring others.
Dependency updates in Dart make sense only when updated as a whole, so maybe we should think about something similar to the table that is printed by flutter pub outdated but inside the IDE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-server Issues related to some aspect of the analysis server P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants