You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This adds support for associating a language for `---@usage` tag which
defaults to `lua` for every code block unless explicitly defined using
the syntax below.
#### Emmylua
- Single line
```lua
---@Usage [lang] `<code>`
```
- Multiline
```lua
---@Usage [lang] [[
---
---@Usage ]]
```
#### Help (vimdoc)
```help
>{lang}
code...
<
```
Copy file name to clipboardExpand all lines: emmylua.md
+88-27Lines changed: 88 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -186,9 +186,9 @@ U:create() *U:create*
186
186
{Human}
187
187
188
188
Usage: ~
189
-
>
190
-
require('Human'):create()
191
-
<
189
+
>lua
190
+
require('Human'):create()
191
+
<
192
192
```
193
193
194
194
### Table of Contents
@@ -291,7 +291,7 @@ This tag can be used to add a divider/separator between section or anything you
291
291
292
292
### Functions
293
293
294
-
A function contains multiple tags which form its structure. Like `---@param` for parameter, `---@return` for the return value, `---@see` for other related things and `---@usage` for example
294
+
A function contains multiple tags which form its structure. Like `---@param` for parameter, `---@return` for the return value, `---@see` for other related things and [`---@usage`](#usage) for example
295
295
296
296
- Syntax
297
297
@@ -305,19 +305,7 @@ A function contains multiple tags which form its structure. Like `---@param` for
305
305
---@usage `<code>`
306
306
```
307
307
308
-
> NOTE:
309
-
>
310
-
> 1. All tag can be used multiple times except `---@usage`
311
-
>
312
-
> 2.`---@usage` tag also has a multiline syntax
313
-
>
314
-
> ```lua
315
-
>---@usage [[
316
-
>---TEXT
317
-
>---TEXT
318
-
>---TEXT
319
-
>---@usage ]]
320
-
>```
308
+
> NOTE: All tag can be used multiple times except `---@usage`
This tag is used to show code usage of functions and [`---@type`](#type). Code inside `---@usage` will be rendered as codeblock. Optionally, a `lang` can be provided to get syntax highlighting (defaults to `lua`).
586
+
587
+
- Syntax
588
+
589
+
1. Single-line
590
+
591
+
```lua
592
+
---@usage [lang] `<code>`
593
+
```
594
+
595
+
2. Multi-line
596
+
597
+
```lua
598
+
---@usage [lang] [[
599
+
---<code>...
600
+
---@usage ]]
601
+
```
602
+
603
+
- Input
604
+
605
+
```lua
606
+
localU= {}
607
+
608
+
---Prints a message
609
+
---@parammsgstring Message
610
+
---@usage lua [[
611
+
---require("module.U").sum(10, 5)
612
+
---@usage ]]
613
+
functionU.echo(msg)
614
+
print(msg)
615
+
end
616
+
617
+
---Add two integer and print it
618
+
---@paramthisnumber First number
619
+
---@paramthatnumber Second number
620
+
---@usage `require("module.U").sum(10, 5)`
621
+
functionU.sum(this, that)
622
+
print(this+that)
623
+
end
624
+
625
+
returnU
626
+
```
627
+
628
+
- Output
629
+
630
+
```
631
+
U.echo({msg}) *U.echo*
632
+
Prints a message
633
+
634
+
Parameters: ~
635
+
{msg} (string) Message
636
+
637
+
Usage: ~
638
+
>lua
639
+
require("module.U").sum(10, 5)
640
+
<
641
+
642
+
643
+
U.sum({this}, {that}) *U.sum*
644
+
Add two integer and print it
645
+
646
+
Parameters: ~
647
+
{this} (number) First number
648
+
{that} (number) Second number
649
+
650
+
Usage: ~
651
+
>lua
652
+
require("module.U").sum(10, 5)
653
+
<
654
+
```
655
+
595
656
### Alias
596
657
597
658
This tag can be used to make a type alias. It is helpful if you are using the same the type multiple times.
0 commit comments