Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 919df19

Browse files
authored
Merge pull request coderoad#423 from coderoad/doc/how-it-works
Doc/how it works
2 parents 02d598d + 6152c3d commit 919df19

11 files changed

+100
-3
lines changed

β€ŽREADME.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ Install CodeRoad from [this link in the VSCode Marketplace](https://marketplace.
4444
- Node.js 10+
4545
- Git
4646

47+
## How CodeRoad Works
48+
49+
Read more in the docs about [how CodeRoad works](https://coderoad.github.io/docs/how-coderoad-works).
50+
4751
## Creating Tutorials
4852

4953
Build and share your own interactive tutorials.

β€Ždocs/docs/how-coderoad-works.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
id: how-coderoad-works
3+
title: How CodeRoad Works
4+
sidebar_label: How CodeRoad Works
5+
---
6+
7+
There are really a few major pieces to understand how CodeRoad works.
8+
9+
1. [How Tests Work](#how-tests-work)
10+
11+
2. [How CodeRoad is Built on Git](#built-on-git)
12+
13+
3. [How CodeRoad Hooks & Actions work](#how-hooks-and-actions-work)
14+
15+
### How Tests Work
16+
17+
In CodeRoad, the user is given a set of **levels** composed of one more **tasks**.
18+
19+
![Level / Task Flow](../images/level-task-flow.png)
20+
21+
Each task is judged to pass (βœ”) or fail (✘) by the result of code tests that runs in the background. Tests can be triggered by saving a file, or by a trigger that listens to specific files for changes.
22+
23+
![Test Flow Diagram](../images/test-flow-diagram.png)
24+
25+
If a test fails, the first failing test name is returned to the user as a hint to identify the problem.
26+
27+
Tests might be in another directory. Those folders or files might even be hidden from you by the tutorial creator.
28+
29+
But where does the code for these tests come from?
30+
31+
### Built on Git
32+
33+
CodeRoad tutorials are stored and loaded using Git, a popular version control system. If you're unfamiliar with Git, think of it as a way to save or load progress from checkpoints called "commits".
34+
35+
![Git Commit Example](../images/git-commit-example.png)
36+
37+
In a tutorial, these commits have a standardized order. First you setup the test runner, then the task tests, then the solution. This pattern is similar to a kind of development called β€œTDD” or β€œtest driven development”. Write tests for the problem you want to solve, then save the results when all the tests pass. This pattern can also be used to play out a tutorial like a game: users get a task, then must solve it to continue.
38+
39+
![CodeRoad Commit Example](../images/coderoad-commit-example.png)
40+
41+
When a tutorial starts, CodeRoad loads git commits from a tutorial up until the first task commit. These commits contain all of the code setup, test runner configuration and tests for the given task.
42+
43+
![Loading Tutorial Commits](../images/loading-tutorial-commits.png)
44+
45+
When a user passes a task, their progress is saved as a commit. Then the next task commit is loaded.
46+
47+
![Tutorial commits with user solution](../images/tutorial-commits-user-solution.png)
48+
49+
Again notice that the user provides the solution and it is not loaded from the tutorial. This allows users to go a little off-road in a tutorial and provide their own solutions.
50+
51+
#### Why Git
52+
53+
Git provides a number of benefits:
54+
55+
- users can save their progress to a service like GitHub to build a public portfolio
56+
- users can continue working on their project after a tutorial is completed
57+
- software developers are largely familiar with Git, and often TDD, making it easy to create tutorials
58+
- Git provides a mechanism for resolving merge conflicts if they happen to occur
59+
- Git provides a mechanism for "resetting" a tutorial, see more below!
60+
61+
#### Reset
62+
63+
If at some point the user is a bit too β€œoff-road” from the solution, the user can always return to the β€œgolden path” by pressing the **reset** button. The reset button reloads the commits up to that point entirely from the tutorial.
64+
65+
![Tutorial commits reset example](../images/tutorial-commits-reset.png)
66+
67+
In the example above you can see the user is β€œreset” back to the original tutorial answers, and back to the second task.
68+
69+
### How Hooks and Actions Work
70+
71+
To make a functional tutorial, tutorial creators need a bit more control over what can be run and when. For example, a test runner wouldn't really work if the package dependencies for that test runner weren't installed.
72+
73+
An **action** is a piece of functionality that can be run. These include:
74+
75+
- `commands` - a list of cli commands to run. For example, "npm install"
76+
- `vscodeCommands` - a list of vscode API commands to run. For example, "setLayout" to change the layout of windows
77+
- `watchers` - a list of files to listen to. If a file changes, the test runner will run automatically
78+
- `files` - a list of files to open in the users workspace to drive the users attention.
79+
- `subtasks` - a task made up of multiple other tests where all must pass to continue
80+
- `filter` - a regex passed into the test runner to limit the tests returned
81+
82+
A **hook** in CodeRoad is a place where a tutorial creator can tap in to run an action. Hooks include:
83+
84+
- `config.setup` - when the tutorial setup. This is a great place to setup your test runner.
85+
- `task.setup` - when a task is started
86+
- `task.solution` - when a solution is loaded from a [reset](#reset)
87+
88+
Hooks and actions combined provide a flexible environment for tutorial development.

β€Ždocs/docs/inspiration.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ In 2016, I developed an earlier version of [CodeRoad using the Atom editor](http
1212

1313
Years later it hit me that using Git as a tutorial format in CodeRoad would have been a simpler solution for both tutorial creation and consumption. Back in 2015, I had worked on a tutorial series for [Angular-Meteor](https://angular-meteor.com/tutorials/socially/angular2/bootstrap) using [Meteor Tutorial Tools](https://github.com/meteor/tutorial-tools). Meteor tutorial tools showed me that a tutorial can be versioned in Git, and that it can help ensure each step in the tutorial in cohesive and consistent.
1414

15-
The idea of CodeRoad sat with me for years to the point where the product started to feel obvious in my mind. It wasn’t so much that I wanted to build a platform, but it was a tool I wanted to use, and nobody else seemed to be working on it. In mid-2019, I had spent enough time thinking about how it would work that I decided to use my spare time to design and build it out.
15+
The idea of CodeRoad sat with me for years to the point where the product started to feel obvious in my mind. It wasn’t so much that I wanted to build a platform, but it was a tool I wanted to use, and nobody else seemed to be working on it. In mid-2019, I had spent enough time thinking about how it would work that I decided to use my spare time to design and build it.
16+
17+
Shawn McKay
18+
19+
CodeRoad creator
12.4 KB
Loading

β€Ždocs/images/git-commit-example.png

11.9 KB
Loading

β€Ždocs/images/level-task-flow.png

21 KB
Loading
25.9 KB
Loading

β€Ždocs/images/test-flow-diagram.png

16.4 KB
Loading
17.5 KB
Loading
Loading

β€Ždocs/sidebars.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
someSidebar: {
3-
Intro: ['overview', 'setup'],
3+
Intro: ['overview', 'setup', 'how-coderoad-works'],
44
Build: [
55
'build-tutorial',
66
'markdown',
@@ -12,7 +12,8 @@ module.exports = {
1212
'edit-tutorial',
1313
'create-a-practice-tutorial',
1414
'examples',
15-
'errors'
15+
'errors',
1616
],
17+
More: ['inspiration'],
1718
},
1819
}

0 commit comments

Comments
Β (0)