-
Notifications
You must be signed in to change notification settings - Fork 28
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
Examples indented by 2 spaces #46
Comments
That is standard of Google style guide adding indented by 4 spaces, we changed that to 2 spaces. The reason of adding indented is for readability. |
Which one? The Google JS style guide doesn't mention
I would argue that the spaces wouldn't be necessary if the As an example, let's look at lodash's doc (I just picked a file at random). They don't indent code, always have |
I don't agree but if anyone (contributors or others) agrees with you, I will accept. |
@RunDevelopment the indentation is not specific to the https://google.github.io/styleguide/javascriptguide.xml?showone=Comments#Comments (search "JSDoc Indentation") I'm not 100% sure if the line-wrapping is handled consistently across non-@example tags in this library though? I think it's a bit of an opinion, which is fine by me for an automated formatters, particularly when there is precedent. The key thing for me is that it is consistent and it doesn't suddenly change and start causing lots of phantom changes in my code-base when I upgrade. |
Then may I suggest adding an option to turn the indentation off? I know that this goes against Prettier's philosophy of being "opinionated" but it might make this plugin more fitting for others and myself. Also, the 2 spaces should probably be changed to |
This could be done. |
@RunDevelopment can you show any examples of what you're trying to write up in an |
Not really, it's just indentation after all. I wouldn't be able to find any examples of "tangible issue" in a discussion of tabs vs spaces or tabWidth 2 vs 4 vs 8 either. The reason I opened this issue is that the 2 spaces seemed arbitrary to me (as in why 2 spaces and why spaces at all). I hadn't seen JSDoc comments with this style before and big projects like lodash also don't use it. |
Cool, thanks. My question wasn't really designed to be dismissive but more thinking if there are issues with code representation in cases where maybe Based on this conversation I'd personally be in favour of fixing it to |
I had thought about it in that way but yes, there is an issue. I just tested it with JSDoc and it doesn't remove the indentation, so all examples have extra indentation. (EXCEPT for the first line. This actually a property of the comment parser JSDoc and we use. It trims the example code.) |
Yea, that's problematic, and trimming like that might be common among parsers. Does JSDoc have a spec around what tags it's treating as pre-formatted text by default v.s. not? We might just need to have similar support for those defaults. |
FTFY. I can't tell you because the docs don't say much about |
The link you posted has documentation saying that the content of
So it probably makes sense to have some exceptions to the indentation for specialized tag definitions, as opposed to unstructured that can be soft-wrapped and be hard to discern from its peers such as We can then do further improvements that way such as avoiding soft-wrapping entirely for tags like |
So, what will the final answer be? ^^ @hosseinmd said, "This could be done.", but I don't know whether he was referring to "adding an option" or "2 spaces should probably be changed to
That's already the case right now. |
In my mind I had:
|
I think both is ok. we could implement both.
I don't understand exactly |
Why? |
Because some tags are treated implicitly as preformatted text. So the indentation is not stripped, it actually becomes part of the output which is not the desired effect of stylistic indent.
Because it's consistent with how users have configured prettier to indent their code. |
IMO it is a benefit |
There is two stuff.
Done.
Not solved yet |
Right now, the code in
@example
tags is indented by 2 spaces. Why is there an indentation at all (this seems to be uncommon) and why 2 spaces specifically?The text was updated successfully, but these errors were encountered: