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

Documentation comments get detached in the presence of imports #226

Open
ghostbuster91 opened this issue Jan 12, 2024 · 2 comments
Open

Comments

@ghostbuster91
Copy link

Problem description

If the first shape definition in a smithy file has a documentation comment attached, that comment gets detached from it if there are any imports above.

Actual behavior

Formatting the following example smithy definition:

$version: "2"

namespace smithy.example

use a.b#c

/// This is documentation about a shape.
string MyString

gives:

$version: "2"

namespace smithy.example

use a.b#c
/// This is documentation about a shape.

string MyString

Expected behavior

I would expect the documentation comment to be still attached to the structure that it was defined for.

$version: "2"

namespace smithy.example

use a.b#c

/// This is documentation about a shape.
string MyString

tested on 8111fdd

@daddykotex
Copy link
Contributor

Hey, thanks for the detailed issue. This should be easy to fix.

With that said, the smithy-cli officially has support for formatting and should be the good to in the future. We're aware that most people that use our formatter do it because it comes bundled in the smithy-language-server (so indirectly files are formatted within the IDE) and that's why we try to keep the lights on here.

Let me take a look at that real quick

@daddykotex
Copy link
Contributor

Before spending time on this, I decided to look at the LSP and see if we could use the official formatter (which handles this case correctly) and turns out it was a relatively easy swap, so I opened a PR there. I'll wait for feedback there before proceeding with a fix here. The reason is that even if I fix it here, we still have to bump the version in the LSP after that so your IDE gets formatting correctly.

Instead, the PR referenced above removes the middleman and just uses the official formatter, so it removes the middleman and fix the issue.

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

No branches or pull requests

2 participants