4 ms·
Notice something not on the list of best practices: documentation. While Node itself has excellent docs (for the most part), the Node community is terrible abou
by Touche 12y ago
Notice something not on the list of best practices: documentation. While Node itself has excellent docs (for the most part), the Node community is terrible about documentation. If you're lucky you'll get a single README.md file with the basics covered.
Pick any category of module and there's a good chance the most popular modules have little documentation; certainly nothing close to comprehensive.
- chrisfosterelli 12y agoDo they really need more than a single README.md file? Many of those modules are so small that anything more than a single README of documentation would be excessively verbose. I've never ran into the problem of feeling a module was poorly documented. The especially complex modules usually have more extensive documentation on their website. I'd say there are cases that are terrible or useful documentation for sure, but in general most modules are very good about it from my experience.
- twerquie 12y agoI agree with this. The surface area of most modules is small enough to be covered in a README.md, which is displayed prominently on npmjs.org, github.com and a copy of it is in your ./node_modules folder. As said earlier, the core Node.js framework has great documentation, as do other frameworks such as Mongoose and Express.
- vkjv 12y agoI agree with everything you say except for Mongoose. Mongoose lacks a lot of documentation on the fringe use cases. However, the beauty of open source is that you can just read the code, which, in my experience, is the most reliable documentation.
- Monkeyget 12y agoI want to write a simple node application that fetches an http document and write it to the disk. The only requirement is for the application to print out in plain English if there is one of the following error: * the document doesn't exist * there is a connection error during download * the local file couldn't be opened * an error occured during writing. For any other error(out of memory,...) the program can crash. How do I do that in node? I don't know. The request package only tells me the callback's first parameter is "An error when applicable (usually from http.ClientRequest object)". The fs package only tells me "Event: 'error': Emitted if there was an error when writing or piping data." I only picked error reporting as an example so I could showcase the problem of lack of documentation on the most basic APIs (http get and writing file). By the way the Error Handling article [0] on Joyent's website is absolutely wonderful. Call me old fashioned but how can I use an API that doesn't tell me which function to call, what a function accepts as parameters, what it returns or how it signals error? [0] https://www.joyent.com/developers/node/design/errors https://www.joyent.com/developers/node/design/errors
- jhchen 12y agoHTTP has standard error codes that tell you why a file didn't download (ex. 404 means it doesn't exist). File systems behave similarly (ex. ENOENT). None of this is language specific and therefore do not belong in Node.js documentation (except perhaps to say that these Node.js libraries also adhere to the same standards everyone else does but this is obvious the moment one of these error objects is printed or inspected).
- nawitus 12y ago>but this is obvious the moment one of these error objects is printed or inspected The point of documentation is that you don't have to run the code to see what the code does.
- stdbrouw 12y agoUnlike e.g. in Python, in Node people aren't so eager to use (partially) autogenerated docs that document functions and classes. Sometimes this is an advantage (because handwritten docs are usually better), sometimes not (when the docs no longer match the actual API). As to whether Node.js projects in general are better documented or worse than the average project in other languages... I dunno, that seems kind of anecdotal. Basic building blocks like `async`, `underscore`, `commander` etc. all have great documentation.
- morganherlocker 12y agoYour average node module is 50-300 lines of code. A readme is just fine to document the 2 or 3 functions that are usually exposed. Beyond that, reading the source is not that onerous. Compare that to your typical doxygen-generated mega-doc, and I think it's a feature, not a bug.
- huskyr 12y agoThis. Especially the number of simple examples is lacking. Compare the documentation for node's 'request' with the Python docs for 'requests': https://github.com/mikeal/request https://github.com/mikeal/request http://docs.python-requests.org/en/latest/ http://docs.python-requests.org/en/latest/ And 'request' is one of the better documented Node modules! Most authors don't bother with any documentation at all and take an 'if you're too dumb to read the source you shouldn't be using my package' attitude. Of course there are exceptions, async is pretty nicely documented for example.
- Already__Taken 12y agoThe lack of simple examples is far more frustrating than docs personally.
- scanr 12y agoRelated question, is there anywhere in the node 'request' docs that describes the structure of the 'response' object?
- novaleaf 12y agomaking api docs is a pain in the butt. any recommendations on "api to html docs" tools?