Skip to content

Lesson 15 of 18Working like an engineer

Reading Documentation and Versions

Pick the right kind of docs, read a reference entry and its signature, understand semantic versions and ranges, and match docs to the version you run.

18 min read0/3 questions

A teammate asks you to add a date filter to an API. You search, find a tutorial, copy the code, and it fails with an error about a function that does not exist. The tutorial was written for version 3 of the library. You have version 5. This happens to every engineer, every week, and the fix is the same each time: go to the official docs, for the version you actually have, and read the right page properly. That skill sounds dull and pays off more than almost any other. In "Reading Errors and Debugging Anything" you learned to read what the computer tells you. This lesson is about reading what the authors of your tools tell you.

Four kinds of documentation

Good documentation sets are split by what the reader needs. A popular way to describe this is the Diátaxis framework, which names four kinds. Python's docs, Django's docs and many others are organised roughly along these lines.

KindAnswersRead it whenPython example
Tutorial"Teach me from zero"You are new to the toolThe Python Tutorial
How-to guide"How do I do this one task?"You know the basics and have a goal"Logging HOWTO", "Sorting Techniques"
Reference"What exactly does this accept and return?"You are writing or debugging a callThe Library Reference for datetime
Explanation"Why does it work like this?"You want the mental modelDesign FAQ, "What's New" pages

Most frustration with docs comes from reading the wrong kind. Reading a tutorial to find one parameter wastes ten minutes. Reading the reference to learn a tool from scratch is like learning a language from its dictionary. At work you will live in the reference and the how-to guides, with occasional trips to the explanations when something surprises you.

Match the pairs0/4 matched

Match each need to the kind of documentation that serves it.

Choose an item, then its match on the other side.

Reading a reference entry

Reference pages look dense because they pack a lot into a small space. Here is how the Python docs describe sorted:

sorted(iterable, /, *, key=None, reverse=False)
 
    Return a new sorted list from the items in iterable.
    Has two optional arguments which must be specified as keyword arguments.
    ...

Every part of that first line is information:

  • iterable has no default, so it is required.
  • / means everything before it is positional-only. You cannot write sorted(iterable=nums).
  • * means everything after it is keyword-only. You must write reverse=True, not just True.
  • key=None and reverse=False are optional, and the value after = is what you get if you leave them out.

The body then tells you the return value ("a new sorted list", so the original is not changed), and any errors it raises. You do not have to go to the website for the signature. Python can tell you directly, and the error you get when you break the rules is worth seeing once:

Python
import inspect print(inspect.signature(sorted))print(inspect.signature(str.split))print(inspect.signature(round)) nums = [3, 1, 2]print(sorted(nums, reverse=True))print(sorted(nums, True))
Output
Press Run (⌘ Enter) to see what happens.

The last line fails with sorted expected 1 argument, got 2, because reverse is keyword-only. Once you can read / and * in a signature, a whole class of TypeError stops being mysterious. In your editor, hovering over a function or pressing "Go to Definition" shows the same signature, plus its docstring.

JavaScript references on MDN (developer.mozilla.org) follow the same pattern with different headings: Syntax, Parameters, Return value, Exceptions, Examples, then Specifications and Browser compatibility. Square brackets in an MDN syntax block, such as toFixed(digits) with "digits Optional", mean the argument can be left out.

Quick check
A reference page shows def connect(host, port=5432, *, timeout=10.0). Which call is valid?
Need a nudge? A hint rules out a wrong answer.

The small print: added, changed, deprecated

Reference entries carry version notes, usually in a coloured box at the end of the entry. They are the most skipped and most useful lines on the page.

  • Added in version 3.12 (older pages say "New in version"): the feature does not exist before 3.12. If your project supports 3.11, you cannot use it.
  • Changed in version 3.13: the behaviour is different from earlier versions. Code that worked before may now act differently.
  • Deprecated since version 3.12: it still works, but it is on the way out, and a replacement is usually named right there.
  • Removed in version X: gone. Old tutorials using it will fail.

A real example: datetime.utcnow() has been deprecated since Python 3.12. It still runs, but it returns a datetime with no timezone attached, which causes subtle bugs. Run this and read the warning, which names the replacement:

Python
import warningsfrom datetime import datetime, UTC warnings.simplefilter("default") now = datetime.now(UTC)print("recommended:", now.tzinfo) old = datetime.utcnow()print("deprecated:", old.tzinfo)
Output
Press Run (⌘ Enter) to see what happens.

