-
Notifications
You must be signed in to change notification settings - Fork 10
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
questions about intended behaviour regarding comments and empty lines #55
Comments
We've started this https://github.com/nushell/nufmt/blob/main/docs/specification.md and there's another one but I can't seem to find it. Ugh, my memory. |
@fdncred bah, how did I not see that, haha Okay, so it doesn't look like "floating comments" (or whatever they ought to be called) are really a thing (yet?) |
I wish I could find the other .md file. IIRC, it was a bit more detailed. I'm not sure what "floating comments" are. |
I may have coined the term today, haha What I mean is comments that aren't anchored to any valid non-comment syntax/statement/expression, they're just "floating" Not usage / Maybe I'm strange and I'm the only one who comments like this: https://gitlab.com/jokeyrhyme/dotfiles/-/blob/6293bf4ea581f81f0d61ef368869b5989dd279eb/bin/xdg-terminal-exec I suppose in Whereas, my (silly?) "floating comment" is more like the "inner documentation" (without necessarily being consumer-facing documentation), e.g. "this comment is about the item that encloses this comment" |
imo, something like nufmt --stdin "# hello\n\n\n# goodbye" should give
i.e. a single empty line in between |
Whoa, there is a lot to unpack here, let me go step by step. I hope I can answer all! First and foremost, a disclaimer: yesterday I found a very interesting article talking about how formatters are made and the corresponding hackernews thread is full of useful comments too. This gave me a lot to think and I realized I need to restructure a lot of the code that I commited yesterday 🏖️ Second, let me explain what is the current way of # initial comment that is not read by the parser, will be just here forever
let my_var = 1;
# this should work 👇
def "my special funcion" [] {}
# final comment that also should not dissapear the lines between Now comes the caveat: this samples given by jokey have a special characteristic: # hello
# goodbye It doesn't have any parser-relevant logic. What do we do with that files? Parser responds: "there is absolutely nothing in this file". That why I simply return the same file. It is a really edge scenario that you write a So, going back to the questions:
Half of the answer is explained above, and the other half: my personal preference is no, I don't like floating comments (floating comments it's now a thing! 👏🏼) But we can write it down as an objective and set sails to satisfy that on the future To be honest, we don't have yet a very thoroughly detailed specification other than fdncred linked before. As always, you can tag me for any question! I really like this project ❤️ |
I often have links to specifications in my code, which aren't desirable to show up in usage information (which is what nushell does with anchored comments), but they are useful when the developer is reading the code But, it's hardly a deal breaker to just expose specifications and other related URLs to users |
Thanks so much for sharing this project! <3
I am testing this commit: 4d57849
Test cases:
nufmt --stdin "# hello\n\n\nlet foo = 'abc'\n\n\n# goodbye"
nufmt --stdin "# hello\n\n\n# goodbye"
I understand the experimental/early nature of this project, and I'm a huge fan of
nu
, so I'm curious about what idiomatic code looks like regarding comments and empty lines:nufmt
preserve all empty lines, or is it idiomatic to have gaps no larger than a single empty line?Cheers! <3
The text was updated successfully, but these errors were encountered: