-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Format block-comments better #3132
Conversation
I'm not sure how to write this as an automated test (I need to verify the output generated by the compiler as a string...), but I have tested this manually: ###
# Block comment hngggg
###
blah = ->
###
# Indented block comment
###
undefined
###
# Mixed
with and without starting hash
###
barfunkle = ->
###
And again
# Indented this time...
###
undefined Outputs: // Generated by CoffeeScript 1.6.3
/*
* Block comment hngggg
*/
(function() {
var barfunkle, blah;
blah = function() {
/*
* Indented block comment
*/
return void 0;
};
/*
* Mixed
with and without starting hash
*/
barfunkle = function() {
/*
And again
* Indented this time...
*/
return void 0;
};
}).call(this); I think this is pretty sweet, I'm just a bit worried about it potentially breaking some preprocessors or something. I don't really expect it to, but it wouldn't be unreasonable really. Anyways, if this seems like something people might like, let me know how I can turn this into an automated test. |
Added a couple of basic tests, similar to the ones demonstrated in this issue (#3 is a multiline string, but can be shrunk down if needed) |
The compiler is written is coffee and is in src/ |
@Nami-Doc thanks, I've added changes into src/nodes.coffee as well |
+1 |
Hmm, I wonder if anyone would be willing to give this a look, in my opinion people who use coffeescript sources but distribute compiled JS would get a lot of value out of this, at least for non-minified releases. It kind of sucks to have really ugly code generated, and this should improve that a bit -- so I'd like to see this merged. Just let me know if there's anything I can do to improve the patch, thanks |
👍 … tested, works, I like it = +1 !
Additionally I'd like to sum up the syntax-definitions which are supported, because I miss some of them in the tests: Input _(New)_:
Output (optimized by the suggestion above):
Input:
Output:
Input:
Output:
Input _(New)_, useful for
Output:
Input _(New)_, same as above, but uses the raw
Output:
Do you agree with my suggestion (implementing two or three more tests) ? Cheers, |
A patch to fix the 'unwanted extra space' (in cases where it is unwanted) is welcome, I can't look too closely at it for a while due to other projects, but I'll give it some review -- Yeah, more tests are always welcome, this is good stuff. |
… and jsdoc-like @doctags-comments.
And here you are … 😀 the patch is not necessary as the above offered pull-request proves … |
Enhancement: Add more block-comment related tests
I'm a bit wary of beefing up block comment output ... but hey, what the heck. Lovely work, @caitp. |
Format block-comments better
This is probably not a big deal, but I just don't like the way this works:
Outputs to
I feel like it would be better to format block comments more like
I don't think this would be terribly difficult to implement - so I might take a stab at it. The only reason it bothers me is because it looks so unclean and weird.
So, I dunno, is it worth taking a stab at?