1Docstrings(3) OCaml library Docstrings(3)
2
3
4
6 Docstrings - Documentation comments
7
9 Module Docstrings
10
12 Module Docstrings
13 : sig end
14
15
16 Documentation comments
17
18 Warning: this module is unstable and part of Compiler_libs .
19
20
21
22
23
24
25 val init : unit -> unit
26
27 (Re)Initialise all docstring state
28
29
30
31 val warn_bad_docstrings : unit -> unit
32
33 Emit warnings for unattached and ambiguous docstrings
34
35
36
37
38 Docstrings
39 type docstring
40
41
42 Documentation comments
43
44
45
46 val docstring : string -> Location.t -> docstring
47
48 Create a docstring
49
50
51
52 val register : docstring -> unit
53
54 Register a docstring
55
56
57
58 val docstring_body : docstring -> string
59
60 Get the text of a docstring
61
62
63
64 val docstring_loc : docstring -> Location.t
65
66 Get the location of a docstring
67
68
69
70
71 Set functions
72 These functions are used by the lexer to associate docstrings to the
73 locations of tokens.
74
75 val set_pre_docstrings : Lexing.position -> docstring list -> unit
76
77 Docstrings immediately preceding a token
78
79
80
81 val set_post_docstrings : Lexing.position -> docstring list -> unit
82
83 Docstrings immediately following a token
84
85
86
87 val set_floating_docstrings : Lexing.position -> docstring list -> unit
88
89 Docstrings not immediately adjacent to a token
90
91
92
93 val set_pre_extra_docstrings : Lexing.position -> docstring list ->
94 unit
95
96 Docstrings immediately following the token which precedes this one
97
98
99
100 val set_post_extra_docstrings : Lexing.position -> docstring list ->
101 unit
102
103 Docstrings immediately preceding the token which follows this one
104
105
106
107
108 Items
109 The Docstrings.docs type represents documentation attached to an item.
110
111 type docs = {
112 docs_pre : docstring option ;
113 docs_post : docstring option ;
114 }
115
116
117
118
119
120 val empty_docs : docs
121
122
123
124
125 val docs_attr : docstring -> Parsetree.attribute
126
127
128
129
130 val add_docs_attrs : docs -> Parsetree.attributes -> Parsetree.at‐
131 tributes
132
133 Convert item documentation to attributes and add them to an attribute
134 list
135
136
137
138 val symbol_docs : unit -> docs
139
140 Fetch the item documentation for the current symbol. This also marks
141 this documentation (for ambiguity warnings).
142
143
144
145 val symbol_docs_lazy : unit -> docs Lazy.t
146
147
148
149
150 val rhs_docs : int -> int -> docs
151
152 Fetch the item documentation for the symbols between two positions.
153 This also marks this documentation (for ambiguity warnings).
154
155
156
157 val rhs_docs_lazy : int -> int -> docs Lazy.t
158
159
160
161
162 val mark_symbol_docs : unit -> unit
163
164 Mark the item documentation for the current symbol (for ambiguity warn‐
165 ings).
166
167
168
169 val mark_rhs_docs : int -> int -> unit
170
171 Mark as associated the item documentation for the symbols between two
172 positions (for ambiguity warnings)
173
174
175
176
177 Fields and constructors
178 The Docstrings.info type represents documentation attached to a field
179 or constructor.
180
181 type info = docstring option
182
183
184
185
186
187 val empty_info : info
188
189
190
191
192 val info_attr : docstring -> Parsetree.attribute
193
194
195
196
197 val add_info_attrs : info -> Parsetree.attributes -> Parsetree.at‐
198 tributes
199
200 Convert field info to attributes and add them to an attribute list
201
202
203
204 val symbol_info : unit -> info
205
206 Fetch the field info for the current symbol.
207
208
209
210 val rhs_info : int -> info
211
212 Fetch the field info following the symbol at a given position.
213
214
215
216
217 Unattached comments
218 The Docstrings.text type represents documentation which is not attached
219 to anything.
220
221 type text = docstring list
222
223
224
225
226
227 val empty_text : text
228
229
230
231
232 val empty_text_lazy : text Lazy.t
233
234
235
236
237 val text_attr : docstring -> Parsetree.attribute
238
239
240
241
242 val add_text_attrs : text -> Parsetree.attributes -> Parsetree.at‐
243 tributes
244
245 Convert text to attributes and add them to an attribute list
246
247
248
249 val symbol_text : unit -> text
250
251 Fetch the text preceding the current symbol.
252
253
254
255 val symbol_text_lazy : unit -> text Lazy.t
256
257
258
259
260 val rhs_text : int -> text
261
262 Fetch the text preceding the symbol at the given position.
263
264
265
266 val rhs_text_lazy : int -> text Lazy.t
267
268
269
270
271
272 Extra text
273 There may be additional text attached to the delimiters of a block
274 (e.g. struct and end ). This is fetched by the following functions,
275 which are applied to the contents of the block rather than the delim‐
276 iters.
277
278 val symbol_pre_extra_text : unit -> text
279
280 Fetch additional text preceding the current symbol
281
282
283
284 val symbol_post_extra_text : unit -> text
285
286 Fetch additional text following the current symbol
287
288
289
290 val rhs_pre_extra_text : int -> text
291
292 Fetch additional text preceding the symbol at the given position
293
294
295
296 val rhs_post_extra_text : int -> text
297
298 Fetch additional text following the symbol at the given position
299
300
301
302 val rhs_post_text : int -> text
303
304 Fetch text following the symbol at the given position
305
306
307 module WithMenhir : sig end
308
309
310
311
312
313
314
315OCamldoc 2021-07-22 Docstrings(3)