pi-dent-terms 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -38
- package/index.ts +3 -2
- package/lib/after-edit.ts +8 -8
- package/lib/changes.ts +19 -19
- package/lib/checks.ts +22 -22
- package/lib/config.ts +10 -7
- package/lib/import.ts +8 -7
- package/lib/match.ts +10 -10
- package/lib/operations.ts +30 -30
- package/lib/prose.ts +11 -11
- package/lib/terms-file.ts +22 -20
- package/lib/text.ts +5 -5
- package/lib/tool.ts +48 -40
- package/lib/workspace.ts +10 -9
- package/package.json +3 -2
- package/specs/AGENTS.md +28 -0
- package/specs/terms-tool.md +369 -0
- package/specs/terms.md +756 -0
package/specs/terms.md
ADDED
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
# Terms specification
|
|
2
|
+
|
|
3
|
+
This document specifies the terms file of a workspace, the matching of its entries in the prose
|
|
4
|
+
of the workspace's documents, the checks that report findings, and the operations that change
|
|
5
|
+
the terms file. The `pi-dent-terms` package provides them as a library and as a pi extension; the
|
|
6
|
+
`Terms` tool and the after-edit check are owned by [terms-tool.md](terms-tool.md).
|
|
7
|
+
|
|
8
|
+
The library computes every check and every operation as a function of its inputs alone: the terms
|
|
9
|
+
file's bytes, the set of documents with their texts, for checks the separately supplied external
|
|
10
|
+
owner texts ([documents](#documents)), for a change check its change set ([change
|
|
11
|
+
checks](#change-checks)), and for an operation its parameters and the date. The same inputs MUST
|
|
12
|
+
give the same output, byte for byte. The library MUST NOT read or write files, read the clock, or
|
|
13
|
+
run processes; the extension supplies the inputs and writes the output ([terms-tool.md, workspace
|
|
14
|
+
access](terms-tool.md#workspace-access)).
|
|
15
|
+
|
|
16
|
+
## 1. Workspace {#workspace}
|
|
17
|
+
|
|
18
|
+
### 1.1 Workspace root {#workspace-root}
|
|
19
|
+
|
|
20
|
+
The workspace root of a directory is the top level of the Git working tree that contains it,
|
|
21
|
+
the directory `git rev-parse --show-toplevel` prints when run in it. A directory outside every
|
|
22
|
+
Git working tree has no workspace root. The workspace of a workspace root is the Git working
|
|
23
|
+
tree below it, with its documents and its terms file. A workspace path is a path relative to
|
|
24
|
+
the workspace root, its segments joined by `/`, with no empty, `.`, or `..` segment.
|
|
25
|
+
|
|
26
|
+
### 1.2 Documents {#documents}
|
|
27
|
+
|
|
28
|
+
The documents of a workspace are the files that `git ls-files -z --cached --others
|
|
29
|
+
--exclude-standard`, run in the workspace root, lists and that meet all of these:
|
|
30
|
+
|
|
31
|
+
- the path ends with `.md`, compared exactly;
|
|
32
|
+
- the path names a regular file, a symbolic link not being one whatever it points to;
|
|
33
|
+
- its bytes are valid UTF-8 and contain no U+0000.
|
|
34
|
+
|
|
35
|
+
A path listed more than once is one document. A document's text is its bytes decoded as UTF-8,
|
|
36
|
+
without a leading U+FEFF; a character is a Unicode scalar value. A line ending is a line feed,
|
|
37
|
+
a carriage return not followed by a line feed, or a carriage return followed by a line feed
|
|
38
|
+
([CommonMark], Section 2.1); lines are numbered from 1. The column of a character is 1 plus the
|
|
39
|
+
number of UTF-16 code units before it on its line. Paths are compared and ordered by UTF-16
|
|
40
|
+
code units.
|
|
41
|
+
|
|
42
|
+
An owner path is either a workspace path ending with `.md`, or one or more leading `../` segments
|
|
43
|
+
followed by a workspace path ending with `.md`. It is resolved against the workspace root, not the
|
|
44
|
+
session's working directory. Owner identity is its path string, without resolving physical file
|
|
45
|
+
aliases. An owner path with leading `../` is external; every other owner path is internal. An
|
|
46
|
+
external owner is not a workspace document, and its text never contributes a document use or an
|
|
47
|
+
occurrence. The library accepts external owner texts separately, keyed by owner path, decoded as
|
|
48
|
+
document texts above. An absent external owner text is unavailable, not an empty text. [file
|
|
49
|
+
checks](#file-checks) defines the check that uses these texts; the extension supplies them per
|
|
50
|
+
[terms-tool.md, workspace access](terms-tool.md#workspace-access).
|
|
51
|
+
|
|
52
|
+
## 2. Terms file {#terms-file}
|
|
53
|
+
|
|
54
|
+
### 2.1 Location and syntax {#location-and-syntax}
|
|
55
|
+
|
|
56
|
+
The terms file of a workspace is `.pi/pi-dent/terms.yaml` under its workspace root; no other path is
|
|
57
|
+
the terms file. Its text is its bytes decoded as UTF-8, without a leading U+FEFF, parsed as one YAML
|
|
58
|
+
document ([YAML 1.2.2]) with the core schema (Section 10.3 of [YAML 1.2.2]), so that a date is a
|
|
59
|
+
string. A text that is not valid UTF-8, that does not parse, that holds other than exactly one
|
|
60
|
+
document, or that has a duplicate key in a mapping gives one T001 finding ([file
|
|
61
|
+
checks](#file-checks)) and no settings and no entries.
|
|
62
|
+
|
|
63
|
+
### 2.2 Root {#root}
|
|
64
|
+
|
|
65
|
+
The root MUST be a mapping; a root that is not gives one T001 finding and no settings and no
|
|
66
|
+
entries. A `terms` value that is absent or not a sequence gives one T001 finding and no entries.
|
|
67
|
+
A `settings` value that is not a mapping, or a `settings` key whose value does not have its
|
|
68
|
+
type, gives one T001 finding and counts as absent.
|
|
69
|
+
|
|
70
|
+
| Key | Type | Contract |
|
|
71
|
+
| ---------- | ------------------ | ---------------------------------- |
|
|
72
|
+
| `settings` | mapping, optional | The file-level settings. |
|
|
73
|
+
| `terms` | sequence, required | The entries ([entries](#entries)). |
|
|
74
|
+
|
|
75
|
+
| `settings` key | Type | Contract |
|
|
76
|
+
| ---------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `checkAfterEdit` | boolean, optional | Whether the after-edit check runs in this workspace ([terms-tool.md, effective setting](terms-tool.md#effective-setting)). |
|
|
78
|
+
|
|
79
|
+
An unknown key of the root, of `settings`, of an entry, or of a history item follows the
|
|
80
|
+
unknown-key rule (pi-dent-agent `specs/config-file.md`, Section 2), the one
|
|
81
|
+
diagnostic being one T001 finding that names the object and all its unknown keys.
|
|
82
|
+
|
|
83
|
+
### 2.3 Entries {#entries}
|
|
84
|
+
|
|
85
|
+
An entry is the record of one concept. A string is one line when it holds neither a line feed nor a
|
|
86
|
+
carriage return; a non-empty line is a one-line string holding a character other than white space; a
|
|
87
|
+
phrase is a one-line string with no leading or trailing white space that holds at least one word
|
|
88
|
+
character (Section 4.1). An id is a string matching `^[a-z0-9]+(-[a-z0-9]+)*$`. Two phrases or ids
|
|
89
|
+
of one list are the same when they are equal after normalisation ([phrases](#phrases)).
|
|
90
|
+
|
|
91
|
+
| Field | Type | Contract |
|
|
92
|
+
| ------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `id` | id, required | The concept's identity. Unique in the file. |
|
|
94
|
+
| `label` | phrase, required | The one preferred term for the concept, in base form. |
|
|
95
|
+
| `meaning` | string, required | What the concept is, one non-empty line. |
|
|
96
|
+
| `owner` | string, required | The owner path ([documents](#documents)) of the file that defines the concept. |
|
|
97
|
+
| `group` | string, required | The heading the entry is listed under, one non-empty line. |
|
|
98
|
+
| `key` | enum, required | `shared`: used by two or more documents. `confusable`: by one or more. `local`: used only by its owner ([file checks](#file-checks)). |
|
|
99
|
+
| `status` | enum, required | `active` or `deprecated`. |
|
|
100
|
+
| `reject` | phrase[], optional | Phrases no document uses for the concept. No phrase twice. |
|
|
101
|
+
| `distinguish` | id[], optional | Ids of neighbouring concepts a reader confuses with this one. No id twice. |
|
|
102
|
+
| `forms` | phrase[], optional | Inflected forms of `label` that [phrases](#phrases) does not derive. No phrase twice. |
|
|
103
|
+
| `replacedBy` | id[], optional | Ids of the entries that replace a deprecated entry, its replacements. No id twice. |
|
|
104
|
+
| `reason` | enum, optional | Why the entry is deprecated: `merged`, `split`, `renamed`, or `out-of-scope`. |
|
|
105
|
+
| `history` | history item[], required | The operations that changed the entry, in the order they did ([history items](#history-items)); at least one item. |
|
|
106
|
+
|
|
107
|
+
An absent list is an empty list. The distinguish relation holds between two entries when either
|
|
108
|
+
lists the other. The `terms` sequence MUST hold its entries in strictly ascending order of `id`; an
|
|
109
|
+
entry whose `id` is not greater than the last string `id` before it gives one T001 finding. Each
|
|
110
|
+
violation of this section or of [history items](#history-items) gives one T001 finding. An entry
|
|
111
|
+
with a T001 finding whose `<value path>` ([file checks](#file-checks)) is the entry or lies under
|
|
112
|
+
it, other than one for unknown keys, is left out of every other check, of matching, and of the
|
|
113
|
+
operations' changes; its `id`, when it is a string, still counts as an existing id.
|
|
114
|
+
|
|
115
|
+
### 2.4 History items {#history-items}
|
|
116
|
+
|
|
117
|
+
A history item is a mapping with the keys `date`, a valid calendar date in the complete extended
|
|
118
|
+
form `YYYY-MM-DD` of [ISO 8601], `op`, and the operands of one operand set of its `op`, each
|
|
119
|
+
required except `replacedBy`:
|
|
120
|
+
|
|
121
|
+
| `op` | Operand sets |
|
|
122
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
123
|
+
| `add` | none |
|
|
124
|
+
| `update` | none; `meaning`: the entry's meaning before the operation, a string; `status`: the entry's status before the operation, `deprecated`; or both |
|
|
125
|
+
| `import` | `from`: the workspace path of the imported document |
|
|
126
|
+
| `rename` | `from`, `to`: the label before and after, phrases |
|
|
127
|
+
| `merge` | on the merged entry, `into`: the id it was merged into; on that entry, `from`: the merged id |
|
|
128
|
+
| `split` | on the split entry, `into`: the list of ids it was split into; on each of those, `from`: the split id |
|
|
129
|
+
| `deprecate` | on the deprecated entry, `reason` and, when it has replacements, `replacedBy`: the list of their ids; on a replacement, `from`: the deprecated id |
|
|
130
|
+
| `reown` | `from`, `to`: the owner before and after, owner paths ([documents](#documents)) |
|
|
131
|
+
|
|
132
|
+
A `merge` or `split` item takes its first set when it holds `into`, a `deprecate` item when it holds
|
|
133
|
+
`reason`, an `update` item the set of those of `meaning` and `status` it holds, and otherwise its
|
|
134
|
+
second set. An id operand
|
|
135
|
+
is a string, a list operand a sequence of strings, and `reason` takes the values of the entry field
|
|
136
|
+
`reason`. A key other than `date`, `op`, and the operands of the taken set is unknown. When `op` is
|
|
137
|
+
absent or not one of these values, no operand set is taken and the item's keys other than `date` and
|
|
138
|
+
`op` are not checked.
|
|
139
|
+
|
|
140
|
+
### 2.5 Canonical form {#canonical-form}
|
|
141
|
+
|
|
142
|
+
Every terms file an operation writes is in canonical form:
|
|
143
|
+
|
|
144
|
+
1. UTF-8 without a byte-order mark; every line ends with a line feed; no line has trailing
|
|
145
|
+
white space.
|
|
146
|
+
2. When the input had a non-empty `settings`, the line `settings:` and each of its keys as
|
|
147
|
+
`<key>: <value>` on its own line indented by 2 spaces, in the order of the table of
|
|
148
|
+
[root](#root); then `terms:`, or `terms: []` when there is no entry.
|
|
149
|
+
3. Each entry as a block sequence item, ` - id: <id>`, then its other present fields, each on its
|
|
150
|
+
own line indented by 4 spaces, in the order of the table of [entries](#entries), a list field as
|
|
151
|
+
`<field>:` alone. An empty list and an absent optional field are not written.
|
|
152
|
+
4. Each item of a list of strings as `- <item>` on its own line indented by 6 spaces.
|
|
153
|
+
5. Each history item as a block mapping: ` - date: <date>`, then `op: <op>`, then each operand as
|
|
154
|
+
`<key>: <value>` in the order of the table of [history items](#history-items), each on its own
|
|
155
|
+
line indented by 8 spaces; a list operand as `<key>:` alone, then each of its ids as `- <id>` on
|
|
156
|
+
its own line indented by 10 spaces.
|
|
157
|
+
6. A string matching `^[A-Za-z0-9]([A-Za-z0-9 ._/-]*[A-Za-z0-9._/])?$` that the core schema
|
|
158
|
+
does not resolve to a null, boolean, integer, or float is written plain; every other string
|
|
159
|
+
is written as ECMAScript `JSON.stringify` writes it ([ECMA-262]), then with each character
|
|
160
|
+
outside the printable set of [YAML 1.2.2], Section 5.1, written `\u` and four lowercase
|
|
161
|
+
hexadecimal digits. When that text holds `\"` and no other `\`, the string is instead
|
|
162
|
+
written single-quoted: `'`, the string with each `'` doubled, then `'`.
|
|
163
|
+
7. No other line is written: the input's comments, blank lines, and layout are not kept.
|
|
164
|
+
|
|
165
|
+
> Note (non-normative): with no flow collection and single quotes where they save escapes, oxfmt
|
|
166
|
+
> leaves a written terms file unchanged.
|
|
167
|
+
|
|
168
|
+
## 3. Prose {#prose}
|
|
169
|
+
|
|
170
|
+
### 3.1 Parsing {#parsing}
|
|
171
|
+
|
|
172
|
+
When line 1 of a document is exactly `---` and a later line is exactly `---`, lines 1 through
|
|
173
|
+
the first such later line are front matter: they hold no prose, and the document is parsed as if
|
|
174
|
+
they were blank, so that line numbers stay. The document is parsed per [CommonMark] with the
|
|
175
|
+
tables extension of [GFM] (Section 4.10) and no other extension; a link destination is taken
|
|
176
|
+
as CommonMark gives it, without percent-decoding.
|
|
177
|
+
|
|
178
|
+
### 3.2 Prose runs {#prose-runs}
|
|
179
|
+
|
|
180
|
+
A prose block is a heading, a paragraph, or a table cell, wherever it is nested: list items and
|
|
181
|
+
block quotes hold paragraphs. Code blocks, HTML blocks, link reference definitions, front
|
|
182
|
+
matter, and the cells of the `Term` and `Avoid or distinguish` columns of a thesaurus table
|
|
183
|
+
([`import`](#import)) hold no prose block. Each prose block gives one prose run: a sequence of
|
|
184
|
+
characters, each with the position (line and column) of its source text, and barriers. Its
|
|
185
|
+
inline content contributes, in order:
|
|
186
|
+
|
|
187
|
+
| Inline content | Contributes |
|
|
188
|
+
| -------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
189
|
+
| Text | its characters |
|
|
190
|
+
| A backslash escape | the escaped character, at the backslash's position |
|
|
191
|
+
| An entity or numeric character reference | the characters it decodes to, at the reference's position |
|
|
192
|
+
| Emphasis, strong emphasis, the link text of a link | what its content contributes; its delimiters and brackets contribute nothing |
|
|
193
|
+
| A soft or hard line break | one space |
|
|
194
|
+
| A code span, raw HTML, an autolink, an image | one barrier |
|
|
195
|
+
|
|
196
|
+
The space of a line break has no position: no occurrence starts or ends with a space, so no
|
|
197
|
+
output reports one. A link destination, a link title, and a link label contribute nothing.
|
|
198
|
+
Prose is the characters of the prose runs of the documents.
|
|
199
|
+
|
|
200
|
+
### 3.3 Suppression comments {#suppression-comments}
|
|
201
|
+
|
|
202
|
+
A suppression comment is an HTML comment whose text between `<!--` and `-->`, with leading and
|
|
203
|
+
trailing white space removed, is `terms-ignore` or starts with `terms-ignore` followed by white
|
|
204
|
+
space, and that is either raw HTML inside a prose block or the whole of an HTML block, leading
|
|
205
|
+
and trailing white space aside. Its target line is the line on which it starts when it is raw
|
|
206
|
+
HTML. Otherwise its target is the first nonblank line after the last line of its HTML block,
|
|
207
|
+
where a blank line holds only white space ([phrases](#phrases)) after removing the markers of the
|
|
208
|
+
comment's enclosing block quotes; it has no target when no such line exists. A valid comment
|
|
209
|
+
with no target suppresses nothing and gives no S001 finding.
|
|
210
|
+
|
|
211
|
+
A suppression comment is valid when that text matches the ECMAScript regular expression
|
|
212
|
+
([ECMA-262]) `^terms-ignore[ \t]+(P001|P002):[ \t]+\S` and is one line. A valid suppression
|
|
213
|
+
comment suppresses the findings of its code whose occurrence starts on its target line; one
|
|
214
|
+
comment suppresses one code on one line. An invalid one suppresses nothing and gives an S001
|
|
215
|
+
finding ([prose checks](#prose-checks)).
|
|
216
|
+
|
|
217
|
+
For example, a standalone `<!-- terms-ignore P001: quoted legacy wording -->` on line 1,
|
|
218
|
+
blank lines 2 and 3, and prose on line 4 targets line 4. If only blank lines follow the
|
|
219
|
+
comment, it has no target. Another nonblank comment or a code-block line is not skipped.
|
|
220
|
+
|
|
221
|
+
## 4. Matching {#matching}
|
|
222
|
+
|
|
223
|
+
### 4.1 Phrases {#phrases}
|
|
224
|
+
|
|
225
|
+
A word character is a character of Unicode general category L, M, or N ([Unicode], Section
|
|
226
|
+
4.5); white space is a character with the Unicode property White_Space ([Unicode], Section 4.6).
|
|
227
|
+
A string is normalised by replacing each maximal run of white space with one space and removing
|
|
228
|
+
leading and trailing white space. The last word of a phrase is its last maximal run of word
|
|
229
|
+
characters.
|
|
230
|
+
|
|
231
|
+
The plural of a phrase whose last character is a letter (category L) is the phrase with its last
|
|
232
|
+
word changed by the first rule that applies, letters compared exactly:
|
|
233
|
+
|
|
234
|
+
1. The word ends with `s`, `x`, `z`, `ch`, or `sh`: `es` is appended.
|
|
235
|
+
2. The word ends with `y` after a letter other than `a`, `e`, `i`, `o`, and `u`: the `y` is
|
|
236
|
+
replaced by `ies`.
|
|
237
|
+
3. Otherwise `s` is appended.
|
|
238
|
+
|
|
239
|
+
A phrase whose last character is not a letter has no plural. The capitalised variant of a string
|
|
240
|
+
whose first character is of category Ll is the string with that character replaced by the result
|
|
241
|
+
of ECMAScript `String.prototype.toUpperCase` on it ([ECMA-262]); any other string has none. A
|
|
242
|
+
possessive needs no variant: an apostrophe is not a word character, so the phrase or its plural
|
|
243
|
+
ends before it.
|
|
244
|
+
|
|
245
|
+
The variants of an entry that passes [terms file](#terms-file) are these normalised strings, each
|
|
246
|
+
recording the entry, its kind, and whether it is plural and whether it is capitalised:
|
|
247
|
+
|
|
248
|
+
| Source | Kind | Variants |
|
|
249
|
+
| ----------------------------------------- | ------------ | ----------------------------------------------------------- |
|
|
250
|
+
| `label` of an active entry | `label` | the label, its plural, and the capitalised variant of each |
|
|
251
|
+
| each `forms` phrase of an active entry | `form` | the phrase and its capitalised variant |
|
|
252
|
+
| `label` of a deprecated entry | `deprecated` | the label, its plural, and the capitalised variant of each |
|
|
253
|
+
| each `forms` phrase of a deprecated entry | `deprecated` | the phrase and its capitalised variant |
|
|
254
|
+
| each `reject` phrase of an active entry | `reject` | the phrase, its plural, and the capitalised variant of each |
|
|
255
|
+
|
|
256
|
+
The reject phrases of a deprecated entry give no variant.
|
|
257
|
+
|
|
258
|
+
### 4.2 Occurrences {#occurrences}
|
|
259
|
+
|
|
260
|
+
An occurrence is a place in a prose run where a variant is found. Each prose run is scanned from
|
|
261
|
+
its first character. At a position `i`, a variant `v` is found when, from `i`:
|
|
262
|
+
|
|
263
|
+
- the run's characters spell `v`, a maximal run of white space in the prose run matching one
|
|
264
|
+
space of `v`, with no barrier in between;
|
|
265
|
+
- when the first character of `v` is a word character, the character before `i` is not a word
|
|
266
|
+
character, a barrier and the start of the run counting as not one;
|
|
267
|
+
- when the last character of `v` is a word character, the character after the spelled text is
|
|
268
|
+
not a word character, a barrier and the end of the run counting as not one.
|
|
269
|
+
|
|
270
|
+
When at least one variant is found at `i`, the one that comes first in this order gives an
|
|
271
|
+
occurrence and the scan continues after the spelled text: the longer spelled text first, in
|
|
272
|
+
UTF-16 code units; then kind `label` or `form` before kind `deprecated`; then not capitalised
|
|
273
|
+
before capitalised; then not plural before plural; then
|
|
274
|
+
kind `label`, `form`, `deprecated`, `reject`; then ascending entry `id`. Otherwise the scan
|
|
275
|
+
continues at `i` + 1. An occurrence starts at the position of its first character; its source
|
|
276
|
+
text is the document text from the start of its first character's source to the end of its last
|
|
277
|
+
character's source.
|
|
278
|
+
|
|
279
|
+
### 4.3 Uses {#uses}
|
|
280
|
+
|
|
281
|
+
A document uses an active entry when it has an occurrence of kind `label` or `form` of that entry,
|
|
282
|
+
or a code span whose entire content, as CommonMark decodes it and then normalised per
|
|
283
|
+
[phrases](#phrases), equals its normalised label or a normalised `forms` phrase, or the capitalised
|
|
284
|
+
variant of either ([phrases](#phrases)). A derived plural alone does not count unless listed in
|
|
285
|
+
`forms`. Every matching active entry counts as used; the occurrence tie-break of
|
|
286
|
+
[occurrences](#occurrences) does not select between code-span matches. Code spans are considered
|
|
287
|
+
wherever inline content is parsed under [parsing](#parsing), including the thesaurus cells excluded
|
|
288
|
+
from prose runs, but not in front matter, HTML blocks, code blocks, or image descriptions. Substring
|
|
289
|
+
matches do not count: a code span `Terms` uses the label `Terms`, but a code span `run Terms now`
|
|
290
|
+
does not use the label `Terms`. Suppression comments do not change uses.
|
|
291
|
+
|
|
292
|
+
Code-span uses count only for T005 and T006 (including the `local` rules) in [file
|
|
293
|
+
checks](#file-checks). A code span remains a barrier under [prose runs](#prose-runs): it gives no
|
|
294
|
+
occurrence, so no prose finding and no edit list item. For T006 an available external owner text is
|
|
295
|
+
parsed and tested for use by these same rules without becoming a document.
|
|
296
|
+
|
|
297
|
+
## 5. Checks {#checks}
|
|
298
|
+
|
|
299
|
+
### 5.1 Findings {#findings}
|
|
300
|
+
|
|
301
|
+
A finding is one reported problem: a workspace path, a line, a column, a code, and a message.
|
|
302
|
+
Its text is `<path>:<line>:<column> <code> <message>`. In a message, `"<x>"` is the value as
|
|
303
|
+
ECMAScript `JSON.stringify` writes it ([ECMA-262]). Findings are ordered by path, then line,
|
|
304
|
+
then column, then code, then message, each ascending by UTF-16 code units or numerically. Every
|
|
305
|
+
finding has the same weight: there is no severity level.
|
|
306
|
+
|
|
307
|
+
The file checks are those that [file checks](#file-checks) lists; the prose checks of a document
|
|
308
|
+
are those that [prose checks](#prose-checks) lists, for that document. The check of a workspace gives the findings of
|
|
309
|
+
the file checks and of the prose checks of every document, ordered, with every finding a valid
|
|
310
|
+
suppression comment suppresses left out.
|
|
311
|
+
|
|
312
|
+
### 5.2 File checks {#file-checks}
|
|
313
|
+
|
|
314
|
+
A file check finding has the path `.pi/pi-dent/terms.yaml`. `<id>` is the concerned entry's `id`. A
|
|
315
|
+
T001 finding concerns the entry its `<value path>` is or lies under, left in or not. Any other
|
|
316
|
+
finding concerns the entry `<id>` and every entry its message names. A finding is placed at the
|
|
317
|
+
start of a YAML node: for T001, the node its `<value path>` names, or line 1, column 1 for `(file)`
|
|
318
|
+
except that a syntax error is placed where the parser reports it; for T002, the label or `forms`
|
|
319
|
+
item `<p>`; for T003, the item `<x>`, the item naming the entry itself, the `owner` value, or the
|
|
320
|
+
`replacedBy` value of a cycle; for T004, the value of the `reason` or `<field>` its message names,
|
|
321
|
+
else the entry; for T005, the `label` value; for T006, the `owner` value.
|
|
322
|
+
|
|
323
|
+
| Code | Condition | Message |
|
|
324
|
+
| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
325
|
+
| T001 | A violation of [terms file](#terms-file) | `<value path>: <reason>` |
|
|
326
|
+
| T002 | The normalised label or a normalised `forms` phrase `<p>` of an active entry equals the normalised label or a normalised `forms` phrase of another entry `<other>` that is deprecated, or active with a smaller `id` | `<id>: "<p>" is also a label or form of <other>` |
|
|
327
|
+
| T002 | The normalised label or a normalised `forms` phrase `<p>` of an active entry equals a normalised `reject` phrase of an active entry `<other>`, itself included | `<id>: "<p>" is a reject phrase of <other>` |
|
|
328
|
+
| T003 | An id `<x>` in the entry's `<field>`, `distinguish` or `replacedBy`, is not an existing id | `<id>: <field> names <x>, which is not an entry` |
|
|
329
|
+
| T003 | The entry's `distinguish` or `replacedBy` holds its own `id` | `<id>: <field> names the entry itself` |
|
|
330
|
+
| T003 | The `owner` of an active entry is internal and is not a document | `<id>: owner <owner> is not a document` |
|
|
331
|
+
| T003 | The entry has the smallest `id` of its cycle set, when that set holds two or more entries | `<id>: replacedBy cycle through <ids>` |
|
|
332
|
+
| T004 | A deprecated entry has no `reason` | `<id>: deprecated without a reason` |
|
|
333
|
+
| T004 | A deprecated entry with `reason` `merged` or `renamed` has other than exactly one replacement | `<id>: reason <reason> needs exactly one replacement, has <n>` |
|
|
334
|
+
| T004 | A deprecated entry with `reason` `split` has fewer than two replacements | `<id>: reason split needs at least two replacements, has <n>` |
|
|
335
|
+
| T004 | A deprecated entry with `reason` `out-of-scope` has a replacement | `<id>: reason out-of-scope takes no replacement, has <n>` |
|
|
336
|
+
| T004 | An active entry has `reason` or a replacement | `<id>: <field> is set on an active entry` |
|
|
337
|
+
| T005 | An active entry with `key` `shared` or `confusable` is used by no document | `<id>: "<label>" is used by no document` |
|
|
338
|
+
| T005 | An active entry with `key` `shared` is used by exactly one document | `<id>: "<label>" is shared but used only by <path>` |
|
|
339
|
+
| T005 | An active entry with `key` `local` is used by a document `<path>` other than its owner (one finding per such document) | `<id>: "<label>" is local but used by <path>` |
|
|
340
|
+
| T006 | An active entry's owner text is available from its document or its supplied external owner text, and that text does not use the entry | `<id>: owner <owner> does not use "<label>"` |
|
|
341
|
+
|
|
342
|
+
`<value path>` names the concerned value from the root, mapping keys joined by `.` and sequence
|
|
343
|
+
positions written `[<i>]` from 0, such as `terms[3].label`; it is `(root)` for the root value
|
|
344
|
+
itself, and `(file)` for a failure of [location and syntax](#location-and-syntax). `<reason>` is:
|
|
345
|
+
|
|
346
|
+
| Violation | `<value path>` | `<reason>` |
|
|
347
|
+
| ---------------------------------------------------------------------------------------------------------- | ------------------- | ----------------------------- |
|
|
348
|
+
| The bytes are not valid UTF-8 | `(file)` | `not valid UTF-8` |
|
|
349
|
+
| The text does not parse | `(file)` | the parser's message |
|
|
350
|
+
| The text holds `<n>` YAML documents, `<n>` other than 1 | `(file)` | `holds <n> YAML documents` |
|
|
351
|
+
| A mapping has a duplicate key | `(file)` | `duplicate key` |
|
|
352
|
+
| A required key `<key>` is absent | the object | `missing <key>` |
|
|
353
|
+
| An object has unknown keys | the object | `unknown keys <keys>` |
|
|
354
|
+
| A value does not have its type | the value | `must be <type>` |
|
|
355
|
+
| A list holds a phrase or id `<x>` that an earlier item holds (`<x>` is the later item's string as written) | the later item | `repeats "<x>"` |
|
|
356
|
+
| `history` holds no item | the `history` value | `must hold at least one item` |
|
|
357
|
+
| An `id` is not greater than the last string `id` `<p>` before it | the `id` value | `must come after <p>` |
|
|
358
|
+
|
|
359
|
+
`<keys>` are the unknown keys as `"<x>"`, in source order, joined by `, `. `<type>` is, for the type
|
|
360
|
+
that [root](#root), [entries](#entries), or [history items](#history-items) gives the value: `a
|
|
361
|
+
mapping`, `a sequence`, `true or false`, `a string`, `an id matching ^[a-z0-9]+(-[a-z0-9]+)*$`, `a
|
|
362
|
+
phrase (one trimmed line holding a letter, mark, or digit)`, `one non-empty line`, `a workspace path
|
|
363
|
+
ending with .md`, `an owner path ending with .md`, `a date YYYY-MM-DD`, or, for an enumeration, `one
|
|
364
|
+
of ` and its values in table order joined by `, `.
|
|
365
|
+
|
|
366
|
+
An external owner gives no T003 owner finding, whether or not its text is available. T006
|
|
367
|
+
skips an unavailable external owner. External owner use does not count toward T005's document
|
|
368
|
+
counts. A `local` entry used by no document gives no zero-use T005: only T006 applies when its
|
|
369
|
+
owner text is available and does not use it (or T003 when its internal owner is not a document).
|
|
370
|
+
The `local` constraints give no P findings; use outside the owner is reported only by T005.
|
|
371
|
+
For example, a `local` entry with an available owner that does not use it and two nonowner
|
|
372
|
+
documents that do use it gives two local T005 findings and one T006. With no uses anywhere it
|
|
373
|
+
gives only T006; with only an unavailable external owner and no document uses it gives neither.
|
|
374
|
+
|
|
375
|
+
> Note (non-normative): a left-out entry's id is an existing id, so a reference to it gives no
|
|
376
|
+
> T003 finding.
|
|
377
|
+
|
|
378
|
+
The cycle set of an entry is the set of entries it reaches by following `replacedBy` ids one or
|
|
379
|
+
more times and that reach it back the same way; `<ids>` are their ids in ascending order, joined
|
|
380
|
+
by `, `. An entry left out under [entries](#entries) gives no finding other than T001.
|
|
381
|
+
|
|
382
|
+
### 5.3 Prose checks {#prose-checks}
|
|
383
|
+
|
|
384
|
+
A prose check finding has the document's path and the start position of its occurrence or
|
|
385
|
+
suppression comment. `<text>` is the spelled prose text of the occurrence, normalised.
|
|
386
|
+
|
|
387
|
+
| Code | Condition | Message |
|
|
388
|
+
| ---- | --------------------------------------- | ------------------------------------------------------------------------------- |
|
|
389
|
+
| P001 | An occurrence of kind `reject` | `"<text>" is rejected: use "<label>" (<id>)` |
|
|
390
|
+
| P002 | An occurrence of kind `deprecated` | `"<text>" is deprecated (<reason>)<replacement>` |
|
|
391
|
+
| S001 | A suppression comment that is not valid | `terms-ignore needs one code, P001 or P002, a colon, and a reason, on one line` |
|
|
392
|
+
|
|
393
|
+
In P001, `<label>` and `<id>` are those of the entry whose reject phrase gave the variant. In
|
|
394
|
+
P002, `<reason>` is the entry's `reason`, or `none` when it has none, and `<replacement>` is
|
|
395
|
+
empty when it has no replacement, else `: use ` followed by `"<label>" (<id>)` for each
|
|
396
|
+
replacement in `replacedBy` order, or `<id>` alone for an id that names no entry left in under
|
|
397
|
+
[entries](#entries), joined by a space, `or`, and a space.
|
|
398
|
+
|
|
399
|
+
### 5.4 Change checks {#change-checks}
|
|
400
|
+
|
|
401
|
+
A change set describes how the workspace differs from an earlier state of it, its base
|
|
402
|
+
workspace, as a list of changes; a change is one item of a change set. The caller supplies it:
|
|
403
|
+
the library takes no revision and runs no Git command. Each change has these fields:
|
|
404
|
+
|
|
405
|
+
| Field | Type | Contract |
|
|
406
|
+
| -------- | ------------------------ | --------------------------------------------------------------------------------- |
|
|
407
|
+
| `path` | workspace path | The changed file's path in the workspace. |
|
|
408
|
+
| `before` | string or null | The file's text in the base workspace; null when it has no file at the base path. |
|
|
409
|
+
| `from` | workspace path, optional | The file's path in the base workspace when it was moved; absent means `path`. |
|
|
410
|
+
|
|
411
|
+
A change's base path is its `from`, else its `path`. A change set is valid when each of these
|
|
412
|
+
conditions holds:
|
|
413
|
+
|
|
414
|
+
1. Every `path` and `from` is `.pi/pi-dent/terms.yaml` or a workspace path ending with `.md`.
|
|
415
|
+
2. A `from` is `.pi/pi-dent/terms.yaml` exactly when its change's `path` is.
|
|
416
|
+
3. A change with a `from` has a `before` that is not null.
|
|
417
|
+
4. No `before` holds a lone surrogate.
|
|
418
|
+
5. No two changes have the same `path`.
|
|
419
|
+
6. No two changes have the same base path.
|
|
420
|
+
|
|
421
|
+
An empty change set is valid. [terms-tool.md, validation](terms-tool.md#validation), rejects an
|
|
422
|
+
invalid one. A file that no change lists is the same in the base workspace as in the workspace, so
|
|
423
|
+
its changes introduce nothing.
|
|
424
|
+
|
|
425
|
+
The base workspace is the workspace with each change undone:
|
|
426
|
+
|
|
427
|
+
1. Its documents are the workspace's documents without those at a change's `path` or base path,
|
|
428
|
+
plus, for each change whose base path ends with `.md` and whose `before` is not null and holds
|
|
429
|
+
no U+0000, a document at the base path whose text is `before` without a leading U+FEFF.
|
|
430
|
+
2. Its terms file is, when a change has the `path` `.pi/pi-dent/terms.yaml`, that change's `before`
|
|
431
|
+
encoded as UTF-8, or none when it is null; otherwise the workspace's terms file.
|
|
432
|
+
3. Its external owner texts are the workspace's.
|
|
433
|
+
|
|
434
|
+
The lines of a text are its parts between line endings ([documents](#documents)); an empty part
|
|
435
|
+
after the last line ending is not a line, and the empty text has none. The base text of a change is
|
|
436
|
+
its `before` without a leading U+FEFF, the empty text when `before` is null; its current text is the
|
|
437
|
+
text of the document or the terms file at its `path`, decoded as UTF-8 without a leading U+FEFF, the
|
|
438
|
+
empty text when there is none or the bytes are not valid UTF-8.
|
|
439
|
+
|
|
440
|
+
The line pairing of a change is the longest list of pairs `(i, j)` of a line number of its base text
|
|
441
|
+
and a line number of its current text, both ascending, whose lines are equal as UTF-16 code unit
|
|
442
|
+
sequences; among several such lists, the one whose sequence `i1, j1, i2, j2, …` is smallest,
|
|
443
|
+
compared item by item. For example, base lines `x`, `y` and current lines `y`, `x` give the one pair
|
|
444
|
+
`(1, 2)`, so current line 1 is a changed line. A changed line is a line of a current text that is in
|
|
445
|
+
no pair. The pairs split the line numbers of each text into regions: those before the first pair,
|
|
446
|
+
those between two consecutive pairs, and those after the last pair, the last region of each text
|
|
447
|
+
also holding every line number past its last line. With no pair, each text has one region holding
|
|
448
|
+
all its line numbers. A region of the current text and the region of the base text between the same
|
|
449
|
+
pairs correspond.
|
|
450
|
+
|
|
451
|
+
The base lines of a finding of the workspace in the file at a change's `path` are, when its line is
|
|
452
|
+
in a pair, the base line of that pair, else the lines of the base region that corresponds to the
|
|
453
|
+
region holding its line; its base path is the change's base path. For a finding in any other file,
|
|
454
|
+
its base path is its path and its base lines are its line. Findings with the same base path, base
|
|
455
|
+
lines, code, and message form a group. The base count of a group is the number of findings of the
|
|
456
|
+
check of the base workspace ([findings](#findings)) at its base path, on one of its base lines, with
|
|
457
|
+
its code and message; a base workspace without a terms file gives no findings. The introduced
|
|
458
|
+
findings of a change set are, of each group, the findings of the check of the workspace after the
|
|
459
|
+
first `<base count>` in finding order, in the order of [findings](#findings).
|
|
460
|
+
|
|
461
|
+
> Note (non-normative): a finding on an edited line is compared with the base findings of the
|
|
462
|
+
> lines that edit replaced. A line moved across an unchanged line leaves its region, so its
|
|
463
|
+
> findings are introduced, as is a finding whose message names a moved document's path.
|
|
464
|
+
|
|
465
|
+
The label occurrences in changed lines of a change set are the occurrences of kind `label` or
|
|
466
|
+
`form` (a form counting as its entry's label) in a document at a change's `path` that start on a
|
|
467
|
+
changed line. Each is the entry's
|
|
468
|
+
`id`, `label`, and `meaning`, the document's path, the occurrence's line and column, and its
|
|
469
|
+
source text normalised ([phrases](#phrases)). They are ordered by `id`, then path, line, and column;
|
|
470
|
+
suppression comments do not change them.
|
|
471
|
+
|
|
472
|
+
## 6. Operations {#operations}
|
|
473
|
+
|
|
474
|
+
### 6.1 Common rules {#common-rules}
|
|
475
|
+
|
|
476
|
+
An operation is one of `add`, `update`, `rename`, `merge`, `split`, `deprecate`, `reown`, and
|
|
477
|
+
`import`. It takes the terms file's bytes, absent when there is no terms file, the documents, the
|
|
478
|
+
date as a calendar date of [ISO 8601], and its parameters, and gives either a refusal text or the
|
|
479
|
+
new terms file text, in canonical form ([canonical form](#canonical-form)), together with an edit
|
|
480
|
+
list. An operation MUST NOT remove an entry, change an `id`, or change any entry other than those
|
|
481
|
+
its section names. It MUST append, to each entry it changes, one history item with the given date,
|
|
482
|
+
the operation's name as `op`, and the operands of [history items](#history-items). Every string
|
|
483
|
+
parameter other than `owner` and `path`, and every string of a list parameter, is normalised
|
|
484
|
+
([phrases](#phrases)) before use; `owner` and `path` are used with leading and trailing white space
|
|
485
|
+
removed.
|
|
486
|
+
|
|
487
|
+
An operation MUST refuse, with the text of the first that applies, when:
|
|
488
|
+
|
|
489
|
+
1. the terms file is absent and the operation is neither `add` nor `import`:
|
|
490
|
+
`no terms file at .pi/pi-dent/terms.yaml`;
|
|
491
|
+
2. the terms file gives a T001 finding:
|
|
492
|
+
`.pi/pi-dent/terms.yaml has T001 findings; fix them first: <finding text>`, with the first
|
|
493
|
+
such finding;
|
|
494
|
+
3. an id `<x>` of a parameter that the operation's section says names an active entry, taken in
|
|
495
|
+
parameter order and then list order, is no entry's `id`: `no entry <x>`, or names a
|
|
496
|
+
deprecated entry: `<x> is deprecated`; then a refusal of the operation's own section, in the
|
|
497
|
+
order listed there;
|
|
498
|
+
4. the new terms file gives a T001, T002, T003, or T004 finding that concerns ([file
|
|
499
|
+
checks](#file-checks)) an entry the operation changed: `<operation> refused: <finding text>`,
|
|
500
|
+
with the first such finding.
|
|
501
|
+
|
|
502
|
+
The edit list holds the occurrences that the operation's section names, in the new terms
|
|
503
|
+
file's matching, ordered by path, line, and column, without an occurrence of kind `reject` that
|
|
504
|
+
a valid P001 suppression comment suppresses or one of kind `deprecated` that a valid P002
|
|
505
|
+
suppression comment suppresses. Each item is the occurrence's path, line, column, source text as
|
|
506
|
+
`old`, and a suggested text as `new`, or none:
|
|
507
|
+
|
|
508
|
+
- for an occurrence of kind `reject` of entry `E`, the label of `E`;
|
|
509
|
+
- for an occurrence of kind `deprecated` whose entry has exactly one replacement, that
|
|
510
|
+
replacement is an entry, and whose variant did not come from a `forms` phrase, its label;
|
|
511
|
+
- for any other occurrence, and for one whose variant came from a `forms` phrase, none.
|
|
512
|
+
|
|
513
|
+
A suggested label is turned into its plural when the occurrence's variant is plural, none being
|
|
514
|
+
suggested when it has no plural, and then into its capitalised variant when the occurrence's
|
|
515
|
+
variant is capitalised and the label has one. An operation MUST NOT change a document.
|
|
516
|
+
|
|
517
|
+
### 6.2 `add` {#add}
|
|
518
|
+
|
|
519
|
+
Parameters: `id`, `label`, `meaning`, `owner`, `group`, `key`, and optionally `reject`,
|
|
520
|
+
`distinguish`, and `forms`. Refusal: `<id> is already an entry` when an entry has the `id`.
|
|
521
|
+
When the terms file is absent, the input is a terms file without settings and entries. The
|
|
522
|
+
operation inserts an active entry with these fields at its place in `id` order. The edit list
|
|
523
|
+
holds the occurrences of kind `reject` of the new entry.
|
|
524
|
+
|
|
525
|
+
### 6.3 `rename` {#rename}
|
|
526
|
+
|
|
527
|
+
Parameters: `id`, naming an active entry, `label`, and optionally `forms`. Refusal: `<id> is already
|
|
528
|
+
labelled "<label>"` when `label` equals the entry's label after normalisation. The operation appends
|
|
529
|
+
the old label, then each old `forms` phrase, to the entry's `reject`, leaving out a phrase already
|
|
530
|
+
there, the new label, and each phrase of the new `forms`; removes the new label and each phrase of
|
|
531
|
+
the new `forms` from `reject`; sets `label`; and sets `forms` to the parameter, or removes it when
|
|
532
|
+
the parameter is absent; phrases are compared normalised. The edit list holds the occurrences of
|
|
533
|
+
kind `reject` of the entry whose variant came from a phrase this operation appended; one whose
|
|
534
|
+
phrase was an old `forms` phrase has no suggested text. The old label is the entry's `label` as
|
|
535
|
+
written, not normalised: the phrase it appends to `reject`, the `from` operand of its history item,
|
|
536
|
+
and the old label of the summary are that text.
|
|
537
|
+
|
|
538
|
+
### 6.4 `merge` {#merge}
|
|
539
|
+
|
|
540
|
+
Parameters: `id` and `into`, each naming an active entry. Refusal:
|
|
541
|
+
`cannot merge <id> into itself` when they are equal. The operation sets the entry `id` to
|
|
542
|
+
`status` `deprecated`, `reason` `merged`, and `replacedBy` `[into]`; appends its `reject`
|
|
543
|
+
phrases to the `reject` of `into`, leaving out a phrase already there; and removes `reject` from
|
|
544
|
+
`id`. The
|
|
545
|
+
history item on `id` has the operand `into`, the one on `into` the operand `from`. The edit list
|
|
546
|
+
holds the occurrences of kind `deprecated` of `id` and of kind `reject` of `into` whose variant
|
|
547
|
+
came from a phrase this operation moved.
|
|
548
|
+
|
|
549
|
+
### 6.5 `split` {#split}
|
|
550
|
+
|
|
551
|
+
Parameters: `id`, naming an active entry, and `into`, a list of ids, each naming an active entry.
|
|
552
|
+
The operation sets the entry `id` to `status` `deprecated`, `reason` `split`, and `replacedBy` the
|
|
553
|
+
list. The history item on `id` has the operand `into`, the one on each listed entry the operand
|
|
554
|
+
`from`; a list of fewer than two ids, or one naming `id`, gives the finding of refusal 4 of [common
|
|
555
|
+
rules](#common-rules). The edit list holds the occurrences of kind `deprecated` of `id`; none has a
|
|
556
|
+
suggested text.
|
|
557
|
+
|
|
558
|
+
### 6.6 `deprecate` {#deprecate}
|
|
559
|
+
|
|
560
|
+
Parameters: `id`, naming an active entry, `reason`, either `renamed` or `out-of-scope`, and
|
|
561
|
+
optionally `replacedBy`, a list of ids, each naming an active entry. The operation sets the entry to
|
|
562
|
+
`status` `deprecated` with the `reason` and, when given, the `replacedBy`. With exactly one
|
|
563
|
+
replacement, it also moves the entry's `reject` phrases to the replacement as `merge` does, and
|
|
564
|
+
appends a history item with the operand `from` to the replacement. A replacement count the reason
|
|
565
|
+
does not admit gives the finding of refusal 4 of [common rules](#common-rules). The edit list holds
|
|
566
|
+
the occurrences of kind `deprecated` of `id` and of kind `reject` of the replacement whose variant
|
|
567
|
+
came from a phrase this operation moved.
|
|
568
|
+
|
|
569
|
+
### 6.7 `reown` {#reown}
|
|
570
|
+
|
|
571
|
+
Parameters: `id`, naming an active entry, and `owner`. Refusal:
|
|
572
|
+
`<id> is already owned by <owner>` when `owner` equals the entry's `owner`. The operation sets
|
|
573
|
+
`owner`. The edit list is empty.
|
|
574
|
+
|
|
575
|
+
### 6.8 `import` {#import}
|
|
576
|
+
|
|
577
|
+
`import` builds the entries of an empty terms file from a thesaurus table of one document.
|
|
578
|
+
Parameter: `path`. Refusals, in order:
|
|
579
|
+
|
|
580
|
+
1. `import needs a terms file without entries; .pi/pi-dent/terms.yaml has <n>` when the terms
|
|
581
|
+
file has at least one entry;
|
|
582
|
+
2. `<path> is not a document` when `path` is not a document;
|
|
583
|
+
3. `<path> has no thesaurus table` when the document has no thesaurus table;
|
|
584
|
+
4. `<path>:<line>: <problem>` for the first row, in document order, that has a problem of this
|
|
585
|
+
list, with the row's line and the first of its problems in list order: `the Term cell is
|
|
586
|
+
empty`, `the label gives no id`, `no heading precedes the table`, `the Owner cell gives no
|
|
587
|
+
owner path`.
|
|
588
|
+
|
|
589
|
+
A thesaurus table is a table of the document whose header cells, as cell texts, are exactly `Term`,
|
|
590
|
+
`Meaning`, `Owner`, and `Avoid or distinguish`, in this order. The cell text of a cell is its inline
|
|
591
|
+
content as plain text, normalised: the characters a prose run gets ([prose runs](#prose-runs)), with
|
|
592
|
+
the content of a code span and the description of an image in place of their barriers and raw HTML
|
|
593
|
+
and autolinks contributing nothing. Each body row of every thesaurus table, in document order, gives
|
|
594
|
+
one active entry, the entries placed in ascending `id` order:
|
|
595
|
+
|
|
596
|
+
| Field | Value |
|
|
597
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
598
|
+
| `label` | The Term cell text. |
|
|
599
|
+
| `id` | The label in ECMAScript lower case, each maximal run of characters other than `a`–`z` and `0`–`9` replaced by `-`, leading and trailing `-` removed; when an earlier row gave the same id, `-<n>` appended with the smallest `n` from 2 that gives a new id. |
|
|
600
|
+
| `meaning` | The Meaning cell text. |
|
|
601
|
+
| `owner` | The row's owner path. |
|
|
602
|
+
| `group` | The heading text, as plain text like a cell text, of the last heading before the table. |
|
|
603
|
+
| `key` | Derived by the rule below. |
|
|
604
|
+
| `distinguish` | The id of each other row whose label equals an item of the row, without repeats, in item order. |
|
|
605
|
+
| `history` | One item with `op` `import` and the operand `from` set to `path`. |
|
|
606
|
+
|
|
607
|
+
The operation MUST set an imported entry's `key` to `local` when its owner is a workspace
|
|
608
|
+
document and the set of workspace documents that use the entry ([uses](#uses)), computed in the
|
|
609
|
+
proposed file's matching, is exactly that owner; else to `confusable` when that set holds exactly
|
|
610
|
+
one document; otherwise to `shared`. An external owner never gives `local`, and is not a use. The
|
|
611
|
+
operation also gives the ids assigned `local`,
|
|
612
|
+
in ascending `id` order, an empty list when none qualify.
|
|
613
|
+
|
|
614
|
+
The owner path of a row is the destination of the first link other than an autolink in its Owner
|
|
615
|
+
cell, else the Owner cell text, without the part from its first `#`, joined with `/` to the
|
|
616
|
+
directory of `path`, or alone when that directory is the workspace root, then with each `.` segment
|
|
617
|
+
removed and each `..` segment removed together with the segment before it when that preceding
|
|
618
|
+
segment is not `..`; leading `..` segments are retained. The Owner cell gives no owner path when
|
|
619
|
+
that destination or text, before the join, is empty, starts with `/`, or holds a `:` before its
|
|
620
|
+
first `/` (or has no `/`); or when the resulting path is not an owner path
|
|
621
|
+
([documents](#documents)). For example, from `docs/research/README.md`,
|
|
622
|
+
`../../specs/terms.md#entries` gives the owner `specs/terms.md`; from `specs/terms.md`,
|
|
623
|
+
`../../elsewhere/notes.md#finding` gives the external owner `../elsewhere/notes.md`, retaining its
|
|
624
|
+
leading `../`.
|
|
625
|
+
|
|
626
|
+
The items of a row are the parts of its Avoid or distinguish cell text split at `;`, each
|
|
627
|
+
normalised, empty parts left out. Every item that does not give a `distinguish` id is a reject
|
|
628
|
+
candidate of the row's entry. The operation keeps the input's `settings`. Its edit list is empty;
|
|
629
|
+
it also gives its reject candidates as pairs of entry id and item, in row order and then item
|
|
630
|
+
order.
|
|
631
|
+
|
|
632
|
+
> Note (non-normative): whether an item names a specific phrase or an ordinary word is a
|
|
633
|
+
> judgement; the candidates are returned for the agent to add with `update`'s `addReject` or drop.
|
|
634
|
+
|
|
635
|
+
### 6.9 `update` {#update}
|
|
636
|
+
|
|
637
|
+
Parameters: `id`, naming an active entry, or any entry when `status` is given, and optionally
|
|
638
|
+
`status`, `key`, `meaning`, `addReject`, `removeReject`, `addDistinguish`, and `removeDistinguish`.
|
|
639
|
+
`status` takes the one value `active`; `key` takes the values of [entries](#entries); `meaning` is a
|
|
640
|
+
string, normalised ([common rules](#common-rules)) and compared with the stored meaning as written;
|
|
641
|
+
the other parameters are string arrays, empty when absent. Reject operands are phrases and
|
|
642
|
+
distinguish operands are ids; they are compared after [phrases](#phrases) normalisation, including
|
|
643
|
+
against stored strings. An unchanged `status`, `key`, or `meaning` is allowed alongside another
|
|
644
|
+
effective change. Empty arrays do nothing.
|
|
645
|
+
|
|
646
|
+
After refusals 1 to 3 of [common rules](#common-rules), the operation MUST refuse in this order
|
|
647
|
+
(lists are scanned in their input order). In these texts `<field>` is the parameter name, `<other>`
|
|
648
|
+
is the distinguish operand, and `"<value>"` and `"<phrase>"` are the normalised operand as
|
|
649
|
+
ECMAScript `JSON.stringify` writes it:
|
|
650
|
+
|
|
651
|
+
1. For each list in parameter order `addReject`, `removeReject`, `addDistinguish`,
|
|
652
|
+
`removeDistinguish`, a repeated normalised value: `<field> repeats "<value>"`.
|
|
653
|
+
2. A value in both reject lists, in `addReject` order:
|
|
654
|
+
`update cannot add and remove reject "<phrase>"`; then a value in both distinguish lists,
|
|
655
|
+
in `addDistinguish` order: `update cannot add and remove distinguish <other>`.
|
|
656
|
+
3. A `removeReject` phrase absent from the entry's `reject`:
|
|
657
|
+
`<id> does not reject "<phrase>"`; then an `addReject` phrase already present:
|
|
658
|
+
`<id> already rejects "<phrase>"`.
|
|
659
|
+
4. For each id in `addDistinguish`, then `removeDistinguish`, an unknown id:
|
|
660
|
+
`no entry <other>`; or the entry's own id:
|
|
661
|
+
`cannot distinguish <id> from itself`. A distinguish target can be active or deprecated.
|
|
662
|
+
5. A `removeDistinguish` id not in the distinguish relation with `id`:
|
|
663
|
+
`<id> is not distinguished from <other>`; then an `addDistinguish` id already in that
|
|
664
|
+
relation: `<id> is already distinguished from <other>`. Presence on either side counts.
|
|
665
|
+
6. No effective change (all list parameters are empty, and `status`, `key`, and `meaning` are
|
|
666
|
+
each absent or unchanged):
|
|
667
|
+
`update makes no changes to <id>`.
|
|
668
|
+
|
|
669
|
+
When `status` is given and the entry is deprecated, the operation sets its `status` to `active` and
|
|
670
|
+
removes its `reason` and `replacedBy`; phrases an earlier operation moved from its `reject` are not
|
|
671
|
+
moved back. The operation sets `key` and `meaning` when given, removes the `removeReject` phrases,
|
|
672
|
+
and appends `addReject` phrases in input order. It removes each `removeDistinguish` relation from
|
|
673
|
+
both entries' lists and adds each `addDistinguish` relation to both entries' lists, appending in
|
|
674
|
+
input order. It preserves the order and spelling of all retained list items. It changes only the
|
|
675
|
+
entry named by `id` and entries named by distinguish operands. An entry is changed when its stored
|
|
676
|
+
`status`, `key`, `meaning`, `reject`, or `distinguish` changes, before adding history. Each such
|
|
677
|
+
entry gets exactly one `update` history item: with the operand `meaning`, the stored meaning before
|
|
678
|
+
the operation as written, when its meaning changed, and the operand `status`, `deprecated`, when its
|
|
679
|
+
status changed; otherwise with no operands, including an entry changed only by a reciprocal
|
|
680
|
+
distinguish edit. Removing a relation stored only on the other entry changes only that other entry;
|
|
681
|
+
it does not append history to an unchanged entry named by `id`.
|
|
682
|
+
|
|
683
|
+
The proposed file is subject to refusal 4 of [common rules](#common-rules), after the refusals above;
|
|
684
|
+
failure writes nothing and gives no edit list. The edit list holds the occurrences of kind `reject`
|
|
685
|
+
of `id` whose variant came from a phrase in `addReject`, using the new file's matching.
|
|
686
|
+
|
|
687
|
+
For example, `update` with `id: rendered-view`, `key: local`, and
|
|
688
|
+
`addReject: [rendering-view]` changes the key and appends that reject phrase, records one
|
|
689
|
+
history item with `op: update`, and lists matching prose occurrences of
|
|
690
|
+
`rendering-view`, not code spans. An update containing only the already-current key is refused.
|
|
691
|
+
An `update` of `rendered-view` with a new `meaning` sets it and records one `update` history
|
|
692
|
+
item whose `meaning` is the old text.
|
|
693
|
+
|
|
694
|
+
> Note (non-normative): a changed meaning keeps the label, for a concept that widens or is
|
|
695
|
+
> described better. A concept that becomes a different one is a `split` or a `deprecate`.
|
|
696
|
+
|
|
697
|
+
## 7. Normative references {#normative-references}
|
|
698
|
+
|
|
699
|
+
- [CommonMark] CommonMark Spec, version 0.31.2 (2024-01-28), J. MacFarlane: Section 2.1
|
|
700
|
+
(characters and lines), Section 4 (leaf blocks), Section 5 (container blocks), and Section 6
|
|
701
|
+
(inlines).
|
|
702
|
+
- [GFM] GitHub Flavored Markdown Spec, version 0.29-gfm (2019-04-06): Section 4.10 (tables
|
|
703
|
+
extension).
|
|
704
|
+
- [YAML 1.2.2] YAML Ain't Markup Language, version 1.2.2 (2021-10-01): the syntax of the terms
|
|
705
|
+
file, Section 5.1 (character set), and Section 10.3 (core schema).
|
|
706
|
+
- [Unicode] The Unicode Standard, Version 15.1.0: Section 4.5 (General Category) and Section 4.6
|
|
707
|
+
with Unicode Standard Annex #44 (the White_Space property).
|
|
708
|
+
- [ECMA-262] ECMAScript Language Specification, 14th edition (June 2023), Ecma International:
|
|
709
|
+
regular expressions, `String.prototype.toLowerCase`, `String.prototype.toUpperCase`, and
|
|
710
|
+
`JSON.stringify`.
|
|
711
|
+
- [ISO 8601] ISO 8601-1:2019, Date and time — Representations for information interchange —
|
|
712
|
+
Part 1: Basic rules: the calendar date, complete representation, extended format.
|
|
713
|
+
|
|
714
|
+
## 8. Specification gaps {#specification-gaps}
|
|
715
|
+
|
|
716
|
+
- Whether a `reject` phrase is a specific phrase or an ordinary word, whether a `label` is in
|
|
717
|
+
base form, and whether a `meaning` is one sentence are not checked.
|
|
718
|
+
- An `id` removed from the terms file by hand cannot be told from one never used, so its reuse
|
|
719
|
+
is not detected.
|
|
720
|
+
- No operation removes or rewrites a history item, and a hand edit of the terms file is outside
|
|
721
|
+
this specification, so a value a history item records, such as a stale fixture id or a personal
|
|
722
|
+
path, stays in the file. Whether a redact operation, or a rule admitting hand redaction of a
|
|
723
|
+
history item, should cover this is open.
|
|
724
|
+
- Text in another Unicode normalisation form than the phrase it spells does not match it.
|
|
725
|
+
- A hyphen is not a word character: `workspace` is found in `workspace-relative`.
|
|
726
|
+
- A label written in upper case throughout, as in a heading set in capitals, is not found; nor is
|
|
727
|
+
a sentence-initial capitalised word attributed to a lowercase label when an active entry's
|
|
728
|
+
label, or a reject phrase, is that capitalised word.
|
|
729
|
+
- The plural rules derive wrong plurals for some words; only `forms` adds the right ones.
|
|
730
|
+
- A suggested text replaces the whole source text of an occurrence, emphasis delimiters and
|
|
731
|
+
line breaks inside it included.
|
|
732
|
+
- A `terms-ignore` comment inside an HTML block holding more than the comment is neither a
|
|
733
|
+
suppression comment nor a finding.
|
|
734
|
+
- Which line and column a YAML parser reports for a syntax error, and its message, are not
|
|
735
|
+
specified.
|
|
736
|
+
- A change to an external owner file cannot be expressed in a change set: the base workspace
|
|
737
|
+
has the workspace's external owner texts.
|
|
738
|
+
- A file copied with `from` while its source stays shares its source's base findings: of each
|
|
739
|
+
group only the findings past the base count are introduced, chosen in finding order, so one of
|
|
740
|
+
the two copies of an old finding is reported; a copy written as a change without `from` gives
|
|
741
|
+
each its own.
|
|
742
|
+
- A file moved to a new path while a new file takes its old path cannot be written as a move: the
|
|
743
|
+
base paths repeat. Writing both as changes without `from` expresses it.
|
|
744
|
+
- The `reject` phrases of an entry deprecated by `split` or with `reason` `out-of-scope` give no
|
|
745
|
+
variant, so they are no longer reported.
|
|
746
|
+
- A plural or capitalised variant of one entry that spells a variant of another entry is not
|
|
747
|
+
reported.
|
|
748
|
+
- A file `git ls-files` lists but that cannot be read, or is not UTF-8, is not a document and is
|
|
749
|
+
not reported.
|
|
750
|
+
- The version of Git whose `ls-files` and `rev-parse` behaviour [workspace](#workspace) relies on
|
|
751
|
+
is not specified.
|
|
752
|
+
- The names the library exports are not specified.
|
|
753
|
+
- An external owner whose file is missing or unreadable gives no finding, so a wrong external
|
|
754
|
+
owner path is not reported.
|
|
755
|
+
- An external owner path pointing back into the workspace is not recognised as an alias of
|
|
756
|
+
its workspace document path; a `local` entry's use there gives T005.
|