---
title: "Code documentation"
source: The Turing Way
source_url: https://github.com/the-turing-way/the-turing-way
licence: CC-BY-4.0
domain: data-and-analysis
subdomain: turing-way
date_added: 2026-04-25
---

(rr-documentation)=
# Code documentation

(rr-documentation-prerequisites)=
## Prerequisites

No previous knowledge is needed to start reading this chapter.
This chapter aims to provide guidance to projects with different types of code and thus different needs (from small scripts to large libraries), so at some points it may require some knowledge of writing code.

(rr-documentation-summary)=
## Summary
A famous quote be Harold Abelson says that "Programs must be written for people to read, and only incidentally for machines to execute."
This refers to the fact that code should be written in a way that it can be understood by people other than the author (and even the author in the future).
And this is not limited to the code itself being well written, but also (and perhaps more importantly) for the code to be clearly documented.

Documentation is the written text that accompanies the code and explains different aspects of it: what it does, how it works, how it is structured, and any other relevant information.
Depending on the complexity of the code, it may be suitable to have different types of documentation aimed at different audiences for example, the users of the software, or other developers.

It is important to emphasise that not all projects need extensive documentation;
sometimes a basic README and a few comments in the code are sufficient for your audience.
As the author of your code, it is up to you to decide the level of documentation that you need.

In this chapter we cover different types of documentation, from the very basics of {ref}`how to document your code itself <rr-documentation-code>` up to {ref}`how to document your software project<rr-project-documentation>`.
The {ref}`other resources<rr-documentation-resources>` section includes multiple links to external resources that can help you further.
