Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature/subtasks#57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 3 commits intomasterfromfeature/subtasks
Jul 5, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
support parsing subtasks
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
@ShMcK
ShMcK committedJul 5, 2020
commit72430c62e1d13258b9ed6f30d5e725c9ceea17c7
43 changes: 31 additions & 12 deletionssrc/utils/parse.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -91,20 +91,39 @@ export function parseMdContent(md: string): TutorialFrame | never {
content: stepContent.trim(),
};
} else {
// parse hints from stepContent
const hintDetectRegex = /^(#{4}\sHINTS[\n\r]+([\*|\-]\s(?<hintContent>[^]*))[\n\r]+)+/;
const hintMatch = section.match(hintDetectRegex);
if (!!hintMatch) {
const hintItemRegex = /[\n\r]+[\*|\-]\s/;
const hints = section
.split(hintItemRegex)
.slice(1) // remove #### HINTS
.map((h) => h.trim());
if (hints.length) {
mdContent.levels[current.levelIndex].steps[
current.stepIndex
].hints = hints;
}
const subtaskDetectRegex = /^(#{4}\sSUBTASKS[\n\r]+([\*|\-]\s(?<subtaskContent>[^]*))[\n\r]+)+/;
const subtaskMatch = section.match(subtaskDetectRegex);
const listItemregex = /[\n\r]+[\*|\-]\s/;

switch (true) {
// parse hints from stepContent
case !!hintMatch:
const hints = section
.split(listItemregex)
.slice(1) // remove #### HINTS
.map((h) => h.trim());
if (hints.length) {
mdContent.levels[current.levelIndex].steps[
current.stepIndex
].hints = hints;
}
return;
// parse subtasks from stepContent
case !!subtaskMatch:
const subtasks = section
.split(listItemregex)
.slice(1) // remove #### SUBTASKS
.map((h) => h.trim());
if (subtasks.length) {
mdContent.levels[current.levelIndex].steps[
current.stepIndex
].subtasks = subtasks;
}
return;
default:
console.warn(`No build parser match found for:\n${section}\n`);
}
}
}
Expand Down
15 changes: 8 additions & 7 deletionstests/parse.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1429,7 +1429,8 @@ Create a function \`add\` that can take a variety of params.

- Add one number
- Add two numbers
- Add three numbers`;
- Add three numbers
`;
const skeleton = {
levels: [
{
Expand All@@ -1453,18 +1454,18 @@ Create a function \`add\` that can take a variety of params.
{
id: "1.1",
setup: {
subtasks: [
"Add one number",
"Add two numbers",
"Add three numbers",
],
commits: ["abcdef1"],
},
content:
"Create a function `add` that can take a variety of params.",
solution: {
commits: ["abcdef2"],
},
subtasks: [
"Add one number",
"Add two numbers",
"Add three numbers",
],
},
],
},
Expand All@@ -1478,7 +1479,7 @@ Create a function \`add\` that can take a variety of params.
"1.1:S": ["abcdef2"],
},
});
expect(result.levels).toEqual(expected.levels);
expect(result.levels[0]).toEqual(expected.levels[0]);
});
});
});
4 changes: 2 additions & 2 deletionstypings/tutorial.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@ export type Step = {
content: string;
setup?: StepActions;
solution?: Maybe<StepActions>;
subtasks?:{ [testName:string]: boolean };
subtasks?: string[];
hints?: string[];
};

Expand All@@ -52,7 +52,7 @@ export type StepActions = {
files?: string[];
watchers?: string[];
filter?: string;
subtasks?:boolean;
subtasks?:string[];
};

export interface TestRunnerArgs {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp