Before the whole internet on your phone thing, I often found myself reading anything when I am on the throne. Often times things like deodorant cans and shampoo bottles. I find myself retaining useless information like what the active ingredient is in my shampoo (Zinc pyrithione). I would sooo kill it in Jeopardy. What is Zinc pyrithione, Alex?
Now you may be wondering why I started out my blog post with my bathroom habits and my aspirations to be Jeopardy star. That feeling you have wanting to read more is also the way I feel when I am reading good documentation. It’s smooth and very simple to read and allows you to get things done quickly. I remember Jacob Kaplan-Moss who is responsible for the django documentation (at least in part), saying that the intended audience should experience success in the first 30 minutes. Whether that be them using your tool, or they get something done that they couldn’t before. This is critical in two major ways:
- It will keep then reading through the boring parts in hopes for other signs of win!
- Praise your magic god like work.
Again for those information whores out, there here is the TL;DR version.
- Installation instructions that work.
- Cater to the masses.
- Tutorials, Tutorials, Tutorials.
- Ramp up to the hard stuff.
- Keep it up to date.
I have chosen docufail as my go to project. I will tell you a few things about docufail before I continue. It a very well written project programmatically, solves a clear problem, and even integrates well into many platforms. However, It is plagued with outdated and poor documentation.
Installation Works
How many times have you seen documentation online especially (open source projects) is they claim to solve all your problems. Back pain? Yep. Trouble sleeping? Yep. Ugly? Of course, docufail can do that and more. It works on all platforms. So you go off reading and understanding how it works; then try to install and it doesn’t work. Then you spend the next three hours trying to troubleshoot an installation issue. Be very explicit on what platforms it works on, and what other requirements are needed. Make it easy for people to get started. Documenting your installation should be written for the dumbest person in your target audience, yes I mean the guy who misses his mouth when he eats.
Often times people who write the documentation are the ones developing it. They have a lot of context that others may not have.
Protip: Do exactly what your documentations says once your done writing it. If it works success; if it doesn’t, rewrite.
Cater to the masses
As you can see, docufail aims to solve a concise problem. There are people who will use it to solve that particular problem, but there are also people who have a slightly different use case with which docufail can help. At the beginning of your documentation, you don’t really care about the second group of people; you want to get as many people as possible to use docufail for its intended purpose. I have seen documentation start off with fringe benefits (internal APIs or extension points) before they even mention what problem it was built to solve.
Tutorials, Tutorials, Tutorials
If your documentation doesn’t have a single tutorial, Go Kill Yourself™. The whole point of documentation is to get your user familiar with your project, and how it can integrate with other things. Often when I find popular projects with poor documentation, I constantly finding myself Googling the following:
docufail tutorial
When people figure something out after spending a couple of hours, they usually write it down so they don’t forget. The smarter and kinder among them put it online so others can find it. The documentation should contain this information not random blogs. Tutorial should be general in focus, allowing you to accomplish a simple task with a direct end result presented before the tutorial.
Protip: Write tutorials on stuff that is basic and won’t change too often significantly. If this can’t be done, it should be in the reference guide and not a tutorial.
Ramp up to the hard stuff
As I was saying before, you need to help your audience get work done, but you don’t want it to be too simple. Some people aren’t meant to be doing this stuff like a butcher, a baker, and candlestick maker to name a few. Make it easy, but not so easy that everyone can do it. This also provides a clear stopping point for those who don’t have the technical chops to continue. This should be stated at the beginning of any document. O’Rielly Media has two sections in every single one of thier books.
- What is this book?
- Who is it for?
These are literally the two places where I look before I buy any book I am going to learning from, at least early on. Now I just suffer through the learning curve.
Protip: Give your user insight on what the project is trying to achieve it will give them the correct context to understand why certain decision were made.
Keep it up to date
If this were a guide on how to kill a project quickly, This would be the number one thing I would recommend: outdated and old documentation. Documentation should be gating any release of any tool, product or open source project. Nobody likes writing documentation, but that shouldn’t be reflected in the work. I can name numerous projects I have seen saying “documentation will get there” and they iterate 3 or 4 version ahead, you are just creating work yourself.
Protip: Soon as you’re done a feature document it. Pass it around to people you work with who don’t know what you have been up to get feedback.
Examples of great documentation
Get to documenting. Have fun with it.
Remember good code without good documentation isn’t good code.
Discussion
Up until recently I have been maintaining Python dependencies manually in my development environment. I would do things like editing the python path and symlinking in python packages, which made me feel very clever until, it quickly turned into the 7th level hell. I would quickly forget where I put things and waste a bunch of time trying to figure out why things were breaking all the time. Don’t even mention trying to figure out what I needed to export when trying to deploy or reproduce the environment for a collaborator.
Requirements
I will be basing this tutorial on the setup I have at home. So for the best results using this guide I would recommend using Ubuntu 10.10. I will try and keep the instruction as generic as possible. Overall goal will be to introduce you to the magic of pip and virtualenv.
Install easy_install
Now it may seem unintuitive to install a tool with the very tool its trying to out date, but it easiest way I have found to do it.
You will need to install easy_install
Once that is installed you are ready to get pip
Since were installing things you might as well install virtualenv.
Creating a virtual environment
The problem that virtualenv is trying to solve is that when you install multiple python package often with various installation methods. It will become increasingly more difficult to keep your core system in order. The idea with virtualenv is to create disposable and quickly reproducible environments to run your python projects.
For ease on my system I have mapped /srv/virtual/ the space where I keep all my virtualenv. So lets say I have Django project I am working on I would name the virtualenv something along the lines of django-<projectname>.
The —no-site-packages option tells virtualenv not to inherit any libraries from your existing Python installation’s site-packages. To activate the newly created virtualenv, you will need to do the following.
Once you have activated the virtualenv you are running within a system that has all the packages you have installed to that particular virtualenv. You can freely browse your file system and run tools as normal; but with the added value that you have the newly installed packages in separated and clean environment maintained by you.
So know we have just created a pristine environment to begin customizing for our projects needs. Enter pip. Pip is designed to make sense of all the various ways you can install python packages on your system. Its trying to solve the problem of how to consistently add and remove desired python packages without any adverse affect on system. I cant tell you how many times I have forgotten the install method for some package and I have to go rummaging through my python path to attempt to remove all the installed eggs. Ugh not fun.
We can use pip to directly install into the virtualenv just by specifying it. In order to do the following your working directory will be the directory that you just created your virtualenv within. In this case it will be the parent directory of the django-mimo virtualenv
Now this package wont be accessible outside of the virtualenv, which is exactly the desired outcome.
Now lets say you have a friend and he wants a copy of your pristine django virtualenv with all the correct package for a project you guys are working on. Do the following.
Thats gives him everything you have installed and he can then turn around and create his own virtualenv with the same exact setup. Everything just works.
Discussion