Skip to content
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

Add missing hover docs #204

Merged
merged 5 commits into from
Feb 27, 2025

Conversation

milesziemer
Copy link
Contributor

This adds hover info for a bunch of things that I didn't get around to in the initial hover upgrade,
including:

  • All shape types
  • Non shape type keywords, metadata, namespace, use, apply, with, and for
  • Member names in service, resource, and operation shapes
  • Links to Smithy docs site for all these "builtins"
  • Documentation traits on user-defined members (before it just wasn't rendered)

I had to add new builtin model for the non-shape keywords, but reused ShapeMemberTargets for
shape type keyword hover.

I also had to add a way to check if the cursor was inside the keyword of a statement, which simplifies
IdlPosition a bit too.

The Smithy docs links use externalDocumentation, like the smithy-build.json model, and I also added
a way to include docs links to all members of a builtin shape, because there's some things which don't
have a great link for themselves specifically, but it would still be nice to allow navigating to some
docs page that could be useful. This works by adding the externalDocumentation trait to the root
shape in the builtins model, and having the hover implementation add any external docs from the
container shape when constructing hover for a builtin. So, for example, hovering over "version": "1.0"
in smithy-build.json now also includes a link to the smithy-build.json page.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

For non-shape keywords, I added a new shape to the builtins model,
NonShapeKeywords. I also had to update Statements so you can check if
the cursor is within the keyword because some statements don't need to
store the keyword Ident. Then I updated IdlPosition to perform this
check.

I also added way to include some externalDocumentation links to the
hover content of all members in a builtin shape, with the intent that
members which don't have a doc link themselves will still have some link
people can use to get to the Smithy site if they need more detail that
isn't provided in the hover content. The way this works is, if the
builtin shape you're getting the hover content for is a member, we also
append the externalDocumentation defined on its container shape. This
way we don't have to repeat the trait on every member.
Docs weren't being rendered for hover on members. Also, the builtin
shape docs for list and map members could clobber the user-defined docs,
so I removed them.
@milesziemer milesziemer requested a review from a team as a code owner February 26, 2025 15:41
@milesziemer milesziemer requested review from JordonPhillips, yefrig and joewyz and removed request for JordonPhillips February 26, 2025 15:41
@milesziemer milesziemer merged commit 790f870 into smithy-lang:main Feb 27, 2025
3 checks passed
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.

3 participants