Skip to content

Commit

Permalink
move off of plain map type for properties, add todo for generalizing …
Browse files Browse the repository at this point in the history
…snippet parsing
  • Loading branch information
jwunderl committed Aug 16, 2023
1 parent c25719c commit 7aa279f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion localtypings/pxtarget.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,9 +1178,13 @@ declare namespace pxt.tutorial {
execute(options: CodeValidationExecuteOptions): Promise<CodeValidationResult>;
}

interface CodeValidatorBaseProperties {
enabled?: string;
}

interface CodeValidatorMetadata {
validatorType: string;
properties: pxt.Map<string>;
properties: CodeValidatorBaseProperties;
}

interface CodeValidationConfig {
Expand Down
5 changes: 5 additions & 0 deletions pxtlib/tutorial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@ ${code}
return pxt.BrowserUtils.getTutorialCodeHash(codeSnippets);
}

/** TODO: if this gets exported, we probably want to consider generalizing to 'parseMarkdownSnippets'
* that returns { snippetName: string[] }; e.g.
* { "blocks": ["block snippet 1", "block snippet 2"], "package": ["deplist 1"] }
* need to cover getMetadataRegex + stripHiddenSnippets types, maybe more if any happen to be around.
**/
function getBlockSnippetCode(mdSnippet: string): string[] {
let hintCode: string[] = [];

Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/tutorialValidators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ abstract class CodeValidatorBase implements CodeValidator {
enabled: boolean;
abstract name: string;

constructor(properties: {[index: string]: string}) {
this.enabled = properties["enabled"]?.toLowerCase() != "false"; // Default to true
constructor(properties: pxt.tutorial.CodeValidatorBaseProperties) {
this.enabled = properties.enabled?.toLowerCase() != "false"; // Default to true
}

async execute(options: CodeValidationExecuteOptions): Promise<CodeValidationResult> {
Expand Down

0 comments on commit 7aa279f

Please sign in to comment.