First you need to know what kind of documentation you want to write.
I am a developer and I mostly write documentation for my code and the projects I'm working for. The audience for the documentation is mostly other developers and technical people who use the software.
So for every project or module I develop/work on, i try to answer those questions:
- What is this software doing?
- Why does it exists?
- What problem does it solve?
- Where does it fit in?
And next some more practical questions:
- How do I build it?
- How do I test it?
- How do I deploy it?
- What dependencies do I need, and where can I get them?
If you have build scripts, CI scripts or Docker files, link them, they are most of the time the best documentation for those processes.
This part already helps a lot, and answers a lot of questions to get other developers started.
I try to make my code as readable as possible, so it doesn't need a lot of documentation. A lot of documentation can be really bad, when you do changes. Because you also need to change a lot of documentation. ALWAYS update the documentation if you change the code. At least delete outdated documentation, if you don't have time to update it.
If I write documentation, I try to answer the questions that are not obvious, and skip the obvious ones, that can be figured out from the code
Bad: The `StockPriceLoader` loads stock prices
Good: The `StockPriceLoader` fetches data from `StockPriceProviders` (see folder ../spp/implementation) and writes them into the database table `stock_prices`
If there are some complex processes I try to make flowcharts for that (but don't overdo it!). I mostly write README.md, my choice there is mermaid or plantuml, which can be directly rendered by some Markdown renderers (Gitlab or VS Code Markdown Preview Enhanced for example).
I try to put the documentation as close as possible to the source code. Mostly directly into the same folder where the code is. So you get versioning for your documentation for free, and if you pull an old version of your code, you get the corresponding documentation.
If you're creating libraries or interfaces, completely different rules will apply. You are probably going to need a complete API documentation, examples, tutorials, ...
At some point you probably need different kind of manuals too: or the end user, for operations, for 1st level support, fact sheets for sales, ...