Skip to content

Latest commit

 

History

History
105 lines (75 loc) · 4.11 KB

Stories.md

File metadata and controls

105 lines (75 loc) · 4.11 KB

Stories

A story is the reason for a branch's work, in its author's words. It is a Markdown file named after the branch, .swiftwhy/changes/<branch>.md unless the project keeps stories elsewhere, and it is committed with the branch. swiftwhy check reads it against what the branch changed.

The format

---
pr: 42
---
# Price carts in fractions

Totals were rounded to whole cents line by line, so long carts lost money.

## Totals keep their cents

``Cart`` adds prices as they are, and rounds once, when the total is shown.

### ``Cart/total()``

Returns a `Double`, since a whole number cannot hold a fraction of a cent.

### ``Cart/coupon``

Gone. Coupons were whole cents off, which the new totals cannot honor exactly.

## Discounts replace coupons

``Discount`` takes a fraction off the total.
Part Is
front matter optional; a pr: line records the pull request the change was reviewed in
# headline what the change does, in a line
paragraphs before the first ## the summary: why the change was made
## theme one part of the change, in prose that links the types it is about
### note the reason for one change; its heading is one link and nothing else

A ### heading that is not exactly one link is read as prose. Fenced code is an example, and links inside it are not read.

Links

Links are written as documentation links are, between double backticks:

Link Names
``Cart`` the type Cart, in every module that declares one
``Cart/total()`` a member, as a caller writes it, with its argument labels: add(_:to:), init(lines:), count
``Cart/Line`` a nested type
``Shop/Cart`` the Cart of the module Shop only
``round(_:)`` a declaration at file scope, such as a free function

A link has to name something the sources declare, now or at the base, so a gone type or member can still be linked and a mistyped one is caught. A type that moved between modules is named by its bare name, or by either module.

What owes a reason

Change Owes
a member that is new, gone, or declared or documented differently a note headed by its link
a member whose body, accessors, or initial value alone changed a note headed by its link
a type that is gone or moved to another module a note headed by the type's link
a type whose own declaration or doc changed, such as a new conformance a note headed by the type's link
a new type a theme that links it, and a note for each of its members
any type whose interface changed a theme that links it, or a type it is nested in

Access makes no difference: a private helper's change owes a reason as a public method's does. One note covers every overload that shares a name and labels. A gone type's members go with it, so its own note speaks for them.

What is no change

Declarations are matched by name, never by place, and compared by what they say:

  • Code that moves within a file, or to another file in the same module, is no change.
  • A body that is only reformatted or commented is no change.
  • A doc comment that says the same on different lines is no change.
  • Overloads in a different order are no change.

A renamed declaration reads as one gone and one new, and each owes its note.

Findings

Code Means
no-story the branch changed something and has no story; swiftwhy draft --write starts one
no-theme a type's interface changed and no theme links it
no-reason a change has no note of its own
dead-link a link names nothing the sources declare, now or at the base

Writing a note

A note answers one question for a reader who is looking at one change: why was this done? The code and its doc comment already say what it does, so a good note does not repeat them.

  • Lead with the reason, in a sentence or two. Detail can follow in later paragraphs.
  • Say what the change makes possible, or what was wrong before it.
  • When a member changed only because its theme required it, say so in a line. A short honest note is better than a padded one.