Skip to content

Commit

Permalink
chore: Update docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko committed Jan 7, 2025
1 parent 1a73b12 commit 326878b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/procedures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export function flyoutCategory(workspace: WorkspaceSvg): FlyoutItemInfo[] {
}

/**
* Add items to xmlList for each listed procedure.
* Creates JSON block definitions for each of the given procedures.
*
* @param procedureList A list of procedures, each of which is defined by a
* three-element list of name, parameter list, and return value boolean.
Expand Down
32 changes: 21 additions & 11 deletions core/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,29 @@ export function flyoutCategory(workspace: WorkspaceSvg): FlyoutItemInfo[] {
];
}

/**
* Returns the JSON definition for a variable field.
*
* @param variable The variable the field should reference.
* @returns JSON for a variable field.
*/
function generateVariableFieldJson(variable: IVariableModel<IVariableState>) {
return {
'VAR': {
'name': variable.getName(),
'type': variable.getType(),
},
};
}

/**
* Construct the blocks required by the flyout for the variable category.
*
* @param workspace The workspace containing variables.
* @param variables List of variables to create blocks for.
* @param includeChangeBlocks True to include `change x by _` blocks.
* @param getterType The type of the variable getter block to generate.
* @param setterType The type of the variable setter block to generate.
* @returns JSON list of blocks.
*/
export function flyoutCategoryBlocks(
Expand All @@ -127,20 +146,10 @@ export function flyoutCategoryBlocks(
): BlockInfo[] {
includeChangeBlocks &&= Blocks['math_change'];

const generateVariableFieldJson = (
variable: IVariableModel<IVariableState>,
) => {
return {
'VAR': {
'name': variable.getName(),
'type': variable.getType(),
},
};
};

const blocks = [];
const mostRecentVariable = variables.slice(-1)[0];
if (mostRecentVariable) {
// Show one setter block, with the name of the most recently created variable.
if (Blocks[setterType]) {
blocks.push({
kind: 'block',
Expand Down Expand Up @@ -171,6 +180,7 @@ export function flyoutCategoryBlocks(
}

if (Blocks[getterType]) {
// Show one getter block for each variable, sorted in alphabetical order.
blocks.push(
...variables.sort(compareByName).map((variable) => {
return {
Expand Down

0 comments on commit 326878b

Please sign in to comment.