1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//! This module defines the diagnostic conditions that the `citations` feature
//! reports (see [diagnostics](crate::guide::concepts_overview#diagnostics)).
//!
//! The lowering rules of `\cite` and `\R` report the errors in the citations
//! of a document: [`NoKey`], [`NoCitation`], [`UnknownFlag`] and
//! [`Uncollected`]. The stages of the feature report the problems with the
//! citation entries. The retrieve stage ([`RETRIEVE`](super::RETRIEVE))
//! obtains the citation entries from the citation providers, and reports
//! [`NoProvider`], [`ProviderFailed`], [`ProviderWarning`], [`EntryCites`] and
//! [`EntryNotInline`]. The check stage ([`CHECK`](super::CHECK)) reports
//! [`NoEntry`] for each cited key that has no citation entry.
//!
//! Each of these conditions is reported as an Error, except
//! [`ProviderWarning`], which is reported as a Warning. The document is
//! rendered in spite of these conditions. The documentation of each condition
//! states what is written in place of the faulty citation or citation entry.
//!
//! The condition [`StageFailed`](super::StageFailed), which a stage of the
//! feature reports when it cannot read or write one of its tables, is defined
//! together with the stages.
use DiagnosticInfo;
/// The error that is reported when a `\cite` call has an empty argument (id
/// `flm.citations.no-key`). An argument that contains only commas and
/// whitespace counts as empty.
///
/// Reported by the lowering rule of `\cite` when it is invoked, and by the
/// lowering rule of `\R` for the `\cite` call that follows the `\R`. If the
/// `\cite` call stands alone, it expands to a dropped mark
/// (`flm.pres.dropped`). Several `\cite` calls written directly one after
/// another, as in `\cite{a}\cite[Thm 4]{b}`, expand to one citation mark, and
/// a call with an empty argument adds no number to this citation mark.
;
/// Error raised when a `\R` is not immediately followed by `\cite`
/// (`flm.citations.no-citation`). The `\R` command must immediately be
/// followed by a valid `\cite{..}` command invocation, as in
/// `\R\cite{bib:myref}` or `\R[I]\cite{bib:myref,bib:myref2}`. Reported by the
/// lowering rule for `\R` when `\R` is invoked. In such a case, the `\R`
/// expands to a dropped mark (`flm.pres.dropped`).
;
/// The error that is reported when the flags argument of `\R` contains an
/// unknown flag (`flm.citations.unknown-flag`).
///
/// The flags argument of `\R` accepts two flags, each written as one
/// character, as in `\R[S]\cite{a}`. The flag `S` capitalizes the word that
/// `\R` writes before the citation mark (`Ref.` instead of `ref.`), and the
/// flag `I` omits this word. Whitespace in the flags argument is ignored.
///
/// Reported by the lowering rule of `\R` when it is invoked, once for each
/// unknown flag. Each unknown flag is ignored. If the flags argument contains
/// content other than characters, the error is reported once, with the plain
/// text of the whole argument, and the whole flags argument is ignored.
/// Error raised when a citation key is cited only outside the trees of the
/// document, so that it has no number (condition id
/// `flm.citations.uncollected`).
///
/// The collect stage ([`COLLECT`](super::COLLECT)) records the citation keys
/// of the citations in the trees of the document, and only these citation keys
/// are numbered. A citation in other content is not recorded. This is the
/// case for a citation in a [synthesized
/// value](crate::guide::concepts_overview#synthesized-values) that a stage
/// creates, and for a citation in the template of a user definition whose use
/// sites are expanded during lowering.
///
/// Reported by the lowering rules of `\cite` and `\R` through
/// [`stage_mark`](super::stage_mark), once for each such citation key, at the
/// `\cite` or `\R`. The citation key is left out of the citation mark. If no
/// citation key is left, the citation expands to a dropped mark
/// (`flm.pres.dropped`).
/// The error that is reported when a document cites works and no citation
/// provider is set up (`flm.citations.no-provider`).
///
/// Citation providers supply the citation entries of the cited works. The
/// program that embeds FLM contributes them to the service slot
/// [`PROVIDERS_SLOT`](super::PROVIDERS_SLOT); see
/// [`CitationProvider`](super::CitationProvider).
///
/// Reported once by the retrieve stage ([`RETRIEVE`](super::RETRIEVE)), at the
/// first citation of the document. The citations are numbered as usual, but no
/// cited key has a citation entry. A dropped mark (`flm.pres.dropped`) is
/// written in place of each citation entry, and the check stage also reports
/// [`NoEntry`] for each cited key.
/// The error that is reported when a citation provider fails to retrieve the
/// citation entry for a citation key (`flm.citations.provider-failed`).
///
/// A citation provider reports this failure by returning a
/// [`CitationProviderError`](super::CitationProviderError) for the citation
/// key. The retrieve stage also reports this error for every citation key of a
/// call of [`CitationProvider::answer_all`](super::CitationProvider::answer_all)
/// that returns a different number of results than it received requests.
///
/// Reported by the retrieve stage ([`RETRIEVE`](super::RETRIEVE)), at the first
/// citation of the citation key. No later citation provider is called for this
/// citation key, and the citation key has no citation entry. A dropped mark
/// (`flm.pres.dropped`) is written in place of its citation entry, and the
/// check stage also reports [`NoEntry`] for it.
/// The warning that is reported for each warning text that a citation
/// provider adds to its answer for a citation key
/// (`flm.citations.provider-warning`).
///
/// A citation provider adds a warning text to an answer with
/// [`CitationAnswer::with_warning`](super::CitationAnswer::with_warning). The
/// message of this diagnostic is the warning text.
///
/// Reported by the retrieve stage ([`RETRIEVE`](super::RETRIEVE)), at the first
/// citation of the citation key, in the order in which the warning texts were
/// added. The answer is processed as usual.
/// The error that is reported when the citation entry for a citation key
/// contains a citation (`flm.citations.entry-cites`).
///
/// A citation entry may not contain `\cite` or `\R`. The citation entry is
/// checked after the user definitions that it uses have been expanded, so a
/// citation that a user definition writes is also found.
///
/// Reported by the retrieve stage ([`RETRIEVE`](super::RETRIEVE)), at the first
/// citation of the citation key. The retrieve stage refuses the citation
/// entry, so the citation key has no citation entry. A dropped mark
/// (`flm.pres.dropped`) is written in place of the citation entry, and the
/// check stage also reports [`NoEntry`] for the citation key.
/// The error that is reported when the citation entry for a citation key is
/// not inline content (`flm.citations.entry-not-inline`).
///
/// A citation entry must be inline content, that is, content without
/// paragraph breaks and blocks, as in `D. Knuth, \emph{The TeXbook}, 1984`. A
/// citation entry is written inside an entry of the list of cited works, or
/// inside a citation mark under the in-place placement
/// ([`CitationPlacement::InPlace`](super::CitationPlacement::InPlace)). The
/// citation entry is checked after the user definitions that it uses have
/// been expanded.
///
/// Reported by the retrieve stage ([`RETRIEVE`](super::RETRIEVE)), at the first
/// citation of the citation key. The retrieve stage refuses the citation
/// entry, so the citation key has no citation entry. A dropped mark
/// (`flm.pres.dropped`) is written in place of the citation entry, and the
/// check stage also reports [`NoEntry`] for the citation key.
/// The error that is reported when a cited key has no citation entry
/// (`flm.citations.no-entry`).
///
/// The field `reason` states why the citation key has no citation entry
/// ([`MissingEntry`](super::MissingEntry)). For instance, no citation provider
/// handles the citation key, or the citation provider failed to retrieve the
/// citation entry.
///
/// Reported by the check stage ([`CHECK`](super::CHECK)), at the first citation
/// of the citation key. The citation key keeps its number, and its citations
/// are written as usual. A dropped mark (`flm.pres.dropped`) is written in
/// place of the citation entry: in the list of cited works, or, under the
/// in-place placement
/// ([`CitationPlacement::InPlace`](super::CitationPlacement::InPlace)), in the
/// citation marks.