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/docblocks #1276

Open
stephan-v opened this issue Jan 23, 2017 · 6 comments
Open

Documentation/docblocks #1276

stephan-v opened this issue Jan 23, 2017 · 6 comments

Comments

@stephan-v
Copy link

I am wondering why there is no section of documentation or docblocks. Is it conventional to leave them out? What is the reason I don't see any docblocks in the open-sourced projects you guys have?

I would love to hear thoughts about using docblocks in Javascript. I find them really helpful when I am programming PHP. Especially if your IDE has support for it and can help you out with the documentation.

@ljharb
Copy link
Collaborator

ljharb commented Jan 23, 2017

Comments in code should not describe "what" - rather, they should primarily describe history/motivation.

If by "docblocks" you mean "JavaDoc"-style documentation, including parameters and return values, then that's exactly the wrong kind of comments. If your code isn't self-documenting, then it's not clear enough.

You're right that the https://github.com/airbnb/javascript#comments section doesn't contain anything about this, but it should.

@stephan-v
Copy link
Author

If your code isn't self-documenting, then it's not clear enough.

Although I agree with this, IDE's can also help you a lot if you supply them with proper context in a JSDoc format. It is not about describing the code to you or other developers. It is about describing the code to your IDE.

@ljharb
Copy link
Collaborator

ljharb commented Jan 24, 2017

Modifying your code to help your tools in a way that doesn't help humans indicates inferior tools.

There shouldn't be a need to use an IDE as a crutch in any language, but definitely not in JS - what specific features are you referring to that the IDE can't figure out without jsdoc comments?

@sean-ww
Copy link

sean-ww commented Sep 15, 2017

With good DocBlocks in php you don't have to read the code. I think that's the point. You can understand large frameworks by skimming through the DocBlocks without reading any code. Why should we have to read your code unless we're directly editing it? Surely we just plug into it. If it's a class, method, whatever... a DocBlock helps us do that.
To me most php is way more readable than the majority of JavaScript that gets churned out.

@ljharb
Copy link
Collaborator

ljharb commented Sep 19, 2017

The goal should be to only read the code to understand it.

@ItamarShDev
Copy link

Just here to raise another point in favor of JSDocs.
When writing in a team , the JSDocs add the autocompletion and intellisense in IDE and code editors (such as VScode), which helps the developers to use the right method and be sure they pass the right arguments to it.

I agree the code should stand for itself and should not be covered and explained with comments and docs.
But I also think JSdocs can help the developer by preventing him from reading any single utils method his/her teammate wrote in the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants