-
Notifications
You must be signed in to change notification settings - Fork 48
Unify commenting style in the project #609
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
Comments
Sounds good to me. I would also add one more note: start the comment with uppercase, don't end with a period (maybe with the exception of multiline comments). |
+1 for uppercase and a period only for ending multiline comments |
I'm also fine with this new comments styleguide :) |
Once this is done, these instructions should be added to the wiki https://github.com/mozfr/transvision/wiki/Code-conventions |
Comment modification for following rules elaborate in #609
Most of the comments should be fixed now. @Thegennok |
Yup, just made the change :) |
Looks great, thanks. Did some minor styling fixes to the rest of the doc, but looks good. |
PHP allows commenting code in many ways borrowed from other languages and there isn't established best practices set in the PSR recommendations yet.
There is:
The only established reference is for docblocks which imposes a specific syntax and 2 asterisks at the beginning of the comment to define that this is extractable code documentation for text editors and documentation generators:
This one is a no-brainer as most IDEs/Editor allow inserting a docblock automatically.
For long comments the formatting I prefer is this one as it is I think clearer for reading the text itself:
That is to say no mid-asterisks and an indented paragraph to make the text stand out.
For a one line comment, personally I think I almost never use bash-style comments, actually I do but only during development for broken or incomplete stuff to find it easily with grep:
For one line comments, currently most of our code base uses //:
I think this is OK especially since it seems to be the default in popular text editors I know with PHP when you comment out a line (tested in Atom and Sublime Text ).
But sometimes we mix styles ex:
Or we use slashes for a multiline comment:
So here is my proposal to make it consistent:
The reason for this last rule is that if you collapse all blocks in your code and your code is well commented you can read the logic of the file by reading the comments, otherwise they are hidden:
@flodolo @TheoChevalier since you are the two other main contributors, would you agree with these conventions? If that is the case, we could turn it into a real issue for the Locasprint, this is kind of tedious work but I think that for a new contributor, it can help learn our whole code base and file structure.
The text was updated successfully, but these errors were encountered: