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
//! [`contribute_kind`]: the function that makes every declaration an xnote
//! kind needs, for the kinds the `xnotes` feature declares from its
//! configuration and for the kinds other features contribute.
use Arc;
use crate;
use crate;
use crate;
use crateElementSpec;
use crate;
use XnoteKind;
use ;
/// Makes every declaration that the xnote kind `kind` needs, on behalf of the
/// feature that `b` registers.
///
/// The [`XnotesFeature`](super::XnotesFeature) calls it for every kind of its
/// configuration, and another feature calls it for a kind of its own, so that
/// both are declared alike. The function checks the kind first
/// ([`XnoteKind::validate`]).
///
/// It makes the following declarations as peer contributions, contributions
/// to a service slot another feature owns, which the registry build drops with
/// one Note when that feature is not registered (see
/// [`crate::core::services`]); the calling feature therefore builds without
/// the `xnotes` or the `numbering` feature:
///
/// - the kind itself, into the service slot of xnote kinds [`KINDS_SLOT`]
/// (`flm.xnotes.kinds`), from which the collect stage reads the kinds;
/// - for a numbered kind, into the numbering feature's service slots: the
/// counter `flm.xnotes.<kind>` ([`counter_name`]), numbered
/// [`within`](XnoteKind::within) the counter the kind states and shown by
/// default in the reference style; the reference style
/// `flm.xnotes.style.<kind>` ([`style_name`]): the kind's
/// [`words`](XnoteKind::words) and [`number_format`](XnoteKind::number_format),
/// no delimiters, several numbers joined compactly; and the mark style
/// `flm.xnotes.style.<kind>.mark` ([`mark_style_name`]): the kind's
/// [`mark`](XnoteKind::mark) template, no words, no delimiters (see
/// [counters and counter
/// styles](crate::guide::concepts_overview#counters-and-counter-styles)). An
/// unnumbered kind declares nothing to the numbering feature: its
/// [`mark`](XnoteKind::mark) holds no number placeholder, so it writes the
/// same text beside every xnote, and the `xnotes` feature compiles that text
/// once, when the registry is built, in the language of a counter style's
/// number template (the language a numbered kind's mark style is compiled
/// in); a mark that is not valid FLM fails the build.
///
/// It also makes the declarations of the kind's list, as the calling
/// feature's own:
///
/// - the synthesized list element `flm.xnotes.<kind>.list`
/// ([`list_element_name`]), a block carrying an [`XnotesListElement`], which
/// no document can write, with its element type's text (so the calling
/// feature gives that type no text of its own);
/// - the table `flm.xnotes.list.<kind>` ([`piece_table`](super::piece_table))
/// holding the list as a piece (a document-level [synthesized
/// value](crate::guide::concepts_overview#synthesized-values) that a
/// backend places beside the content;
/// [`Piece`](crate::core::piece::Piece)), the stage that writes it,
/// `flm.xnotes.build-list.<kind>` ([`ListBuilder`](super::ListBuilder)), and
/// the piece's declaration, contributed as a peer to the `pieces` feature's
/// service slot: placed after the content, on by default;
/// - the list's general lowering rule `flm.xnotes.<kind>.list.lower.default`
/// ([`ListRule`](super::ListRule)), and the kind's title, compiled as FLM
/// text when the registry is built (a title that is not valid FLM fails the
/// build);
/// - the list's rule on the `html` backend,
/// `flm.xnotes.<kind>.list.lower.html`
/// ([`ListHtmlRule`](super::html::ListHtmlRule)), which writes the list as
/// the general rule does, with a link back from each entry to its mark;
/// - on the LaTeX side ([`latex`](super::latex)): the kind's definition piece
/// `flm.latex.def.xnotes.<kind>`
/// ([`LatexPreambleDef`](crate::stdlib::backends::latex::LatexPreambleDef),
/// a unit of LaTeX definitions that a lowering rule requires by identifier),
/// contributed as a peer to the style file's service slot; and the rule of
/// the kind's list element on the `latex-recomposed` backend, which writes
/// nothing;
/// - the peer declarations ([`PeerName`](crate::core::registry::PeerName)) of
/// every name these rules, and a rule calling
/// [`stage_latex`](super::stage_latex), use and another feature owns: the
/// table of xnotes, the numbering feature's counter table, the references
/// feature's anchors and safe-labels tables, the presentation elements, the
/// `html` and `latex-recomposed` backends and the LaTeX family's macro and
/// raw constructs. The calling feature therefore builds and renders without
/// any of those features: a rule whose backend or produced element nobody
/// declares is set aside (excluded from rule selection; see
/// [`PeerName`](crate::core::registry::PeerName)), and a rule that reads a
/// table optionally finds it absent. Where the `xnotes` feature is absent,
/// the document renders with no list placed. A feature may call the function
/// for several kinds, or declare some of these names itself: the registry
/// merges a repeated identical peer declaration into the first.
///
/// The function declares no command: an author writes xnotes only with the
/// commands the `xnotes` feature declares for the kinds of its own
/// configuration. A kind another feature creates has no command
/// (`commands: []`); its xnotes are that feature's own nodes, whose element
/// implements the [`XnoteSource`](super::XnoteSource) aspect and returns its
/// reference points with [`ref_points`](super::ref_points). For the same
/// reason the function declares no peer of the references feature's scoped
/// package of labels
/// ([`refs::LABEL_PACKAGE`](crate::stdlib::features::refs::LABEL_PACKAGE)):
/// a feature that registers an element whose argument refers to that package
/// declares the package as a peer itself
/// ([`FeatureBuilder::peer_scoped_package`]).
///
/// Two features that contribute kinds of one name fail the registry build:
/// both declare the list element of that name, and, for a numbered kind, the
/// counter of that name.
///
/// # Errors
///
/// [`BuildError::Feature`] when the kind fails [`XnoteKind::validate`]; the
/// [`BuildError`] of the registry builder when a declaration is made in a
/// [registration round](crate::core::registry::builder#the-two-registration-rounds)
/// that does not accept it (from a finalizer, for instance).
/// The counter of the numbered xnote kind `kind`: shown in the reference
/// style, numbered within the counter the kind states, with no nesting
/// joiner.
/// The reference style of the numbered xnote kind `kind`: its words, its
/// number format, no delimiters, several numbers joined compactly.
/// The mark style of the xnote kind `kind`: its mark template, no words, no
/// delimiters. A numbered kind declares it to the numbering feature; the
/// feature itself compiles an unnumbered kind's fixed mark as this style
/// (the private module `marks`), so that one template is read in one way.
pub
/// The element value of the list of the xnote kind `kind`: a block carrying
/// the kind.