Skip to content

Commit 45168a6

Browse files
committed
chore(docs): run prettier --write on docs
1 parent 231a9b1 commit 45168a6

213 files changed

Lines changed: 4738 additions & 3832 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/docs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ npm run serve
3535

3636
The build folder is now served at http://localhost:3000/.
3737

38+
## Linting
39+
40+
```bash
41+
# check formatting:
42+
npm run format:check
43+
# fix formatting:
44+
npm run format
45+
```
46+
3847
## Generating reference docs
3948

4049
The API reference pages are auto-generated from the Blockly TypeScript source using `@microsoft/api-extractor` and `@microsoft/api-documenter`. This is a separate step from the Docusaurus build and must be run from the `packages/blockly` directory:

packages/docs/docs/codelabs/context-menu-option/add-a-context-menu-item.mdx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ Add a function to `index.js` named `registerHelloWorldItem`. Create a new regist
3333
function registerHelloWorldItem() {
3434
const helloWorldItem = {
3535
displayText: 'Hello World',
36-
preconditionFn: function(scope) {
36+
preconditionFn: function (scope) {
3737
return 'enabled';
3838
},
39-
callback: function(scope) {
40-
},
39+
callback: function (scope) {},
4140
id: 'hello_world',
4241
weight: 100,
4342
};
@@ -52,10 +51,9 @@ function start() {
5251

5352
Blockly.ContextMenuItems.registerCommentOptions();
5453
// Create main workspace.
55-
workspace = Blockly.inject('blocklyDiv',
56-
{
57-
toolbox: toolboxSimple,
58-
});
54+
workspace = Blockly.inject('blocklyDiv', {
55+
toolbox: toolboxSimple,
56+
});
5957
}
6058
```
6159

@@ -80,6 +78,10 @@ you will never need to make a new `ContextMenuRegistry`. Always use the singleto
8078

8179
Reload your web page and open a context menu on the workspace (right-click with a mouse, or press `Ctrl+Enter` (Windows) or `Command+Enter` (Mac) if you are navigating Blockly with the keyboard). You should see a new option labeled "Hello World" at the bottom of the context menu.
8280

83-
<CodelabImage> ![A context menu. The last option says "Hello World".](../../../static/images/codelabs/context-menu-option/hello_world.png) </CodelabImage>
81+
<CodelabImage>
82+
{' '}
83+
![A context menu. The last option says "Hello
84+
World".](../../../static/images/codelabs/context-menu-option/hello_world.png){' '}
85+
</CodelabImage>
8486

8587
Next, drag a block onto the workspace and open a context menu on the block. You'll see "Hello World" at the bottom of the block's context menu. Finally, open a context menu on the workspace and create a comment, then open a context menu on the comment's header. "Hello World" should be at the bottom of the context menu.

packages/docs/docs/codelabs/context-menu-option/callback.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ As an example, update the help item's `callback` to add a block to the workspace
3030
- Select the **Help** option.
3131
- A text block should appear in the top left of the workspace.
3232

33-
34-
![A text block containing the text "Now there is a block".](../../../static/images/codelabs/context-menu-option/there_is_a_block.png)
33+
![A text block containing the text "Now there is a block".](../../../static/images/codelabs/context-menu-option/there_is_a_block.png)

packages/docs/docs/codelabs/context-menu-option/codelab-overview.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ description: Overview of the "Customizing context menus" codelab.
1111
### What you'll learn
1212

1313
In this codelab you will learn how to:
14+
1415
- Add a context menu option to the workspace.
1516
- Add a context menu option to all blocks.
1617
- Use precondition functions to hide or disable context menu options.
1718
- Take an action when a menu option is selected.
1819
- Customize ordering and display text for context menu options.
1920

2021
### What you'll build
22+
2123
A very simple Blockly workspace with a few new context menu options.
2224

2325
### What you'll need
26+
2427
- A browser.
2528
- A text editor.
2629
- Basic knowledge of HTML, CSS, and JavaScript.
2730

28-
This codelab is focused on Blockly's context menus. Non-relevant concepts and code are glossed over and are provided for you to simply copy and paste.
31+
This codelab is focused on Blockly's context menus. Non-relevant concepts and code are glossed over and are provided for you to simply copy and paste.

packages/docs/docs/codelabs/context-menu-option/display-text.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ As an example, add this registry item. The display text depends on the block typ
1616
```js
1717
function registerDisplayItem() {
1818
const displayItem = {
19-
displayText: function(scope) {
19+
displayText: function (scope) {
2020
if (scope.focusedNode.type.startsWith('text')) {
2121
return 'Text block';
2222
} else if (scope.focusedNode.type.startsWith('controls')) {
@@ -25,13 +25,12 @@ function registerDisplayItem() {
2525
return 'Some other block';
2626
}
2727
},
28-
preconditionFn: function(scope) {
28+
preconditionFn: function (scope) {
2929
return scope.focusedNode instanceof Blockly.BlockSvg
3030
? 'enabled'
3131
: 'hidden';
3232
},
33-
callback: function(scope) {
34-
},
33+
callback: function (scope) {},
3534
id: 'display_text_example',
3635
weight: 100,
3736
};
@@ -44,4 +43,4 @@ As usual, remember to call `registerDisplayItem()` from your `start` function.
4443
### Test it
4544

4645
- Reload the workspace and open context menus on various blocks.
47-
- The last context menu option's text should vary based on the block type.
46+
- The last context menu option's text should vary based on the block type.

packages/docs/docs/codelabs/context-menu-option/precondition-blockly-state.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ Disabling your context menu options half of the time is not useful, but you may
1313
function registerHelpItem() {
1414
const helpItem = {
1515
displayText: 'Help! There are no blocks',
16-
preconditionFn: function(scope) {
16+
preconditionFn: function (scope) {
1717
if (!(scope.focusedNode instanceof Blockly.WorkspaceSvg)) return 'hidden';
1818
if (!scope.focusedNode.getTopBlocks().length) {
1919
return 'enabled';
2020
}
2121
return 'hidden';
2222
},
23-
callback: function(scope) {
24-
},
23+
callback: function (scope) {},
2524
id: 'help_no_blocks',
2625
weight: 100,
2726
};
@@ -34,4 +33,4 @@ Don't forget to call `registerHelpItem` from your `start` function.
3433
### Test it
3534

3635
- Reload your page and open a context menu on the workspace. You should see an option labeled "Help! There are no blocks".
37-
- Add a block to the workspace and open a context menu on the workspace again. The **Help** option should be gone.
36+
- Add a block to the workspace and open a context menu on the workspace again. The **Help** option should be gone.

packages/docs/docs/codelabs/context-menu-option/precondition-external-state.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ Use of the `preconditionFn` is not limited to checking the type of the Blockly c
2929

3030
Reload your workspace, check your watch, and open a context menu on the workspace to confirm the timing. The option will always be in the menu, but will sometimes be greyed out.
3131

32-
![A context menu. The last option says "Hello World" but the text is grey, indicating that it cannot be selected.](../../../static/images/codelabs/context-menu-option/hello_world_grey.png)
32+
![A context menu. The last option says "Hello World" but the text is grey, indicating that it cannot be selected.](../../../static/images/codelabs/context-menu-option/hello_world_grey.png)

packages/docs/docs/codelabs/context-menu-option/precondition-node-type.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The `scope` argument is an object that is passed to `preconditionFn`. You'll use
1717

1818
The return value of `preconditionFn` is `'enabled'`, `'disabled'`, or `'hidden'`. An **enabled** option is shown with black text and is selectable. A **disabled** option is shown with grey text and is not selectable. A **hidden** option is not included in the context menu at all.
1919

20-
### Write the function
20+
### Write the function
2121

2222
You can now test `scope.focusedNode` to display the "Hello World" option in workspace and block context menus, but not on any others. Change `preconditionFn` to:
2323

packages/docs/docs/codelabs/context-menu-option/separators.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ function registerSeparators() {
2222
scopeType: Blockly.ContextMenuRegistry.ScopeType.WORKSPACE,
2323
weight: 99,
2424
separator: true,
25-
}
25+
};
2626
Blockly.ContextMenuRegistry.registry.register(workspaceSeparator);
2727

2828
const blockSeparator = {
2929
id: 'block_separator',
3030
scopeType: Blockly.ContextMenuRegistry.ScopeType.BLOCK,
3131
weight: 99,
3232
separator: true,
33-
}
33+
};
3434
Blockly.ContextMenuRegistry.registry.register(blockSeparator);
3535
}
3636
```

packages/docs/docs/codelabs/context-menu-option/setup.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@ git clone https://github.com/RaspberryPiFoundation/blockly.git
2424
If you downloaded the source as a zip, unpacking it should give you a root folder named `blockly-main`.
2525

2626
The relevant files are in `docs/docs/codelabs/context-menu-option`. There are two versions of the app:
27+
2728
- `starter-code/`: The starter code that you'll build upon in this codelab.
2829
- `complete-code/`: The code after completing the codelab, in case you get lost or want to compare to your version.
2930

3031
Each folder contains:
32+
3133
- `index.js` - The codelab's logic. To start, it just injects a simple workspace.
3234
- `index.html` - A web page containing a simple blockly workspace.
3335

3436
To run the code, simple open `starter-code/index.html` in a browser. You should see a Blockly workspace with an always-open flyout.
3537

36-
<CodelabImage>![A web page with the text "Context Menu Codelab" and a simple Blockly workspace.](../../../static/images/codelabs/context-menu-option/starter_workspace.png)</CodelabImage>
38+
<CodelabImage>
39+
![A web page with the text "Context Menu Codelab" and a simple Blockly
40+
workspace.](../../../static/images/codelabs/context-menu-option/starter_workspace.png)
41+
</CodelabImage>

0 commit comments

Comments
 (0)