I have a lot of projects, mostly NPM modules. If you browser through www.npmjs.com/~bahmutov you may notice how uniform all my README files are. Every module has a README file that follows pretty much the same template (thanks to Yeoman generator-node-bahmutov I use to scaffold new projects).
The main sections top to bottom are:
- head with name and description
- requirements and install instructions
- how to load the code
- quick example
- legal matters
Let me quickly describe what each section does.
Most people looking at the README are not your users. Maybe they were searching for something else and stumbled upon your repository. In either case, the first thing my README has to answer for everyone is "what is this?" The most important information everyone should see right away is module's name and description.
People who are NOT looking for a Mocha utility will leave after reading these two lines. People who are looking for a big "in your face" messages to make their Mocha output easier to understand will continue reading.
No one wants to waste time learning and using an unreliable library. Having a few badges that tell the user that the project has CI system, has recently published version and follows certain conventions is a good way to earn user's trust. I wrote about badges before so here are the only 5 badges I always use.
I start with a large NPM badge with the main information: latest published version and when it was published.
Then I have 4 inline badges that signal the quality of the module.
|I only use NPM modules with a CI system setup. I hope it stays green.|
|module uses semantic-release to publish.|
|this module has its dependencies updated automatically.|
Here is the Markdown markup for these badges. I usually keep the urls at the bottom of the readme. Only the package name and username and repository names have to be updated in the urls.
Requirements and install
This section tells what version of Node (and NPM) is required by this module. Projects that set strict engines option in their
.npmrc will not be able to install dependencies that need newer versions of Node. Also I show the install command to let people know if the module is meant as a production or development dependency. Copy and paste into the terminal and go!
Again, as a courtesy to the user, I want to quickly show how one can load the module. Is it a function or an object? Maybe the module is doing global registration?! Do not make me think, just show me so I can copy and paste into my code!
// include somewhere at the beginning
Show an example
The reader is still trying to decide if your module is what they need. Showing the most basic "hello, world" example gives this last bit of information, hopefully. Just put the most typical basic example to showcase the main benefit or use of your library.
At the bottom of the README I put links to my profile, this blog, etc. I also clearly tell what license this module has. Pretty much all my software is published under MIT license, and the users should know it. I also make sure the
package.json file has the license specified to make life easier for audit tools like license-checker.
The README should answer quickly the following questions
- what your library is doing?
- can it be used in the user's application?
- how it should be used?
- are you allowed to use it?
And that's it! Remember, you are not there to answer these questions, but your README text is.