Skip to content

Reading a schematic

Try it on a pull request

A schematic draws one function. Read it from the top. When the function splits, read across.

The line at the top names that function and lists its parameters. In the picture below, saveDraft(note) is the function being drawn.

Plain statements stack, in the order they run. A run of them shares one block.

A guard is a check that leaves at once. It takes a single row: the condition, an arrow, and the exit. A ladder of guards stays flat.

The two paths sit side by side, so you can compare them in one glance.

Each case is its own row. The label is on the left and the work is on the right.

A violet bar marks a loop. When the loop walks a collection, everything to its right runs once per item. A while or an unbounded for is the same bar; the header says which.

try is a gray bar. catch is a red bar beneath it, with its own block for the failure.

A callback is a dashed frame, and it has its own scope. A return inside the frame leaves the callback, and its arrow stops at the frame. The outer return is the one that reaches the exit rail.

A row carries a tag only when its text matches a SQL statement or an HTTP call the front end recognizes. A read is teal, a write is amber, and a request is blue. The tag names the table or the request. A call that is not recognized has no tag, which means the front end did not see one, not that the function does no IO.

Every return and throw that leaves the function runs out to one rail on the right. When the function can also fall off the end, that path is marked end.

Fill warms as blocks nest. Calm code stays narrow and cool. Deeply nested code draws wide and warm.

The first chip in the header is the measured cognitive complexity. Green runs up to 5, amber up to 15, and red above that. charge scores 6, so its chip is amber. The color makes a high number easy to see. It is not a claim that the function is wrong.

An added row carries a + and a removed row carries a −. Green is added and red is removed, and the mark stays with the row.

The front page and the app draw a function at five levels, listed here from least to most detail. Headers shows only the header; each step after it adds one kind of information, down to the code itself. The + button (or the + key) zooms in toward the code, and − zooms out toward the headers. Changing level keeps the line you were reading in the same place on the screen, until you scroll. The app opens a pull request at Schematic and a repository, folder or file at Headers.

LevelWhat it showsThe question it answers
HeadersOnly each function’s header: name, parameters, complexity. Click one to open it.What is in this file, and what does each function promise?
OutlineDecisions and exits in words. Runs of statements are plain bars.What does it decide, and where can it leave?
SchematicEvery step in plain words, without comments and logs.What does it do, step by step, in plain words?
DenoisedThe function’s code, with comments, docstrings and logs faded.The code without comments, docstrings and logs
FullThe function’s code, as written.The code exactly as written

Outline keeps the blocks and folds a run of statements into one bar. Schematic writes every step out in words.

Outline
Schematic

Try it on a pull request