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
19
20
21
22
23 val init : unit -> unit
24
25 (Re)Initialise all docstring state
26
27
28
29 val warn_bad_docstrings : unit -> unit
30
31 Emit warnings for unattached and ambiguous docstrings
32
33
34
35
36 === Docstrings ===
37
38
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 These functions are used by the lexer to associate
72 docstrings to the locations of tokens. ===
73
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 The Docstrings.docs type represents documentation attached to
109 an item. ===
110
111
112 type docs = {
113 docs_pre : docstring option ;
114 docs_post : docstring option ;
115 }
116
117
118
119
120
121 val empty_docs : docs
122
123
124
125
126 val docs_attr : docstring -> Parsetree.attribute
127
128
129
130
131 val add_docs_attrs : docs -> Parsetree.attributes -> Parse‐
132 tree.attributes
133
134 Convert item documentation to attributes and add them to an attribute
135 list
136
137
138
139 val symbol_docs : unit -> docs
140
141 Fetch the item documentation for the current symbol. This also marks
142 this documentation (for ambiguity warnings).
143
144
145
146 val symbol_docs_lazy : unit -> docs Lazy.t
147
148
149
150
151 val rhs_docs : int -> int -> docs
152
153 Fetch the item documentation for the symbols between two positions.
154 This also marks this documentation (for ambiguity warnings).
155
156
157
158 val rhs_docs_lazy : int -> int -> docs Lazy.t
159
160
161
162
163 val mark_symbol_docs : unit -> unit
164
165 Mark the item documentation for the current symbol (for ambiguity warn‐
166 ings).
167
168
169
170 val mark_rhs_docs : int -> int -> unit
171
172 Mark as associated the item documentation for the symbols between two
173 positions (for ambiguity warnings)
174
175
176
177
178 === Fields and constructors The Docstrings.info type represents docu‐
179 mentation attached to a field or constructor. ===
180
181
182 type info = docstring option
183
184
185
186
187
188 val empty_info : info
189
190
191
192
193 val info_attr : docstring -> Parsetree.attribute
194
195
196
197
198 val add_info_attrs : info -> Parsetree.attributes -> Parse‐
199 tree.attributes
200
201 Convert field info to attributes and add them to an attribute list
202
203
204
205 val symbol_info : unit -> info
206
207 Fetch the field info for the current symbol.
208
209
210
211 val rhs_info : int -> info
212
213 Fetch the field info following the symbol at a given position.
214
215
216
217
218 === Unattached comments The Docstrings.text type represents documenta‐
219 tion which is not attached to anything. ===
220
221
222 type text = docstring list
223
224
225
226
227
228 val empty_text : text
229
230
231
232
233 val empty_text_lazy : text Lazy.t
234
235
236
237
238 val text_attr : docstring -> Parsetree.attribute
239
240
241
242
243 val add_text_attrs : text -> Parsetree.attributes -> Parse‐
244 tree.attributes
245
246 Convert text to attributes and add them to an attribute list
247
248
249
250 val symbol_text : unit -> text
251
252 Fetch the text preceding the current symbol.
253
254
255
256 val symbol_text_lazy : unit -> text Lazy.t
257
258
259
260
261 val rhs_text : int -> text
262
263 Fetch the text preceding the symbol at the given position.
264
265
266
267 val rhs_text_lazy : int -> text Lazy.t
268
269
270
271
272
273 === Extra text There may be additional text attached to the delimiters
274 of a block (e.g. struct and end). This is fetched by the following
275 functions, which are applied to the contents of the block rather than
276 the delimiters. ===
277
278
279 val symbol_pre_extra_text : unit -> text
280
281 Fetch additional text preceding the current symbol
282
283
284
285 val symbol_post_extra_text : unit -> text
286
287 Fetch additional text following the current symbol
288
289
290
291 val rhs_pre_extra_text : int -> text
292
293 Fetch additional text preceding the symbol at the given position
294
295
296
297 val rhs_post_extra_text : int -> text
298
299 Fetch additional text following the symbol at the given position
300
301
302
303 val rhs_post_text : int -> text
304
305 Fetch text following the symbol at the given position
306
307
308
309
310
311OCamldoc 2019-02-02 Docstrings(3)