A DeprecationWarning is the docs talking to you through your terminal. Do not silence these. Read them when you upgrade, and fix them while the fix is still optional. Teams that ignore them get a pile of breakage on the day the old API is finally removed.

MDN's equivalent is the Browser compatibility table at the bottom of each page, and the Baseline badge at the top. "Baseline Widely available" means the feature has worked in all major browsers for a long time. "Newly available" means it only recently landed everywhere, so some of your users on older browsers may not have it. When in doubt, check for the feature in code:

JavaScript
const features = { "Array.prototype.toSorted": typeof Array.prototype.toSorted, "Object.groupBy": typeof Object.groupBy, "Promise.try": typeof Promise.try,}; for (const [name, kind] of Object.entries(features)) { console.log(name.padEnd(26), kind === "function" ? "available" : "missing");}
Output
Press Run (⌘ Enter) to see what happens.

The result depends on the browser you are using right now, which is exactly the point: the docs tell you what the standard says, and your users' browsers decide what actually runs.

Semantic versioning

Almost every package uses semantic versioning (semver): three numbers, MAJOR.MINOR.PATCH.

  • PATCH (1.4.2 to 1.4.3): bug fixes only. Should be safe.
  • MINOR (1.4.3 to 1.5.0): new features, nothing removed. Old code should still work.
  • MAJOR (1.5.0 to 2.0.0): breaking changes. Read the migration guide before upgrading.

"Should" is doing work in those sentences. Semver is a promise made by humans, and humans break it by accident. A patch release can still break you if you relied on the bug it fixed. That is why lockfiles exist.

One special case: versions below 1.0.0 make no stability promise at all. In 0.x releases, each minor bump (0.4 to 0.5) is allowed to break things. Many popular tools stay at 0.x for years, so treat their minor releases like majors.

In your dependency file you usually write a range rather than one exact version. The common forms:

You writeEcosystemMeans
^1.2.3npm (the default npm install writes)at least 1.2.3, below 2.0.0
~1.2.3npmat least 1.2.3, below 1.3.0
>=1.2,<2Pythonat least 1.2, below 2
~=1.2Pythonat least 1.2, below 2 (same as above)
~=1.2.3Pythonat least 1.2.3, below 1.3
==1.2.3Pythonexactly 1.2.3

The caret has a twist for 0.x versions, matching the "no promise below 1.0" rule. Run this small re-implementation of npm's rules:

JavaScript
// A tiny version of the rules npm uses for ^ and ~ ranges.function parse(v) { return v.split(".").map(Number);} function compare(a, b) { for (let i = 0; i < 3; i++) { if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1; } return 0;} function upperBound(range) { const op = range[0]; const [major, minor, patch] = parse(range.slice(1)); if (op === "~") return [major, minor + 1, 0]; if (major > 0) return [major + 1, 0, 0]; if (minor > 0) return [0, minor + 1, 0]; return [0, 0, patch + 1];} function satisfies(version, range) { const v = parse(version); const low = parse(range.slice(1)); return compare(v, low) >= 0 && compare(v, upperBound(range)) < 0;} const published = ["1.2.3", "1.2.9", "1.3.0", "1.9.4", "2.0.0"];for (const range of ["^1.2.3", "~1.2.3"]) { const ok = published.filter((v) => satisfies(v, range)); console.log(range.padEnd(7), "allows", ok.join(", "));} const early = ["0.2.3", "0.2.8", "0.3.0", "1.0.0"];console.log("^0.2.3 allows", early.filter((v) => satisfies(v, "^0.2.3")).join(", "));
Output
Press Run (⌘ Enter) to see what happens.

^0.2.3 stops before 0.3.0, because in 0.x the minor number acts like a major. The real npm rules also handle pre-releases like 2.0.0-beta.1, which this sketch ignores.

Predict the outputJavaScript

What does this print?

const versions = ["4.17.20", "4.18.0", "4.21.2", "5.0.0"];
// Which of these does the range ^4.17.20 allow?
const allowed = versions.filter((v) => v.startsWith("4."));
console.log(allowed.length);
Need a nudge? Hints walk you through it.

The range says what you are willing to accept. The lockfile (package-lock.json, uv.lock) records what you actually installed, down to the patch, for every package and every package those depend on. Ranges let you upgrade on purpose. Lockfiles make sure your laptop, your teammate and the server all run the same code until you do.

