alpha
Login
or
Join now
nandi.uk
/
gleam
Star
2
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Fork of daniellemaywood.uk/gleam — Wasm codegen work
Star
2
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Print links to types in documentation
author
GearsDatapacks
committer
Louis Pilfold
date
1 year ago
(May 12, 2025, 10:29 AM +0100)
commit
fdd78398
fdd78398ccb5dbee5913535329f1ae4fff6eba60
parent
0186fa96
0186fa96f44e0561bc25f7ab05e739a1134d6a4a
+211
-95
16 changed files
Expand all
Collapse all
Unified
Split
compiler-core
src
docs
printer.rs
snapshots
gleam_core__docs__tests__canonical_link.snap
gleam_core__docs__tests__discarded_arguments_are_not_shown.snap
gleam_core__docs__tests__docs_of_a_type_constructor_are_not_used_by_the_following_function.snap
gleam_core__docs__tests__hello_docs.snap
gleam_core__docs__tests__ignored_argument_is_called_arg.snap
gleam_core__docs__tests__internal_definitions_are_not_included.snap
gleam_core__docs__tests__long_function_wrapping.snap
gleam_core__docs__tests__markdown_code_from_function_comment_is_trimmed.snap
gleam_core__docs__tests__markdown_code_from_module_comment_is_trimmed.snap
gleam_core__docs__tests__markdown_code_from_standalone_pages_is_not_trimmed.snap
gleam_core__docs__tests__no_hex_publish.snap
gleam_core__docs__tests__tables.snap
docs.rs
templates
documentation_layout.html
documentation_module.html
+10
-21
compiler-core/src/docs.rs
View file
Reviewed
···
153
153
type_: SearchItemType::Page,
154
154
parent_title: config.name.to_string(),
155
155
title: config.name.to_string(),
156
156
-
content,
156
156
+
content: escape_html_content(content),
157
157
reference: page.path.to_string(),
158
158
})
159
159
}
···
170
170
let rendered_documentation =
171
171
render_markdown(&documentation_content.clone(), MarkdownSource::Comment);
172
172
173
173
-
let mut printer = Printer::new(&module.ast.names);
173
173
+
let mut printer = Printer::new(
174
174
+
module.ast.type_info.package.clone(),
175
175
+
module.name.clone(),
176
176
+
&module.ast.names,
177
177
+
);
174
178
175
179
let types: Vec<TypeDefinition<'_>> = module
176
180
.ast
177
181
.definitions
178
182
.iter()
179
179
-
.filter(|statement| !statement.is_internal())
180
180
-
.flat_map(|statement| printer.type_definition(&source_links, statement))
183
183
+
.filter_map(|statement| printer.type_definition(&source_links, statement))
181
184
.sorted()
182
185
.collect();
183
186
···
185
188
.ast
186
189
.definitions
187
190
.iter()
188
188
-
.filter(|statement| !statement.is_internal())
189
189
-
.flat_map(|statement| printer.value(&source_links, statement))
191
191
+
.filter_map(|statement| printer.value(&source_links, statement))
190
192
.sorted()
191
193
.collect();
192
194
···
351
353
});
352
354
353
355
let search_data_json = serde_to_string(&SearchData {
354
354
-
items: escape_html_contents(search_items),
356
356
+
items: search_items,
355
357
programming_language: SearchProgrammingLanguage::Gleam,
356
358
})
357
359
.expect("search index serialization");
···
518
520
);
519
521
}
520
522
521
521
-
fn escape_html_contents(indexes: Vec<SearchItem>) -> Vec<SearchItem> {
522
522
-
indexes
523
523
-
.into_iter()
524
524
-
.map(|idx| SearchItem {
525
525
-
type_: idx.type_,
526
526
-
parent_title: idx.parent_title,
527
527
-
title: idx.title,
528
528
-
content: escape_html_content(idx.content),
529
529
-
reference: idx.reference,
530
530
-
})
531
531
-
.collect::<Vec<SearchItem>>()
532
532
-
}
533
533
-
534
523
fn import_synonyms(parent: &str, child: &str) -> String {
535
524
format!("Synonyms:\n{parent}.{child}\n{parent} {child}")
536
525
}
···
542
531
.unwrap_or_else(|| "".into());
543
532
544
533
// TODO: parse markdown properly and extract the text nodes
545
545
-
raw_text.replace("```gleam", "").replace("```", "")
534
534
+
escape_html_content(raw_text.replace("```gleam", "").replace("```", ""))
546
535
}
547
536
548
537
fn markdown_documentation(doc: &Option<(u32, EcoString)>) -> String {
+125
-49
compiler-core/src/docs/printer.rs
View file
Reviewed
···
3
3
ops::Deref,
4
4
};
5
5
6
6
-
use ecow::EcoString;
6
6
+
use ecow::{EcoString, eco_format};
7
7
use itertools::Itertools;
8
8
9
9
use crate::{
···
13
13
TypedRecordConstructor,
14
14
},
15
15
docvec,
16
16
-
pretty::{Document, Documentable, break_, join, line, nil},
17
17
-
type_::{Deprecation, Type, TypeVar, printer::Names},
16
16
+
pretty::{Document, Documentable, break_, join, line, nil, zero_width_string},
17
17
+
type_::{
18
18
+
Deprecation, PRELUDE_MODULE_NAME, PRELUDE_PACKAGE_NAME, Type, TypeVar, printer::Names,
19
19
+
},
18
20
};
19
21
20
22
use super::{
···
24
26
25
27
pub struct Printer<'a> {
26
28
names: &'a Names,
29
29
+
package: EcoString,
30
30
+
module: EcoString,
27
31
printed_type_variables: HashMap<u64, EcoString>,
28
32
printed_type_variable_names: HashSet<EcoString>,
29
33
uid: u64,
30
34
}
31
35
32
36
impl Printer<'_> {
33
33
-
pub fn new<'a>(names: &'a Names) -> Printer<'a> {
37
37
+
pub fn new<'a>(package: EcoString, module: EcoString, names: &'a Names) -> Printer<'a> {
34
38
Printer {
35
39
names,
40
40
+
package,
41
41
+
module,
36
42
printed_type_variables: HashMap::new(),
37
43
printed_type_variable_names: HashSet::new(),
38
44
uid: 0,
···
64
70
Deprecation::NotDeprecated => "".to_string(),
65
71
Deprecation::Deprecated { message } => message.to_string(),
66
72
},
67
67
-
constructors: constructors
68
68
-
.iter()
69
69
-
.map(|constructor| TypeConstructor {
70
70
-
definition: print(self.record_constructor(constructor)),
71
71
-
documentation: markdown_documentation(&constructor.documentation),
72
72
-
text_documentation: text_documentation(&constructor.documentation),
73
73
-
arguments: constructor
74
74
-
.arguments
75
75
-
.iter()
76
76
-
.filter_map(|arg| arg.label.as_ref().map(|(_, label)| (arg, label)))
77
77
-
.map(|(argument, label)| TypeConstructorArg {
78
78
-
name: label.trim_end().to_string(),
79
79
-
doc: markdown_documentation(&argument.doc),
80
80
-
})
81
81
-
.filter(|arg| !arg.doc.is_empty())
82
82
-
.collect(),
83
83
-
})
84
84
-
.collect(),
73
73
+
constructors: if *opaque {
74
74
+
Vec::new()
75
75
+
} else {
76
76
+
constructors
77
77
+
.iter()
78
78
+
.map(|constructor| TypeConstructor {
79
79
+
definition: print(self.record_constructor(constructor)),
80
80
+
documentation: markdown_documentation(&constructor.documentation),
81
81
+
text_documentation: text_documentation(&constructor.documentation),
82
82
+
arguments: constructor
83
83
+
.arguments
84
84
+
.iter()
85
85
+
.filter_map(|arg| arg.label.as_ref().map(|(_, label)| (arg, label)))
86
86
+
.map(|(argument, label)| TypeConstructorArg {
87
87
+
name: label.trim_end().to_string(),
88
88
+
doc: markdown_documentation(&argument.doc),
89
89
+
})
90
90
+
.filter(|arg| !arg.doc.is_empty())
91
91
+
.collect(),
92
92
+
})
93
93
+
.collect()
94
94
+
},
85
95
source_url: source_links.url(*location),
86
96
opaque: *opaque,
87
97
}),
···
174
184
let arguments = if parameters.is_empty() {
175
185
nil()
176
186
} else {
177
177
-
Self::wrap_arguments(parameters.iter().map(|(_, parameter)| parameter.to_doc()))
187
187
+
Self::wrap_arguments(
188
188
+
parameters
189
189
+
.iter()
190
190
+
.map(|(_, parameter)| self.variable(parameter)),
191
191
+
)
178
192
};
179
193
180
194
let keywords = if opaque { "opaque type " } else { "type " };
181
195
182
182
-
let type_head = docvec!["pub ", keywords, name, arguments];
196
196
+
let type_head = docvec![
197
197
+
self.keyword("pub "),
198
198
+
self.keyword(keywords),
199
199
+
self.title(name),
200
200
+
arguments
201
201
+
];
183
202
184
184
-
if constructors.is_empty() {
203
203
+
if constructors.is_empty() || opaque {
185
204
return type_head;
186
205
}
187
206
···
202
221
constructor: &'a TypedRecordConstructor,
203
222
) -> Document<'a> {
204
223
if constructor.arguments.is_empty() {
205
205
-
return constructor.name.as_str().to_doc();
224
224
+
return self.title(&constructor.name);
206
225
}
207
226
208
227
let arguments = constructor.arguments.iter().map(
209
228
|RecordConstructorArg { label, type_, .. }| match label {
210
210
-
Some((_, label)) => label.to_doc().append(": ").append(self.type_(type_)),
229
229
+
Some((_, label)) => self.variable(label).append(": ").append(self.type_(type_)),
211
230
None => self.type_(type_),
212
231
},
213
232
);
214
233
215
215
-
constructor
216
216
-
.name
217
217
-
.as_str()
218
218
-
.to_doc()
219
219
-
.append(Self::wrap_arguments(arguments))
234
234
+
let arguments = Self::wrap_arguments(arguments);
235
235
+
236
236
+
docvec![self.title(&constructor.name), arguments]
220
237
}
221
238
222
239
fn type_alias<'a>(
···
228
245
let parameters = if parameters.is_empty() {
229
246
nil()
230
247
} else {
231
231
-
let arguments = parameters.iter().map(|(_, parameter)| parameter.to_doc());
248
248
+
let arguments = parameters
249
249
+
.iter()
250
250
+
.map(|(_, parameter)| self.variable(parameter));
232
251
Self::wrap_arguments(arguments)
233
252
};
234
253
235
254
docvec![
236
236
-
"pub type ",
237
237
-
name,
255
255
+
self.keyword("pub type "),
256
256
+
self.title(name),
238
257
parameters,
239
258
break_(" =", " = "),
240
259
self.type_(type_).nest(INDENT)
···
242
261
}
243
262
244
263
fn constant<'a>(&mut self, name: &'a str, type_: &Type) -> Document<'a> {
245
245
-
docvec!["pub const ", name, ": ", self.type_(type_)]
264
264
+
docvec![
265
265
+
self.keyword("pub const "),
266
266
+
self.title(name),
267
267
+
": ",
268
268
+
self.type_(type_)
269
269
+
]
246
270
}
247
271
248
272
fn function_signature<'a>(
···
252
276
return_type: &Type,
253
277
) -> Document<'a> {
254
278
let arguments = arguments.iter().map(|argument| {
255
255
-
let name = self.argument_name(argument);
279
279
+
let name = self.variable(self.argument_name(argument));
256
280
docvec![name, ": ", self.type_(&argument.type_)].group()
257
281
});
282
282
+
let arguments = Self::wrap_arguments(arguments);
258
283
259
284
docvec![
260
260
-
"pub fn ",
261
261
-
name,
262
262
-
Self::wrap_arguments(arguments),
285
285
+
self.keyword("pub fn "),
286
286
+
self.title(name),
287
287
+
arguments,
263
288
" -> ",
264
289
self.type_(return_type)
265
290
]
···
301
326
302
327
fn type_(&mut self, type_: &Type) -> Document<'static> {
303
328
match type_ {
304
304
-
Type::Named { name, args, .. } => {
329
329
+
Type::Named {
330
330
+
package,
331
331
+
module,
332
332
+
name,
333
333
+
args,
334
334
+
..
335
335
+
} => {
336
336
+
let name = self.named_type_name(package, module, name);
305
337
if args.is_empty() {
306
306
-
name.clone().to_doc()
338
338
+
name
307
339
} else {
308
308
-
name.clone().to_doc().append(Self::type_arguments(
340
340
+
name.append(Self::type_arguments(
309
341
args.iter().map(|argument| self.type_(argument)),
310
342
))
311
343
}
312
344
}
313
345
Type::Fn { args, return_ } => docvec![
314
314
-
"fn",
346
346
+
self.keyword("fn"),
315
347
Self::type_arguments(args.iter().map(|argument| self.type_(argument))),
316
348
" -> ",
317
349
self.type_(return_)
···
323
355
Type::Var { type_ } => match type_.as_ref().borrow().deref() {
324
356
TypeVar::Link { type_ } => self.type_(type_),
325
357
326
326
-
TypeVar::Unbound { id } | TypeVar::Generic { id } => self.type_variable(*id),
358
358
+
TypeVar::Unbound { id } | TypeVar::Generic { id } => {
359
359
+
let name = self.type_variable(*id);
360
360
+
self.variable(name)
361
361
+
}
327
362
},
328
363
}
329
364
}
330
365
331
331
-
fn type_variable(&mut self, id: u64) -> Document<'static> {
366
366
+
fn type_variable(&mut self, id: u64) -> EcoString {
332
367
if let Some(name) = self.names.get_type_variable(id) {
333
333
-
return name.clone().to_doc();
368
368
+
return name.clone();
334
369
}
335
370
336
371
if let Some(name) = self.printed_type_variables.get(&id) {
337
337
-
return name.clone().to_doc();
372
372
+
return name.clone();
338
373
}
339
374
340
375
loop {
···
342
377
if !self.printed_type_variable_names.contains(&name) {
343
378
_ = self.printed_type_variable_names.insert(name.clone());
344
379
_ = self.printed_type_variables.insert(id, name.clone());
345
345
-
return name.to_doc();
380
380
+
return name;
346
381
}
382
382
+
}
383
383
+
}
384
384
+
385
385
+
fn named_type_name(&self, package: &str, module: &str, name: &EcoString) -> Document<'static> {
386
386
+
if package == PRELUDE_PACKAGE_NAME && module == PRELUDE_MODULE_NAME {
387
387
+
self.title(name)
388
388
+
} else if package == self.package && module == self.module {
389
389
+
self.link(eco_format!("#{name}"), self.title(name))
390
390
+
} else {
391
391
+
self.link(
392
392
+
eco_format!("https://hexdocs.pm/{package}/{module}.html#{name}"),
393
393
+
self.title(name),
394
394
+
)
347
395
}
348
396
}
349
397
···
367
415
368
416
self.uid += 1;
369
417
chars.into_iter().rev().collect()
418
418
+
}
419
419
+
420
420
+
fn keyword<'a>(&self, keyword: impl Documentable<'a>) -> Document<'a> {
421
421
+
keyword.to_doc().surround(
422
422
+
zero_width_string(r#"<span class="hljs-keyword">"#.into()),
423
423
+
zero_width_string("</span>".into()),
424
424
+
)
425
425
+
}
426
426
+
427
427
+
fn title<'a>(&self, name: impl Documentable<'a>) -> Document<'a> {
428
428
+
name.to_doc().surround(
429
429
+
zero_width_string(r#"<span class="hljs-title">"#.into()),
430
430
+
zero_width_string("</span>".into()),
431
431
+
)
432
432
+
}
433
433
+
434
434
+
fn variable<'a>(&self, name: impl Documentable<'a>) -> Document<'a> {
435
435
+
name.to_doc().surround(
436
436
+
zero_width_string(r#"<span class="hljs-variable">"#.into()),
437
437
+
zero_width_string("</span>".into()),
438
438
+
)
439
439
+
}
440
440
+
441
441
+
fn link<'a>(&self, href: EcoString, name: impl Documentable<'a>) -> Document<'a> {
442
442
+
name.to_doc().surround(
443
443
+
zero_width_string(eco_format!(r#"<a href="{href}">"#)),
444
444
+
zero_width_string("</a>".into()),
445
445
+
)
370
446
}
371
447
}
372
448
+11
-2
compiler-core/src/docs/snapshots/gleam_core__docs__tests__canonical_link.snap
View file
Reviewed
···
311
311
elem.classList.add("gleam");
312
312
}
313
313
});
314
314
+
hljs.configure({
315
315
+
cssSelector: 'pre code:not(.hljs-ignore)'
316
316
+
})
314
317
hljs.highlightAll();
315
318
</script>
316
319
···
595
598
596
599
</div>
597
600
598
598
-
<pre><code class="hljs gleam">pub fn one() -> Int</code></pre>
601
601
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre>
599
602
600
603
<div class="rendered-markdown"><p>Here is some documentation</p>
601
604
</div>
···
675
678
elem.classList.add("gleam");
676
679
}
677
680
});
681
681
+
hljs.configure({
682
682
+
cssSelector: 'pre code:not(.hljs-ignore)'
683
683
+
})
678
684
hljs.highlightAll();
679
685
</script>
680
686
···
959
965
960
966
</div>
961
967
962
962
-
<pre><code class="hljs gleam">pub fn one() -> Int</code></pre>
968
968
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre>
963
969
964
970
<div class="rendered-markdown"><p>Here is some documentation</p>
965
971
</div>
···
1039
1045
elem.classList.add("gleam");
1040
1046
}
1041
1047
});
1048
1048
+
hljs.configure({
1049
1049
+
cssSelector: 'pre code:not(.hljs-ignore)'
1050
1050
+
})
1042
1051
hljs.highlightAll();
1043
1052
</script>
1044
1053
+4
-1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__discarded_arguments_are_not_shown.snap
View file
Reviewed
···
264
264
265
265
</div>
266
266
267
267
-
<pre><code class="hljs gleam">pub fn discard(discarded: a) -> Int</code></pre>
267
267
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">discard</span>(<span class="hljs-variable">discarded</span>: <span class="hljs-variable">a</span>) -> <span class="hljs-title">Int</span></code></pre>
268
268
269
269
<div class="rendered-markdown"></div>
270
270
</div>
···
343
343
elem.classList.add("gleam");
344
344
}
345
345
});
346
346
+
hljs.configure({
347
347
+
cssSelector: 'pre code:not(.hljs-ignore)'
348
348
+
})
346
349
hljs.highlightAll();
347
350
</script>
348
351
+7
-4
compiler-core/src/docs/snapshots/gleam_core__docs__tests__docs_of_a_type_constructor_are_not_used_by_the_following_function.snap
View file
Reviewed
···
272
272
273
273
<div class="custom-type-constructors">
274
274
<div class="rendered-markdown"></div>
275
275
-
<pre><code class="hljs gleam">pub type Wibble {
276
276
-
Wobble(wabble: Int)
275
275
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub </span><span class="hljs-keyword">type </span><span class="hljs-title">Wibble</span> {
276
276
+
<span class="hljs-title">Wobble</span>(<span class="hljs-variable">wabble</span>: <span class="hljs-title">Int</span>)
277
277
}</code></pre>
278
278
279
279
<h3>
···
284
284
<li class="constructor-item">
285
285
<div class="constructor-row">
286
286
<svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg>
287
287
-
<pre class="constructor-name"><code class="hljs gleam">Wobble(wabble: Int)</code></pre>
287
287
+
<pre class="constructor-name"><code class="hljs gleam hljs-ignore"><span class="hljs-title">Wobble</span>(<span class="hljs-variable">wabble</span>: <span class="hljs-title">Int</span>)</code></pre>
288
288
</div>
289
289
290
290
<div class="constructor-item-docs">
···
335
335
336
336
</div>
337
337
338
338
-
<pre><code class="hljs gleam">pub fn main() -> a</code></pre>
338
338
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">main</span>() -> <span class="hljs-variable">a</span></code></pre>
339
339
340
340
<div class="rendered-markdown"></div>
341
341
</div>
···
414
414
elem.classList.add("gleam");
415
415
}
416
416
});
417
417
+
hljs.configure({
418
418
+
cssSelector: 'pre code:not(.hljs-ignore)'
419
419
+
})
417
420
hljs.highlightAll();
418
421
</script>
419
422
+4
-1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__hello_docs.snap
View file
Reviewed
···
264
264
265
265
</div>
266
266
267
267
-
<pre><code class="hljs gleam">pub fn one() -> Int</code></pre>
267
267
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre>
268
268
269
269
<div class="rendered-markdown"><p>Here is some documentation</p>
270
270
</div>
···
344
344
elem.classList.add("gleam");
345
345
}
346
346
});
347
347
+
hljs.configure({
348
348
+
cssSelector: 'pre code:not(.hljs-ignore)'
349
349
+
})
347
350
hljs.highlightAll();
348
351
</script>
349
352
+4
-1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__ignored_argument_is_called_arg.snap
View file
Reviewed
···
264
264
265
265
</div>
266
266
267
267
-
<pre><code class="hljs gleam">pub fn one(arg: a) -> Int</code></pre>
267
267
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>(<span class="hljs-variable">arg</span>: <span class="hljs-variable">a</span>) -> <span class="hljs-title">Int</span></code></pre>
268
268
269
269
<div class="rendered-markdown"></div>
270
270
</div>
···
343
343
elem.classList.add("gleam");
344
344
}
345
345
});
346
346
+
hljs.configure({
347
347
+
cssSelector: 'pre code:not(.hljs-ignore)'
348
348
+
})
346
349
hljs.highlightAll();
347
350
</script>
348
351
+3
compiler-core/src/docs/snapshots/gleam_core__docs__tests__internal_definitions_are_not_included.snap
View file
Reviewed
···
313
313
elem.classList.add("gleam");
314
314
}
315
315
});
316
316
+
hljs.configure({
317
317
+
cssSelector: 'pre code:not(.hljs-ignore)'
318
318
+
})
316
319
hljs.highlightAll();
317
320
</script>
318
321
+12
-9
compiler-core/src/docs/snapshots/gleam_core__docs__tests__long_function_wrapping.snap
View file
Reviewed
···
272
272
273
273
<div class="custom-type-constructors">
274
274
<div class="rendered-markdown"></div>
275
275
-
<pre><code class="hljs gleam">pub type Option(t) {
276
276
-
Some(t)
277
277
-
None
275
275
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub </span><span class="hljs-keyword">type </span><span class="hljs-title">Option</span>(<span class="hljs-variable">t</span>) {
276
276
+
<span class="hljs-title">Some</span>(<span class="hljs-variable">t</span>)
277
277
+
<span class="hljs-title">None</span>
278
278
}</code></pre>
279
279
280
280
<h3>
···
285
285
<li class="constructor-item">
286
286
<div class="constructor-row">
287
287
<svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg>
288
288
-
<pre class="constructor-name"><code class="hljs gleam">Some(t)</code></pre>
288
288
+
<pre class="constructor-name"><code class="hljs gleam hljs-ignore"><span class="hljs-title">Some</span>(<span class="hljs-variable">t</span>)</code></pre>
289
289
</div>
290
290
291
291
<div class="constructor-item-docs">
···
298
298
<li class="constructor-item">
299
299
<div class="constructor-row">
300
300
<svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg>
301
301
-
<pre class="constructor-name"><code class="hljs gleam">None</code></pre>
301
301
+
<pre class="constructor-name"><code class="hljs gleam hljs-ignore"><span class="hljs-title">None</span></code></pre>
302
302
</div>
303
303
304
304
<div class="constructor-item-docs">
···
333
333
334
334
</div>
335
335
336
336
-
<pre><code class="hljs gleam">pub fn lazy_or(
337
337
-
first: Option(a),
338
338
-
second: fn() -> Option(a),
339
339
-
) -> Option(a)</code></pre>
336
336
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">lazy_or</span>(
337
337
+
<span class="hljs-variable">first</span>: <a href="#Option"><span class="hljs-title">Option</span></a>(<span class="hljs-variable">a</span>),
338
338
+
<span class="hljs-variable">second</span>: <span class="hljs-keyword">fn</span>() -> <a href="#Option"><span class="hljs-title">Option</span></a>(<span class="hljs-variable">a</span>),
339
339
+
) -> <a href="#Option"><span class="hljs-title">Option</span></a>(<span class="hljs-variable">a</span>)</code></pre>
340
340
341
341
<div class="rendered-markdown"><p>Returns the first value if it is <code>Some</code>, otherwise evaluates the given
342
342
function for a fallback value.</p>
···
417
417
elem.classList.add("gleam");
418
418
}
419
419
});
420
420
+
hljs.configure({
421
421
+
cssSelector: 'pre code:not(.hljs-ignore)'
422
422
+
})
420
423
hljs.highlightAll();
421
424
</script>
422
425
+4
-1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__markdown_code_from_function_comment_is_trimmed.snap
View file
Reviewed
···
264
264
265
265
</div>
266
266
267
267
-
<pre><code class="hljs gleam">pub fn indentation_test() -> a</code></pre>
267
267
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">indentation_test</span>() -> <span class="hljs-variable">a</span></code></pre>
268
268
269
269
<div class="rendered-markdown"><p>Here’s an example code snippet:</p>
270
270
<pre><code>wibble
···
347
347
elem.classList.add("gleam");
348
348
}
349
349
});
350
350
+
hljs.configure({
351
351
+
cssSelector: 'pre code:not(.hljs-ignore)'
352
352
+
})
350
353
hljs.highlightAll();
351
354
</script>
352
355
+3
compiler-core/src/docs/snapshots/gleam_core__docs__tests__markdown_code_from_module_comment_is_trimmed.snap
View file
Reviewed
···
317
317
elem.classList.add("gleam");
318
318
}
319
319
});
320
320
+
hljs.configure({
321
321
+
cssSelector: 'pre code:not(.hljs-ignore)'
322
322
+
})
320
323
hljs.highlightAll();
321
324
</script>
322
325
+3
compiler-core/src/docs/snapshots/gleam_core__docs__tests__markdown_code_from_standalone_pages_is_not_trimmed.snap
View file
Reviewed
···
311
311
elem.classList.add("gleam");
312
312
}
313
313
});
314
314
+
hljs.configure({
315
315
+
cssSelector: 'pre code:not(.hljs-ignore)'
316
316
+
})
314
317
hljs.highlightAll();
315
318
</script>
316
319
+11
-2
compiler-core/src/docs/snapshots/gleam_core__docs__tests__no_hex_publish.snap
View file
Reviewed
···
304
304
elem.classList.add("gleam");
305
305
}
306
306
});
307
307
+
hljs.configure({
308
308
+
cssSelector: 'pre code:not(.hljs-ignore)'
309
309
+
})
307
310
hljs.highlightAll();
308
311
</script>
309
312
···
581
584
582
585
</div>
583
586
584
584
-
<pre><code class="hljs gleam">pub fn one() -> Int</code></pre>
587
587
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre>
585
588
586
589
<div class="rendered-markdown"><p>Here is some documentation</p>
587
590
</div>
···
661
664
elem.classList.add("gleam");
662
665
}
663
666
});
667
667
+
hljs.configure({
668
668
+
cssSelector: 'pre code:not(.hljs-ignore)'
669
669
+
})
664
670
hljs.highlightAll();
665
671
</script>
666
672
···
938
944
939
945
</div>
940
946
941
941
-
<pre><code class="hljs gleam">pub fn one() -> Int</code></pre>
947
947
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre>
942
948
943
949
<div class="rendered-markdown"><p>Here is some documentation</p>
944
950
</div>
···
1018
1024
elem.classList.add("gleam");
1019
1025
}
1020
1026
});
1027
1027
+
hljs.configure({
1028
1028
+
cssSelector: 'pre code:not(.hljs-ignore)'
1029
1029
+
})
1021
1030
hljs.highlightAll();
1022
1031
</script>
1023
1032
+4
-1
compiler-core/src/docs/snapshots/gleam_core__docs__tests__tables.snap
View file
Reviewed
···
264
264
265
265
</div>
266
266
267
267
-
<pre><code class="hljs gleam">pub fn one() -> Int</code></pre>
267
267
+
<pre><code class="hljs gleam hljs-ignore"><span class="hljs-keyword">pub fn </span><span class="hljs-title">one</span>() -> <span class="hljs-title">Int</span></code></pre>
268
268
269
269
<div class="rendered-markdown"><table><thead><tr><th>heading 1</th><th>heading 2</th></tr></thead><tbody>
270
270
<tr><td>row 1 cell 1</td><td>row 1 cell 2</td></tr>
···
347
347
elem.classList.add("gleam");
348
348
}
349
349
});
350
350
+
hljs.configure({
351
351
+
cssSelector: 'pre code:not(.hljs-ignore)'
352
352
+
})
350
353
hljs.highlightAll();
351
354
</script>
352
355
+3
compiler-core/templates/documentation_layout.html
View file
Reviewed
···
300
300
elem.classList.add("gleam");
301
301
}
302
302
});
303
303
+
hljs.configure({
304
304
+
cssSelector: 'pre code:not(.hljs-ignore)'
305
305
+
})
303
306
hljs.highlightAll();
304
307
</script>
305
308
+3
-3
compiler-core/templates/documentation_module.html
View file
Reviewed
···
55
55
{% endif %}
56
56
<div class="custom-type-constructors">
57
57
<div class="rendered-markdown">{{ typ.documentation|safe }}</div>
58
58
-
<pre><code class="hljs gleam">{{ typ.definition }}</code></pre>
58
58
+
<pre><code class="hljs gleam hljs-ignore">{{ typ.definition|safe }}</code></pre>
59
59
{% if !typ.constructors.is_empty() %}
60
60
<h3>
61
61
Constructors
···
65
65
<li class="constructor-item">
66
66
<div class="constructor-row">
67
67
<svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg>
68
68
-
<pre class="constructor-name"><code class="hljs gleam">{{ constructor.definition }}</code></pre>
68
68
+
<pre class="constructor-name"><code class="hljs gleam hljs-ignore">{{ constructor.definition|safe }}</code></pre>
69
69
</div>
70
70
71
71
<div class="constructor-item-docs">
···
119
119
{% endif %}
120
120
</div>
121
121
122
122
-
<pre><code class="hljs gleam">{{ value.definition }}</code></pre>
122
122
+
<pre><code class="hljs gleam hljs-ignore">{{ value.definition|safe }}</code></pre>
123
123
{% if !value.deprecation_message.is_empty() %}
124
124
<p>
125
125
<b>Deprecated:</b> {{ value.deprecation_message }}