█
LastWrite
  • > Curriculum
  • > Pricing
  • > For Educators
  • > About
  • > Contact
Log InGet Started

Questions, concerns, bug reports, or suggestions? We read every message, write to us at [email protected].

More ways to reach us →
LastWrite

Structured computer science lessons for aspiring developers and security professionals.

[email protected]

(201) 785-7951

Mon–Fri, 9 AM–5 PM EST

Learn

  • Curriculum
  • Pricing

Company

  • About
  • For Educators & Schools
  • Contact Us

Legal

  • Terms of Service
  • Privacy Policy
© 2026 LastWrite. All rights reserved.
Curriculum/Software Engineering/Engineering Fundamentals/Documentation: READMEs, Inline Docs, and API Docs
35 minBeginner

Documentation: READMEs, Inline Docs, and API Docs

After this lesson, you will be able to: Write a README that actually helps, document the why with inline comments, and generate reference docs from code with JSDoc/TSDoc and OpenAPI.

Documentation is an engineering deliverable, not an afterthought. The README is the first thing a teammate, a hiring manager, or future-you reads. Good docs are the difference between code that other people can use and code only you can run. This lesson covers the three layers: project docs (README), inline docs (the why), and reference docs (generated from code).

Prerequisites:Code Quality and Readability

Three layers of documentation

Project docs answer 'what is this and how do I run it' (the README, a docs/ folder). Inline docs answer 'why is this code doing something non-obvious' (comments at the point of confusion). Reference docs answer 'what does this function/endpoint take and return' (generated from JSDoc/TSDoc or an OpenAPI spec). Each layer has a different reader and a different job. The mistake is writing none of them, or writing the wrong one (a wall of WHAT comments instead of a README).

The README that earns trust

Order matters. A reader decides whether to keep going in the first ten seconds.

  1. 1

    One-line description: what this project is, in a sentence.

  2. 2

    A screenshot or demo GIF if there is any UI, or a short usage example if it is a library/CLI.

  3. 3

    Quickstart: the exact commands to install and run locally (clone, install, copy .env.example, run). Test them on a clean checkout.

  4. 4

    Configuration: what environment variables exist and what each does.

  5. 5

    Project structure: a few lines on where the important code lives (helps the reading-code skill from the last lesson).

  6. 6

    Contributing + license if it is open source.

  7. 7

    Skip vanity badges no one maintains and 'about me' essays. Brevity wins.

JSDoc / TSDoc that editors and doc generators read

Structured comments power editor tooltips AND generate an API reference site with TypeDoc.

html
/**
* Charges a customer and records the payment.
*
* @param customerId - Stripe customer ID (starts with `cus_`).
* @param amountCents - Amount to charge, in the smallest currency unit.
* @returns The created payment record.
* @throws {PaymentError} If the card is declined or the customer is missing.
*
* @example
* const payment = await charge("cus_123", 1500); // $15.00
*/
export async function charge(customerId: string, amountCents: number): Promise<Payment> {
// ...
}
// Editors show this on hover. TypeDoc turns it into a docs site.
// You write it once, in the same file as the code, so it stays in sync.

💡 API docs: OpenAPI for HTTP services

For a REST API, the reference layer is an OpenAPI (Swagger) document: a machine-readable description of every endpoint, its parameters, and its responses. Tools like Swagger UI render it as an interactive page where consumers can try requests, and clients can be code-generated from it. You can hand-write the spec or generate it from typed route definitions. The REST APIs subtrack in Programming Languages covers writing one end to end.

Inline docs: the why, never the what

This is the same rule from the code-quality lesson, applied to documentation. A comment that restates the code (`// loop over users`) is noise that goes stale. A comment that explains a decision (`// We retry only on 5xx; 4xx means the request itself is wrong`) is gold, because the reasoning is invisible from the code alone. If you are writing many WHAT comments, fix the names instead. Reserve comments for the surprising, the regulatory, and the 'do not change this without reading PR #482'.

ℹ️ Your own knowledge base: Obsidian

Documentation is not only for projects. The engineers who grow fastest keep a personal knowledge base of what they learn: commands they always forget, how a tricky system works, notes from a debugging session. Obsidian is a popular free tool for this: plain Markdown files on your own disk, with a graph view that links related notes. It is widely used by both software engineers and security professionals to build a searchable second brain over a career. Start one now and add to it every time you learn something the hard way.

Common mistakes only experienced engineers catch

A README that lists features but never says how to run the thing. Quickstart first. Docs that drift from the code because they live in a separate wiki nobody updates. Keep reference docs in the code (JSDoc) so they move with it. Documenting private internals as if they were a public API. Document the surface other people use. No .env.example, so a new contributor cannot start the project. Writing docs once and never again. Update the README in the same PR that changes behavior, the way you update tests.

Quick Check

Where should reference documentation for a function live?

Pick the option most likely to stay accurate.

Sign in and purchase access to unlock this lesson.

Sign in to purchase
←Code Review
Back to Engineering Fundamentals
Engineering Fundamentals Job Readiness→