# RapidSMS Developers Guide/Coding standards and documentation

Documentation is important to every piece of code but even more for RapidSMS.
Because of the openness of RapidSMS and most of the Apps for it, it development focus and the community behind, there is a great need for reuse and improvements.
Proper documentation is a requirement to have you App reused and improved by the community.

## Coding standards

The RapidSMS community follows the PEP8 coding standard. It's a convention of how to write code which will ensure readability and easiness of contribution.
The standard is well written, please go read it. Some highlights though:
* Lines should not contain more than 79 characters
* No new line at end of file
* One space before and after operators
* 2 lines separation before classes or functions
Also, along the PEP8 standard, RapidSMS expects each file to contains formatting and encoding comments after shebang. Your files should thus always start with the following:
Example of actual PEP8 compliant code:

## Comments

Regular comments are very useful in RapidSMS Apps:
* helps beginners learn from example
* allows other developers to read your code in english instead of code
* will help yourself in the future when you'll have no idea why you wrote that line.
* helps you construct a consistent program by forcing you to concisely describe what you wrote ; thus enlightening mistakes.
Above example actually have some comments:

## Docstrings

Inline documentation is python feature that allows you to write some comments inside the code of your classes, functions and modules. Python will then automatically parse those comments and formats them into a nice documentation.
Example:
We added a multi-line comment (with triple-quotes) at the beginning of our method. Python understands that every multi-line comment at the beginning of module, class, function or method is a docstring.
That docstring can be only one line long (although it still needs to use triple-quotes).
In the example above, we first added a short description (this is a convention), then some more detailed information after one line break.
To access the documentation, simply start a Python shell and call help on the target object.
This means that any developer can now access a well formatted documentation from the shell.
It is also used by external tools to generate standalone documentation in HTML or other.
Docstrings are required by the community in order for you app to be reused. Make sure you add docstrings to all your modules (files), classes, functions and methods.
Full example:

## Documentation

Even if your code is well written and correctly commented, no one wants to spend hours looking at source files just to check if the feature he's looking for exist.
That's why it is important that you create at least one file (nammed README at the root of your project by convention) describing your app.
It should contain:
* Name of App
* Your name and contact
* Description of what it does
* What dependencies it has
* How to install/use it.
Should your application be complex, please, also create a docs/ folder and add any further documentation to it.

## Important Note

It is very important that you write those comments and docstring as you write the code because if you don't, it will result in errors in this documentation and bad documentation is worse than no documentation. This is a habit you want to learn.
← Internationalization · Customizing Admin U.I →