Skip to content

Commit 0478ceb

Browse files
Update documentation
1 parent 89c7f3f commit 0478ceb

File tree

3 files changed

+53
-16
lines changed

3 files changed

+53
-16
lines changed

inventory.ts

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ namespace Inventory {
7575
//% block="%Inventory(Item) set text of %attribute to %value"
7676
//% weight=20
7777
//% group="Item"
78+
//% hidden
7879
set_text(attribute: ItemTextAttribute, value: string) {
7980
if (attribute == ItemTextAttribute.Name) {
8081
this.name = value;
@@ -85,10 +86,12 @@ namespace Inventory {
8586

8687
/**
8788
* Get the name of description of the item.
89+
* @return: The text.
8890
*/
8991
//% block="%Inventory(Item) get text of %attribute"
9092
//% weight=10
9193
//% group="Item"
94+
//% hidden
9295
get_text(attribute: ItemTextAttribute) {
9396
if (attribute == ItemTextAttribute.Name) {
9497
return this.name;
@@ -106,23 +109,27 @@ namespace Inventory {
106109
//% new_image.shadow=screen_image_picker
107110
//% weight=40
108111
//% group="Item"
112+
//% hidden
109113
set_image(new_image: Image) {
110114
this.image = new_image;
111115
}
112116

113117
/**
114118
* Get the image of the item.
119+
* @return: The image.
115120
*/
116121
//% block="%Inventory(Item) get image"
117122
//% weight=30
118123
//% group="Item"
124+
//% hidden
119125
get_image() {
120126
return this.image;
121127
}
122128
}
123129

124130
/**
125-
* Create a new item - for blocks.
131+
* Create a new item - for blocks. Only rewrapped for blocks.
132+
* @return: A new Inventory.Item.
126133
*/
127134
//% block="create item with name %name and %image || with description %description"
128135
//% blockSetVariable=item
@@ -132,6 +139,7 @@ namespace Inventory {
132139
//% description.dfl="Description"
133140
//% weight=50
134141
//% group="Item"
142+
//% hidden
135143
export function create_item(name: string, image: Image, description: string = null) {
136144
return new Item(name, image, description)
137145
}
@@ -186,10 +194,12 @@ namespace Inventory {
186194

187195
/**
188196
* Get the items in the toolbar. Only rewrapped for blocks.
197+
* @return: The items, as an array of Item.
189198
*/
190199
//% block="%Inventory(toolbar) get items"
191200
//% weight=80
192201
//% group="Toolbar"
202+
//% hidden
193203
public get_items() {
194204
return this.items;
195205
}
@@ -209,6 +219,7 @@ namespace Inventory {
209219
//% new_items.shadow="lists_create_with"
210220
//% weight=90
211221
//% group="Toolbar"
222+
//% hidden
212223
public set_items(new_items: Item[]) {
213224
this.items = new_items;
214225
}
@@ -230,10 +241,13 @@ namespace Inventory {
230241

231242
/**
232243
* Set the selected index or max items. Only rewrapped for blocks.
244+
* @attribute: A property of the ToolbarNumberAttribute enum.
245+
* @value: The new value.
233246
*/
234247
//% block="%Inventory(toolbar) set %attribute to %value"
235248
//% weight=70
236249
//% group="Toolbar"
250+
//% hidden
237251
public set_number(attribute: ToolbarNumberAttribute, value: number) {
238252
if (attribute == ToolbarNumberAttribute.SelectedIndex) {
239253
this.selected = value;
@@ -244,10 +258,13 @@ namespace Inventory {
244258

245259
/**
246260
* Get the selected index or max items. Only rewrapped for blocks.
261+
* @attribute: A property of the ToolbarNumberAttribute enum.
262+
* @return: A number.
247263
*/
248264
//% block="%Inventory(toolbar) get %attribute"
249265
//% weight=60
250266
//% group="Toolbar"
267+
//% hidden
251268
public get_number(attribute: ToolbarNumberAttribute) {
252269
if (attribute == ToolbarNumberAttribute.SelectedIndex) {
253270
return this.selected;
@@ -280,7 +297,7 @@ namespace Inventory {
280297
/**
281298
* Get the color of a specific part of the toolbar.
282299
* @param attribute: A property of the ToolbarColorAttribute enum.
283-
* @return: The color (which is a number) of the attribute, otherwise -1.
300+
* @return: The color (which is a number) of the attribute, otherwise -1.
284301
*/
285302
//% block="%Inventory(toolbar) get color of %attribute"
286303
//% weight=40
@@ -341,13 +358,15 @@ namespace Inventory {
341358

342359
/**
343360
* Create a new toolbar - for blocks.
361+
* @return: A new Toolbar.
344362
*/
345363
//% block="create toolbar with items %items and max items %max_items"
346364
//% blockSetVariable=toolbar
347365
//% items.shadow="lists_create_with"
348366
//% max_items.dfl=3
349367
//% weight=100
350368
//% group="Toolbar"
369+
//% hidden
351370
export function create_toolbar(items: Item[], max_items: number) {
352371
return new Toolbar(items, max_items);
353372
}
@@ -404,10 +423,12 @@ namespace Inventory {
404423

405424
/**
406425
* Get the items in the inventory. Only rewrapped for blocks.
426+
* @return: The items - as an array of Item.
407427
*/
408-
//% block="%Inventory(Inventory) get items"
428+
//% block="%Inventory(inventory) get items"
409429
//% weight=80
410430
//% group="Inventory"
431+
//% hidden
411432
public get_items() {
412433
return this.items;
413434
}
@@ -420,10 +441,15 @@ namespace Inventory {
420441
this.update();
421442
}
422443

423-
//% block="%Inventory(Inventory) set items to %new_items"
444+
/**
445+
* Set the items in the inventory. Only rewrapped for blocks.
446+
* @new_items: A list of Item.
447+
*/
448+
//% block="%Inventory(inventory) set items to %new_items"
424449
//% new_items.shadow="lists_create_with"
425450
//% weight=90
426451
//% group="Inventory"
452+
//% hidden
427453
public set_items(new_items: Item[]) {
428454
this.items = new_items;
429455
}
@@ -445,10 +471,13 @@ namespace Inventory {
445471

446472
/**
447473
* Set the selected index or max items. Only rewrapped for blocks.
474+
* @attribute: A property of the InventoryNumberAttribute enum.
475+
* @value: The new number.
448476
*/
449-
//% block="%Inventory(Inventory) set %attribute to %value"
477+
//% block="%Inventory(inventory) set %attribute to %value"
450478
//% weight=70
451479
//% group="Inventory"
480+
//% hidden
452481
public set_number(attribute: InventoryNumberAttribute, value: number) {
453482
if (attribute == InventoryNumberAttribute.SelectedIndex) {
454483
this.selected = value;
@@ -459,10 +488,13 @@ namespace Inventory {
459488

460489
/**
461490
* Get the selected index or max items. Only rewrapped for blocks.
491+
* @attribute: A property of the InventoryNumberAttribute enum.
492+
* @return: The number.
462493
*/
463-
//% block="%Inventory(Inventory) get %attribute"
494+
//% block="%Inventory(inventory) get %attribute"
464495
//% weight=60
465496
//% group="Inventory"
497+
//% hidden
466498
public get_number(attribute: InventoryNumberAttribute) {
467499
if (attribute == InventoryNumberAttribute.SelectedIndex) {
468500
return this.selected;
@@ -481,10 +513,12 @@ namespace Inventory {
481513

482514
/**
483515
* Get the text in the inventory. Only rewrapped for blocks.
516+
* @return: A string.
484517
*/
485-
//% block="%Inventory(Inventory) get text"
518+
//% block="%Inventory(inventory) get text"
486519
//% weight=40
487520
//% group="Inventory"
521+
//% hidden
488522
public get_text() {
489523
return this.text;
490524
}
@@ -499,10 +533,12 @@ namespace Inventory {
499533

500534
/**
501535
* Set the text in the inventory. Only rewrapped for blocks.
536+
* @new_text: The new text.
502537
*/
503-
//% block="%Inventory(Inventory) set text to %new_text"
538+
//% block="%Inventory(inventory) set text to %new_text"
504539
//% weight=50
505540
//% group="Inventory"
541+
//% hidden
506542
public set_text(new_text: string) {
507543
this.text = new_text;
508544
}
@@ -512,7 +548,7 @@ namespace Inventory {
512548
* @param attribute: A property of the InventoryColorAttribute enum.
513549
* @param color: A number which should be the new color of the attribute.
514550
*/
515-
//% block="%Inventory(Inventory) set color of %attribute to %color"
551+
//% block="%Inventory(inventory) set color of %attribute to %color"
516552
//% color.shadow=colorindexpicker
517553
//% weight=30
518554
//% group="Inventory"
@@ -532,9 +568,9 @@ namespace Inventory {
532568
/**
533569
* Get the color of a specific part of the inventory.
534570
* @param attribute: A property of the InventoryColorAttribute enum.
535-
* @return: The color (which is a number) of the attribute, otherwise -1.
571+
* @return: The color (which is a number) of the attribute, otherwise -1.
536572
*/
537-
//% block="%Inventory(Inventory) get color of %attribute"
573+
//% block="%Inventory(inventory) get color of %attribute"
538574
//% weight=20
539575
//% group="Inventory"
540576
public get_color(attribute: InventoryColorAttribute) {
@@ -595,6 +631,7 @@ namespace Inventory {
595631
//% max_items.dfl=3
596632
//% weight=100
597633
//% group="Inventory"
634+
//% hidden
598635
export function create_inventory(items: Item[], max_items: number) {
599636
return new Inventory(items, max_items);
600637
}

main.blocks

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ c e e 2 2 2 2 2 2 2 2 2 2 4 2 e
1515
. . 2 e e 2 2 2 2 2 4 4 2 e . .
1616
. . . 2 2 e e 4 4 4 2 e e . . .
1717
. . . . . 2 2 e e e e . . . . .
18-
`</field><data>{"commentRefs":[],"fieldData":{"img":null}}</data></shadow></value></block></value><value name="ADD1"><block type="Inventory_create_item" id=",t,UL;q$]J`QsDQIM1-I"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="false"></mutation><value name="name"><shadow type="text" id="nbqY-rh)`B]F;w4-?s9A"><field name="TEXT">Burger</field></shadow></value><value name="image"><shadow type="screen_image_picker" id="z[_o.mv8Hr9EMcI.M^ud"><field name="img">img`
18+
`</field><data>{"commentRefs":[],"fieldData":{"img":"C*Jj0V6f(`UxDmM[KZQr"}}</data></shadow></value></block></value><value name="ADD1"><block type="Inventory_create_item" id=",t,UL;q$]J`QsDQIM1-I"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="false"></mutation><value name="name"><shadow type="text" id="nbqY-rh)`B]F;w4-?s9A"><field name="TEXT">Burger</field></shadow></value><value name="image"><shadow type="screen_image_picker" id="z[_o.mv8Hr9EMcI.M^ud"><field name="img">img`
1919
. . . . c c c b b b b b . . . .
2020
. . c c b 4 4 4 4 4 4 b b b . .
2121
. c c 4 4 4 4 4 5 4 4 4 4 b c .
@@ -32,7 +32,7 @@ e b e 8 8 c c 8 8 c c c 8 e b e
3232
e e b e c c e e e e e c e b e e
3333
. e e b b 4 4 4 4 4 4 4 4 e e .
3434
. . . c c c c c e e e e e . . .
35-
`</field><data>{"commentRefs":[],"fieldData":{"img":null}}</data></shadow></value></block></value><value name="ADD2"><block type="Inventory_create_item" id="~v{1{*UL4%ticn;Suz+j"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="false"></mutation><value name="name"><shadow type="text" id="J6]h4Y,R^Hw1]WD#rfgi"><field name="TEXT">Pizza</field></shadow></value><value name="image"><shadow type="screen_image_picker" id="VE3?jVwcq-dT_3BffU?T"><field name="img">img`
35+
`</field><data>{"commentRefs":[],"fieldData":{"img":"z[_o.mv8Hr9EMcI.M^ud"}}</data></shadow></value></block></value><value name="ADD2"><block type="Inventory_create_item" id="~v{1{*UL4%ticn;Suz+j"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="false"></mutation><value name="name"><shadow type="text" id="J6]h4Y,R^Hw1]WD#rfgi"><field name="TEXT">Pizza</field></shadow></value><value name="image"><shadow type="screen_image_picker" id="VE3?jVwcq-dT_3BffU?T"><field name="img">img`
3636
. . . . . . b b b b . . . . . .
3737
. . . . . . b 4 4 4 b . . . . .
3838
. . . . . . b b 4 4 4 b . . . .
@@ -49,7 +49,7 @@ b d 3 2 d 5 5 5 d d d 4 4 . . .
4949
b 5 5 5 5 d d 4 4 4 4 . . . . .
5050
4 d d d 4 4 4 . . . . . . . . .
5151
4 4 4 4 . . . . . . . . . . . .
52-
`</field><data>{"commentRefs":[],"fieldData":{"img":null}}</data></shadow></value></block></value></block></value><value name="max_items"><shadow type="math_number" id=";{XJv*oFCG(A8lgxD[xN"><field name="NUM">3</field></shadow></value></block></value><next><block type="Sprite_blockCombine_set" id="U2Z201f5R!=x(ZhOTlHB"><field name="property">Sprite.left@set</field><value name="mySprite"><block type="variables_get" id="E[{41[wBC#oLj%`.VRIq"><field name="VAR" id="%8P,Y?##mLxxx6@=UhAU">toolbar</field></block></value><value name="value"><shadow type="math_number" id="ivw[Wt)/oP%xQr]G9=0;"><field name="NUM">4</field></shadow></value><next><block type="Sprite_blockCombine_set" id="l(j#*`pDE`X%rK]e[3|L"><field name="property">Sprite.bottom@set</field><value name="mySprite"><block type="variables_get" id="|mwBV1q81)Tx{lqf7OQM"><field name="VAR" id="%8P,Y?##mLxxx6@=UhAU">toolbar</field></block></value><value name="value"><block type="math_arithmetic" id=":~#5-/8Dby@q}6+%~0_!"><field name="OP">MINUS</field><value name="A"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="scenescreenheight" id="NUC!|c:qc8|Ah_H-PZR`"/></value><value name="B"><shadow type="math_number" id="X+k0!HwYSIwoCw:t6_bi"><field name="NUM">4</field></shadow></value></block></value><next><block type="variables_set" id="Kq-=*):0s#6OWv~z=koQ"><field name="VAR" id="O5Ms-MSjX1ckdlYxmHl3">inv_contents</field><value name="VALUE"><shadow type="math_number" id=";01CIAdyET|r1C%Mz~DA" disabled="true"><field name="NUM">0</field></shadow><block type="lists_create_with" id="p(B0J%*p~XC:SElB4hYX"><mutation items="0"/></block></value><next><block type="controls_repeat_ext" id="j1l_O;JtRmp2sE}VFEbj"><value name="TIMES"><shadow type="math_whole_number" id="!nS4jz/3)M/(.l#|J!1!"><field name="NUM">30</field></shadow></value><statement name="DO"><block type="array_push" id="MylATnWYLGSva.ri@4aP"><value name="list"><block type="variables_get" id="NEGf/75}%fl3V/?EH?o?"><field name="VAR" id="O5Ms-MSjX1ckdlYxmHl3">inv_contents</field></block></value><value name="value"><block type="Inventory_create_item" id="xg$Ml=),@C?-/5]xsXiq"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="false"></mutation><value name="name"><shadow type="text" id="7K3=hJ}UsuWS@CslxuWc"><field name="TEXT">Apple</field></shadow></value><value name="image"><shadow type="screen_image_picker" id="1ypAW:UuJ0y60RuD~]k0"><field name="img">img`
52+
`</field><data>{"commentRefs":[],"fieldData":{"img":"VE3?jVwcq-dT_3BffU?T"}}</data></shadow></value></block></value></block></value><value name="max_items"><shadow type="math_number" id=";{XJv*oFCG(A8lgxD[xN"><field name="NUM">3</field></shadow></value></block></value><next><block type="Sprite_blockCombine_set" id="U2Z201f5R!=x(ZhOTlHB"><field name="property">Sprite.left@set</field><value name="mySprite"><block type="variables_get" id="E[{41[wBC#oLj%`.VRIq"><field name="VAR" id="%8P,Y?##mLxxx6@=UhAU">toolbar</field></block></value><value name="value"><shadow type="math_number" id="ivw[Wt)/oP%xQr]G9=0;"><field name="NUM">4</field></shadow></value><next><block type="Sprite_blockCombine_set" id="l(j#*`pDE`X%rK]e[3|L"><field name="property">Sprite.bottom@set</field><value name="mySprite"><block type="variables_get" id="|mwBV1q81)Tx{lqf7OQM"><field name="VAR" id="%8P,Y?##mLxxx6@=UhAU">toolbar</field></block></value><value name="value"><block type="math_arithmetic" id=":~#5-/8Dby@q}6+%~0_!"><field name="OP">MINUS</field><value name="A"><shadow type="math_number"><field name="NUM">0</field></shadow><block type="scenescreenheight" id="NUC!|c:qc8|Ah_H-PZR`"/></value><value name="B"><shadow type="math_number" id="X+k0!HwYSIwoCw:t6_bi"><field name="NUM">4</field></shadow></value></block></value><next><block type="variables_set" id="Kq-=*):0s#6OWv~z=koQ"><field name="VAR" id="O5Ms-MSjX1ckdlYxmHl3">inv_contents</field><value name="VALUE"><shadow type="math_number" id=";01CIAdyET|r1C%Mz~DA" disabled="true"><field name="NUM">0</field></shadow><block type="lists_create_with" id="p(B0J%*p~XC:SElB4hYX"><mutation items="0"/></block></value><next><block type="controls_repeat_ext" id="j1l_O;JtRmp2sE}VFEbj"><value name="TIMES"><shadow type="math_whole_number" id="!nS4jz/3)M/(.l#|J!1!"><field name="NUM">30</field></shadow></value><statement name="DO"><block type="array_push" id="MylATnWYLGSva.ri@4aP"><value name="list"><block type="variables_get" id="NEGf/75}%fl3V/?EH?o?"><field name="VAR" id="O5Ms-MSjX1ckdlYxmHl3">inv_contents</field></block></value><value name="value"><block type="Inventory_create_item" id="xg$Ml=),@C?-/5]xsXiq"><mutation xmlns="http://www.w3.org/1999/xhtml" _expanded="0" _input_init="false"></mutation><value name="name"><shadow type="text" id="7K3=hJ}UsuWS@CslxuWc"><field name="TEXT">Apple</field></shadow></value><value name="image"><shadow type="screen_image_picker" id="1ypAW:UuJ0y60RuD~]k0"><field name="img">img`
5353
. . . . . . . e c 7 . . . . . .
5454
. . . . e e e c 7 7 e e . . . .
5555
. . c e e e e c 7 e 2 2 e e . .
@@ -66,4 +66,4 @@ c e e 2 2 2 2 2 2 2 2 2 2 4 2 e
6666
. . 2 e e 2 2 2 2 2 4 4 2 e . .
6767
. . . 2 2 e e 4 4 4 2 e e . . .
6868
. . . . . 2 2 e e e e . . . . .
69-
`</field><data>{"commentRefs":[],"fieldData":{"img":null}}</data></shadow></value></block></value></block></statement><next><block type="variables_set" id="6*fnw9@VSz6[m|bfgvep"><field name="VAR" id="{5=8(#8[mpRK`SUegF[~">inventory</field><value name="VALUE"><shadow xmlns="http://www.w3.org/1999/xhtml" type="math_number"><field name="NUM">0</field></shadow><block type="Inventory_create_inventory" id="e!}NYYxw5}]SAk:)rY(;"><value name="items"><block type="variables_get" id="LQEB#dO[e-;9pM0$_1Z9"><field name="VAR" id="O5Ms-MSjX1ckdlYxmHl3">inv_contents</field></block></value><value name="max_items"><shadow type="math_number" id="u#PGL%1M6q%k,(UL}}wm"><field name="NUM">32</field></shadow></value></block></value><next><block type="Sprite_blockCombine_set" id="1b[P,lbS@A`ddAx@3-No"><field name="property">Sprite.top@set</field><value name="mySprite"><block type="variables_get" id="#Y;O5:@lisQq#8*z.SA#"><field name="VAR" id="{5=8(#8[mpRK`SUegF[~">inventory</field></block></value><value name="value"><shadow type="math_number" id="{D9zZZIi@-mfdtD}#+UX"><field name="NUM">4</field></shadow></value><next><block type="Sprite_blockCombine_set" id=";QnO;`_85r}zr={!EbzJ"><field name="property">Sprite.left@set</field><value name="mySprite"><block type="variables_get" id=";EsAn;RYMrU=KO7jOJuf"><field name="VAR" id="{5=8(#8[mpRK`SUegF[~">inventory</field></block></value><value name="value"><shadow type="math_number" id="IoY1s#NPn/:~H0KGR4t3"><field name="NUM">4</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>
69+
`</field><data>{"commentRefs":[],"fieldData":{"img":"1ypAW:UuJ0y60RuD~]k0"}}</data></shadow></value></block></value></block></statement><next><block type="variables_set" id="6*fnw9@VSz6[m|bfgvep"><field name="VAR" id="{5=8(#8[mpRK`SUegF[~">inventory</field><value name="VALUE"><shadow xmlns="http://www.w3.org/1999/xhtml" type="math_number"><field name="NUM">0</field></shadow><block type="Inventory_create_inventory" id="e!}NYYxw5}]SAk:)rY(;"><value name="items"><block type="variables_get" id="LQEB#dO[e-;9pM0$_1Z9"><field name="VAR" id="O5Ms-MSjX1ckdlYxmHl3">inv_contents</field></block></value><value name="max_items"><shadow type="math_number" id="u#PGL%1M6q%k,(UL}}wm"><field name="NUM">32</field></shadow></value></block></value><next><block type="Sprite_blockCombine_set" id="1b[P,lbS@A`ddAx@3-No"><field name="property">Sprite.top@set</field><value name="mySprite"><block type="variables_get" id="#Y;O5:@lisQq#8*z.SA#"><field name="VAR" id="{5=8(#8[mpRK`SUegF[~">inventory</field></block></value><value name="value"><shadow type="math_number" id="{D9zZZIi@-mfdtD}#+UX"><field name="NUM">4</field></shadow></value><next><block type="Sprite_blockCombine_set" id=";QnO;`_85r}zr={!EbzJ"><field name="property">Sprite.left@set</field><value name="mySprite"><block type="variables_get" id=";EsAn;RYMrU=KO7jOJuf"><field name="VAR" id="{5=8(#8[mpRK`SUegF[~">inventory</field></block></value><value name="value"><shadow type="math_number" id="IoY1s#NPn/:~H0KGR4t3"><field name="NUM">4</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>

0 commit comments

Comments
 (0)