Camera pans from stage left.It shows a text editor, open to a blank page.A person hunched in front, head to desk.
The scene above is well known to everyone who writes for a living; the mixed emotions of a blank page. Full of excitement, fresh with a new beginning. Yet also full of despair, where do you even start?
I am here to stop this scene from playing out.
This is a guide to documenting your first project. The first time is always the hardest, and I hope this guide will get you started down the righteous path. At the end, you should have a project that is ready for public release.
Feel free to read this document straight through, or simply use it as a reference.
I find it best to start off with a selfish appeal. The best reason to write docs is because you will be using your code in 6 months. Code that you wrote 6 months ago is often indistinguishable from code that someone else has written. You will look upon a file with a fond sense of remembrance. Then a sneaking feeling of foreboding, knowing that someone less experienced, less wise, had written it.
As you go through this selfless act of untangling things that were obvious or clever months ago, you will start to empathize with your users. If only I had written down why I had done this. Life would be so much simpler. Documentation allows you to transfer the why behind code. Much in the same way code comments explain the why, and not the how, documentation serves the same purpose.
You have written a piece of code, and released it into the world. You have done this because you think that others might find it useful. However, people need to understand why your code might be useful for them, before they decide to use it. Documentation tells people that this project is for them.
If people don’t know why your project exists,they won’t use it.If people can’t figure out how to install your code,they won’t use it.If people can’t figure out how to use your code,they won’t use it.
There are a small number of people who will source dive and use any code out there. That is a vanishingly small number of people, compared to people who will use your code when properly documented. If you really love your project, document it, and let other people use it.
Open source is this magical thing right? You release code, and the code gnomes come and make it better for you.
There are lots of ways that open source is amazing, but it doesn’t exist outside the laws of physics. You have to put work in, to get work out.
You only get contributions after you have put in a lot of work.You only get contributions after you have users.You only get contributions after you have documentation.
Documentation also provides a platform for your first contributions. A lot of people have never contributed before, and documentation changes are a lot less scary than code changes. If you don’t have documentation, you will miss out on a whole class of contributors.
There is an old truth that writing things down helps you think. It’s really easy to have an idea in your head that sounds perfect, but the act of putting words to paper requires a distillation of thought.
Writing documentation improves the design of your code. Talking through your API and design decisions on paper allows you to think about them in a more formalized way. A nice side effect is that it allows people to contribute code that follows your original intentions as well.
Writing documentation is a different form of writing than most people have experience with. Technical writing is an art that doesn’t come naturally. Writing documentation will start you down the road to being a better technical writer, which is a useful skill to have as a programmer.
Writing also becomes easier over time. If you don’t write for many months, it is a lot harder to start writing again. Keeping your projects documented will keep you writing at a reasonable cadence.
Starting simple is the best way to achieve actual results. I will present a well-paved path to walk down, and after you have the basic idea, you can expand your scope. The tools should be powerful and easy to use. This removes obstacles to actually putting words on the page.
As programmers we live in a world of plain text. Our documentation tooling should be no exception. We want tools that turn plain text into pretty HTML. We also have some of the best tooling available for tracking changes to files. Why would we forgo using those tools when writing documentation. This workflow is powerful, and familiar to developers.
Resources --------- * Online documentation: http://docs.writethedocs.org/ * Conference: http://conf.writethedocs.org/
This will render into a header, with a list underneath it. The URLs will be hyperlinked automatically. It’s easy to write, still makes sense as plain text, and renders nicely into HTML.
Your first steps in documentation should go into your README. Code hosting services will render your README into HTML automatically if you provide the proper extension. It is also the first interaction that most users will have with your project. So having a solid README will serve your project well.
Some people even go as far as to start your project with a README
Now we’re getting down to the brass tacks. Making sure that you give your users all the information that they need, but not too much.
First, you need to ask yourself who you’re writing for. At first, you generally just need to appeal to two audiences:
Users are people who simply want to use your code, and don’t care how it works. Developers are people who want to contribute back to your code.
A lot of people will come to your docs trying to figure out what exactly your project is. Someone will mention it, or they’ll google a phrase randomly. You should explain what your project does and why it exists. Fabric does a great job of this.
Show a telling example of what your project would normally be used for. Requests does a great example of this.
A lot of people have the same problems. If things happen all the time, you should probably fix your documentation or the code, so that the problems go away. However, there are always questions that get asked about your project, things that can’t be changed, etc. Document those, and keep it up to date. FAQs are generally out of date, but when done well, they are a golden resource. Tastypie did a great job with this, with their “Cookbook” concept.
Mailing list? IRC Channel? Document how to get help and interact with the community around a project. Django does a great job with this.
People usually have standards for how they expect things to be done in their projects. You should document these so that if people write code, they can do things in the norm of the project. Open Comparison does a great job of this.
Once people figure out whether they want to use your code or not, they need to know how to actually get it and make it run. Hopefully your install instructions should be a couple lines for the basic case. A page that gives more information and caveats should be linked from here if necessary. I think at Read the Docs we do a good job with this.
BSD? MIT? GPL? This stuff might not matter to you, but the people who want to use your code will care about this a whole lot. Think about what you want to accomplish with your license, and please only pick one of the standard licenses that you see around the web.
After you follow the above guide, we know your project will be successful! For further reading, check out this post on how to maintain an open source project.
A simple template for you to start with, for your README. Name the file README.md if you want to use markdown, or README.rst if you want to use reStructuredText. More information about these can be found in the sidebar on markup.
$project ======== $project will solve your problem of where to start with documentation, by providing a basic explanation of how to do it easily. Look how easy it is to use: import project # Get your stuff done project.do_stuff() Features -------- - Be awesome - Make things faster Installation ------------ Install $project by running: install project Contribute ---------- - Issue Tracker: github.com/$project/$project/issues - Source Code: github.com/$project/$project Support ------- If you are having issues, please let us know. We have a mailing list located at: firstname.lastname@example.org License ------- The project is licensed under the BSD license.