Skip to content

Commit

Permalink
chore: add missing jsdoc to some codelabs (google#2184)
Browse files Browse the repository at this point in the history
  • Loading branch information
maribethb authored Feb 5, 2024
1 parent 9a01aec commit 3927169
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
19 changes: 13 additions & 6 deletions examples/custom-renderer-codelab/src/renderers/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

import * as Blockly from 'blockly/core';

/**
* The ConstantProvider holds rendering-related constants such as colour
* and size information.
*/
class CustomConstantProvider extends Blockly.blockRendering.ConstantProvider {
/** @override */
constructor() {
// Set up all of the constants from the base provider.
super();
Expand Down Expand Up @@ -81,7 +86,7 @@ class CustomConstantProvider extends Blockly.blockRendering.ConstantProvider {
}

/**
* @returns Rectangular notch for use with previous and next connections.
* @returns {Object} Rectangular notch for use with previous and next connections.
*/
makeRectangularPreviousConn() {
const width = this.NOTCH_WIDTH;
Expand All @@ -90,8 +95,8 @@ class CustomConstantProvider extends Blockly.blockRendering.ConstantProvider {
/**
* Since previous and next connections share the same shape you can define
* a function to generate the path for both.
* @param dir Multiplier for the horizontal direction of the path (-1 or 1)
* @returns SVGPath line for use with previous and next connections.
* @param {number} dir Multiplier for the horizontal direction of the path (-1 or 1)
* @returns {Object} SVGPath line for use with previous and next connections.
*/
function makeMainPath(dir) {
return Blockly.utils.svgPaths.line([
Expand All @@ -112,7 +117,7 @@ class CustomConstantProvider extends Blockly.blockRendering.ConstantProvider {
}

/**
* @returns Rectangular puzzle tab for use with input and output connections.
* @returns {Object} Rectangular puzzle tab for use with input and output connections.
*/
makeRectangularInputConn() {
const width = this.TAB_WIDTH;
Expand All @@ -121,8 +126,8 @@ class CustomConstantProvider extends Blockly.blockRendering.ConstantProvider {
/**
* Since input and output connections share the same shape you can define
* a function to generate the path for both.
* @param dir Multiplier for the vertical direction of the path (-1 or 1)
* @returns SVGPath line for use with input and output connections.
* @param {number} dir Multiplier for the vertical direction of the path (-1 or 1)
* @returns {Object} SVGPath line for use with input and output connections.
*/
function makeMainPath(dir) {
return Blockly.utils.svgPaths.line([
Expand All @@ -143,7 +148,9 @@ class CustomConstantProvider extends Blockly.blockRendering.ConstantProvider {
}
}

/** The CustomRenderer class incorporates our custom ConstantProvider. */
export class CustomRenderer extends Blockly.blockRendering.Renderer {
/** @override */
constructor() {
super();
}
Expand Down
6 changes: 6 additions & 0 deletions examples/keyboard-navigation-codelab/src/cursors/custom.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import * as Blockly from 'blockly/core';

/** A custom cursor that skips previous and next connections. */
export class CustomCursor extends Blockly.Cursor {
/** @override */
constructor() {
super();
}

/** @override */
next() {
const curNode = this.getCurNode();
if (!curNode) {
Expand All @@ -26,6 +29,7 @@ export class CustomCursor extends Blockly.Cursor {
return newNode;
}

/** @override */
in() {
const curNode = this.getCurNode();
if (!curNode) {
Expand All @@ -43,6 +47,7 @@ export class CustomCursor extends Blockly.Cursor {
return newNode;
}

/** @override */
prev() {
const curNode = this.getCurNode();
if (!curNode) {
Expand All @@ -64,6 +69,7 @@ export class CustomCursor extends Blockly.Cursor {
return newNode;
}

/** @override */
out() {
const curNode = this.getCurNode();
if (!curNode) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as Blockly from 'blockly/core';

/** A custom Marker that causes an entire block to flash when marked. */
class CustomMarkerSvg extends Blockly.blockRendering.MarkerSvg {
/** @override */
constructor(workspace, constants, marker) {
super(workspace, constants, marker);
}
Expand Down Expand Up @@ -30,6 +32,7 @@ class CustomMarkerSvg extends Blockly.blockRendering.MarkerSvg {
}
}

/** @override */
showWithBlock_(curNode) {
// Get the block from the AST Node
const block = curNode.getLocation();
Expand Down Expand Up @@ -78,11 +81,14 @@ class CustomMarkerSvg extends Blockly.blockRendering.MarkerSvg {
}
}

/** A renderer that uses our custom marker. */
class CustomRenderer extends Blockly.geras.Renderer {
/** @override */
constructor(name) {
super(name);
}

/** @override */
makeMarkerDrawer(workspace, marker) {
return new CustomMarkerSvg(workspace, this.getConstants(), marker);
}
Expand Down

0 comments on commit 3927169

Please sign in to comment.