Skip to content

Commit 786ade7

Browse files
authored
Merge pull request #552 from apple/chuck/style-guide-updates
Style guide updates for swift-testing
2 parents 2f253b0 + a95501e commit 786ade7

File tree

1 file changed

+70
-35
lines changed

1 file changed

+70
-35
lines changed

Documentation/StyleGuide.md

Lines changed: 70 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!--
44
This source file is part of the Swift.org open source project
55
6-
Copyright (c) 2023 Apple Inc. and the Swift project authors
6+
Copyright (c) 2023-2024 Apple Inc. and the Swift project authors
77
Licensed under Apache License v2.0 with Runtime Library Exception
88
99
See https://swift.org/LICENSE.txt for license information
@@ -25,13 +25,13 @@ it have a consistent experience.
2525
#### Indentation and spacing
2626

2727
When writing code for the testing library, use two spaces for indentation. Wrap
28-
comments (especially long block comments) at 80 columns. Code does not need to
29-
be wrapped at 80 columns, however it is recommended that long argument lists be
30-
broken up across multiple lines if doing so improves readability.
28+
comments (especially long block comments) at 80 columns. Code doesn't need to
29+
be wrapped at 80 columns, however, it's recommended that you break up long
30+
argument lists up across multiple lines if doing so improves readability.
3131

3232
#### Symbol names and API design
3333

34-
New API should follow the rules documented in Swift's
34+
New API should follow the rules documented in the Swift
3535
[API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/).
3636

3737
Swift symbols that, for technical reasons, must be `public` but which are not
@@ -71,24 +71,59 @@ typedef struct SWTContainer {
7171
#### Documenting symbols
7272

7373
Most symbols, including symbols marked `private`, should be given markup-style
74-
documentation. Symbols that fulfill protocol requirements do not need to be
74+
documentation. Symbols that fulfill protocol requirements don't need to be
7575
given additional documentation (the documentation in the protocol declaration is
76-
generally sufficient.)
77-
78-
When writing an abstract for a symbol, start the abstract with either a noun or
79-
a verb ending in "s" depending on what kind of symbol it is:
80-
81-
| Noun | Verb ending in _s_ |
82-
|----------------------|---------------------------|
83-
| Associated type | Enumerations |
84-
| Class | Function and function macro |
85-
| Constant | Initializer |
86-
| Enumerated types | Macro |
87-
| Property | Method |
88-
| Protocol | Subscript |
89-
| Structure | |
90-
| Type alias | |
91-
| Variable | |
76+
generally sufficient).
77+
78+
When writing an symbol abstracts, follow these general guidelines:
79+
80+
**Limit abstracts to a single sentence that's 150 characters or fewer.**
81+
Abstracts consist of a single sentence or sentence fragment. Move any additional
82+
information or explanation to other sections, such as the Overview (for
83+
articles, classes, protocols, structures) or the Discussion (for methods,
84+
properties, constants).
85+
86+
**Don't repeat the technical terms in an entity's name.** Abstracts are concise
87+
but descriptive, and provide more information than a simple repetition of the
88+
symbol name.
89+
90+
**Don't include links to other symbols in the abstract.** Avoid making the
91+
reader leave the abstract to investigate terms. Provide links to other symbols
92+
in the Overview, Discussion, See Also, or other sections.
93+
94+
**Don't include symbol names or technical terms in code font.** Use “plain
95+
English” rather than the literal names to describe symbols. Specify the related
96+
symbols in the Overview, Discussion, or other sections.
97+
98+
**Avoid parentheses or slashes in abstracts.** Don't add alternative versions of
99+
terms or parenthetical asides in an abstract. If a task or topic requires
100+
explanation, include the information in the Overview or Discussion. Acronyms are
101+
an exception; spell out the full name on first use and include the acronym in
102+
parentheses, such as: *Your computer can transfer information to devices that
103+
use Bluetooth Low Energy (BLE) wireless technology.*
104+
105+
**Avoid language like *the following* or *below* or *these
106+
examples* in your abstract.** Abstracts can appear without context in a search
107+
result, so locational modifiers can be confusing.
108+
109+
**Use the correct grammatical style for the symbol.** Abstracts start
110+
with a noun phrase or a verb phrase --- either a verb ending in *s* or an
111+
imperative statement that conveys the symbol's action. Refer to the following
112+
table when constructing your abstract:
113+
114+
| Noun | Imperative verb | Verb ending in *s* |
115+
|----------------------|-----------------------|---------------------------|
116+
| Associated type | API collection pages | Enumerations |
117+
| Class | Articles | Function and function macro |
118+
| Constant | Sample code projects | Initializer |
119+
| Entitlement | | Macro |
120+
| Enumerated types | | Method |
121+
| Information property list key | | Notification |
122+
| Property | | Subscript |
123+
| Protocol | | |
124+
| Structure | | |
125+
| Type alias | | |
126+
| Variable | | |
92127

