File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,14 @@ pub fn (mut d Doc) stmt(mut stmt ast.Stmt, filename string) !DocNode {
242
242
}
243
243
}
244
244
}
245
+ for sa in stmt.attrs {
246
+ node.attrs[sa.name] = if sa.has_at {
247
+ '@[${sa.str()} ]'
248
+ } else {
249
+ '[${sa.str()} ]'
250
+ }
251
+ node.tags << node.attrs[sa.name]
252
+ }
245
253
}
246
254
ast.InterfaceDecl {
247
255
node.kind = .interface_
@@ -264,6 +272,14 @@ pub fn (mut d Doc) stmt(mut stmt ast.Stmt, filename string) !DocNode {
264
272
}
265
273
}
266
274
}
275
+ for sa in stmt.attrs {
276
+ node.attrs[sa.name] = if sa.has_at {
277
+ '@[${sa.str()} ]'
278
+ } else {
279
+ '[${sa.str()} ]'
280
+ }
281
+ node.tags << node.attrs[sa.name]
282
+ }
267
283
}
268
284
ast.TypeDecl {
269
285
node.kind = .typedef
Original file line number Diff line number Diff line change @@ -16,3 +16,47 @@ fn test_generate_from_mod() {
16
16
assert nested_mod_doc.contents.len == 3
17
17
assert nested_mod_doc.contents['ChunkScanner' ].children.len == 3
18
18
}
19
+
20
+ fn test_tags_with_flag_struct_attribute () {
21
+ mod_name := 'gg'
22
+ mod_doc := doc.generate_from_mod (mod_name, false , true ) or {
23
+ eprintln (err)
24
+ assert false
25
+ doc.Doc{}
26
+ }
27
+ assert mod_doc.head.name == mod_name
28
+
29
+ mouse_buttons := mod_doc.contents['MouseButtons' ]!
30
+ assert mouse_buttons.content == '@[flag]
31
+ pub enum MouseButtons {
32
+ left
33
+ right
34
+ middle
35
+ }'
36
+ assert mouse_buttons.attrs == {
37
+ 'flag' : '@[flag]'
38
+ }
39
+ assert mouse_buttons.tags == ['@[flag]' ]
40
+
41
+ end_options := mod_doc.contents['EndOptions' ]
42
+ assert end_options.content == '@[params]
43
+ pub struct EndOptions {
44
+ how EndEnum
45
+ }'
46
+ assert end_options.attrs == {
47
+ 'params' : '@[params]'
48
+ }
49
+ assert end_options.tags == ['@[params]' ]
50
+
51
+ pipeline_container := mod_doc.contents['PipelineContainer' ]
52
+ assert pipeline_container.content == '@[heap]
53
+ pub struct PipelineContainer {
54
+ pub mut:
55
+ alpha sgl.Pipeline
56
+ add sgl.Pipeline
57
+ }'
58
+ assert pipeline_container.attrs == {
59
+ 'heap' : '@[heap]'
60
+ }
61
+ assert pipeline_container.tags == ['@[heap]' ]
62
+ }
You can’t perform that action at this time.
0 commit comments