Upgrading on purpose: changelogs and release notes

Before you upgrade anything with a major or minor bump, read what changed. Projects publish this as a CHANGELOG.md in the repo, as GitHub Releases, or as a "What's New" or "Migration guide" page in the docs. Read them in this order:

  1. Search the page for "breaking", "removed" and "deprecated".
  2. Check whether anything you use is mentioned. Search your code for those names.
  3. Look for a migration guide for major versions. Big projects usually write one, sometimes with an automatic migration tool.
  4. Upgrade one major version at a time, run the tests, then go on.

Runtimes have their own schedule. Python releases a new version every October. Each gets about two years of bug fixes, then security fixes only, and reaches end of life about five years after release. After end of life it gets no fixes at all, even for security holes. Node.js releases a new major every six months, and the even-numbered ones become LTS (long-term support) releases, which is what you use in production. Both projects publish a status table: python.org's downloads page and nodejs.org's release schedule. Check them rather than trusting a blog post.

The life of a Python version (3.15 as the example)
  1. Oct 2026

    3.15.0 released

    New features land. Libraries race to support it over the next months, so brand-new versions can be bumpy for big projects.

  2. 2026 to 2028

    Bugfix releases

    Regular 3.15.x releases fix bugs. This is the comfortable window to adopt it.

  3. 2028 to 2031

    Security fixes only

    Only security patches, released as source. Plan your upgrade during this window.

  4. Oct 2031

    End of life

    No more fixes of any kind. Running it in production is a known risk that security scanners and auditors will flag.

Matching docs to the version you run

The most common docs mistake is reading the page for the wrong version. First find out what you have:

python3 --versionnode --versionnpm ls reactuv pip show httpx

npm ls react shows the installed version of one package, and uv pip show httpx (or pip show httpx) does the same in a Python environment. Your lockfile also tells you, and it is the source of truth for what the server installs.

Then pick that version in the docs. docs.python.org has a version switcher at the top of every page. Most library docs on Read the Docs or their own sites have one too, often in a corner. If the URL contains /latest/ or /dev/, you may be reading about features that are not released yet.

When the docs are thin: read the source

Sometimes the docs simply do not answer your question. Professionals do not stop there:

  • Go to Definition in your editor jumps into the library's code. For Python and JavaScript, the installed source is on your disk, in .venv or node_modules, and readable.
  • Read the tests. A library's test folder is a large collection of working examples, written by the people who know it best, and guaranteed to run against that version.
  • Search GitHub. Code search across public repos shows how other people actually call the function. Issues often explain behaviour the docs skip.
  • Read type hints and docstrings. A function annotated -> list[str] | None tells you to handle None before you hit the bug.

You do not need to understand the whole library. Find the function, read twenty lines, and see what it really does with your argument.

Spotting outdated tutorials and invented APIs

Search results and AI answers both mix current and outdated material. Learn the warning signs:

  • No date, or a date more than two or three years old, for a fast-moving tool.
  • Old syntax: Python 2 print "hi", React class components and componentDidMount for new code, var everywhere in JavaScript, pip install into the system Python with sudo.
  • Version numbers in the text that are several majors behind what you installed.
  • APIs you cannot find in the reference. If a function or option is not in the official reference for your version, assume it does not exist until proven otherwise.

That last point matters most with AI assistants. They can confidently produce function names and options that sound right and are not real, or that existed in an older version. The fix takes thirty seconds: look the name up in the reference for your version, or check it with inspect.signature and "Go to Definition". "Trust but Verify" in the AI Engineering course goes deeper on this.

Key terms
API reference
The part of the docs that lists every function, parameter, default, return value and error, precisely and briefly.
signature
The first line of a function's definition: its name, parameters, defaults and markers like / and *.
keyword-only argument
A parameter after * in a Python signature. It must be passed by name, such as reverse=True.
deprecated
Still works, but scheduled for removal. The docs or warning usually name the replacement.
semantic versioning
MAJOR.MINOR.PATCH: breaking changes, new features, and bug fixes. Versions below 1.0 make no stability promise.
version range
What your dependency file accepts, such as ^1.2.3 in npm or >=1.2,<2 in Python. The lockfile records what was actually installed.
end of life
The date after which a version gets no fixes at all, including security fixes.