93128
For instance, when writing the abstract for a class `Order`, you could write:
94129

@@ -143,7 +178,7 @@ Documentation should be written in a professional voice. The author and the
143178
reader are not expected to know each other personally, so avoid overly familiar
144179
terms or colloquialisms such as _we_, _our_, or _let's_.
145180

146-
When writing specific instructions that a reader must follow exactly in order to
181+
When writing specific instructions that a reader must follow exactly to
147182
accomplish a task, use the second person (_you_, _your_, and so on).
148183

149184
#### Articles
@@ -160,23 +195,23 @@ these guidelines when creating an article:
160195
- Start section headings with an imperative verb.
161196
- Always follow a section heading with some text to setup the code or problem
162197
you want to solve.
163-
- Ensure that your filename adheres to the guidance in the [Filenames](#filenames)
164-
section, below.
198+
- Ensure that your filename adheres to the guidance in the
199+
[Filenames](#filenames) section, below.
165200

166201
#### API collections
167202

168203
To organize related subsets of symbols, articles, and other content, use an API
169204
collection. Follow these guidelines when creating an API collection:
170205

171-
- Begin the collection title with a noun that describes what the items in the
172-
collection have in common.
173-
- After the title, include a single sentence that describes the items in the
174-
collection.
206+
- Begin the collection title with a noun that describes what the items in the
207+
collection have in common.
208+
- After the title, include a single sentence abstract that describes the items
209+
in the collection.
175210
- Optionally, include an overview to the collection.
176211
- Organize the symbols under topic group headings. Begin a topic group heading
177-
with a gerund.
178-
- Ensure that your filename adheres to the guidance in the [Filenames](#filenames)
179-
section, below.
212+
with a gerund.
213+
- Ensure that your filename adheres to the guidance in the
214+
[Filenames](#filenames) section, below.
180215

181216
#### Filenames
182217

@@ -193,7 +228,7 @@ page is _Event tags_, the filename would be `event-tags.md`.
193228
The DocC compiler lowercases URL paths, so filenames converted from
194229
[UpperCamelCase](https://en.wikipedia.org/wiki/Camel_case) may be difficult to
195230
read. UpperCamelCase should still be used for Markdown files in the repository
196-
such as this one that are not part of a DocC bundle.
231+
such as this one that aren't part of a DocC bundle.
197232

198233
For more information, see [Adding Supplemental Content to a Documentation Catalog](https://www.swift.org/documentation/docc/adding-supplemental-content-to-a-documentation-catalog).
199234

@@ -202,6 +237,6 @@ For more information, see [Adding Supplemental Content to a Documentation Catalo
202237
Documentation is encoded as UTF-8 using Markdown where possible.
203238

204239
Documentation should be wrapped at 80 columns, including code samples in
205-
documentation where possible, so the reader does not need to scroll
206-
horizontally. If documentation includes a long link, it does not need to be
240+
documentation where possible, so the reader doesn't need to scroll
241+
horizontally. If documentation includes a long link, it doesn't need to be
207242
split up over multiple lines, and a URL shortener should _not_ be used.

0 commit comments

Comments
 (0)