packages/walkthroughgen/readme.md
Walkthroughgen is a tool for creating walkthroughs, tutorials, readmes, and documentation. It helps you maintain step-by-step guides by generating markdown and working directories from a simple YAML configuration.
npm install -g walkthroughgen
walkthrough.yaml file:title: "My Tutorial"
text: "A step-by-step guide"
targets:
- markdown: "./walkthrough.md"
onChange:
diff: true
cp: true
- folders:
path: "./by-section"
final:
dirName: "final"
sections:
- name: setup
title: "Initial Setup"
steps:
- file: {src: ./files/package.json, dest: package.json}
- command: "npm install"
walkthroughgen generate walkthrough.yaml
A typical walkthrough project looks like this:
my-tutorial/
āāā walkthrough/ # Source files for each step
ā āāā 00-package.json
ā āāā 01-index.ts
ā āāā 02-config.ts
āāā walkthrough.yaml # Walkthrough configuration
āāā build/ # Generated output
āāā by-section/ # Section-by-section working directories
ā āāā 00-setup/
ā āāā 01-config/
āāā final/ # Final project state
āāā walkthrough.md # Generated markdown
title: Title of the walkthroughtext: Introduction texttargets: Output configurationsections: Tutorial sectionstargets:
- markdown: "./output.md"
onChange:
diff: true # Show diffs for changed files
cp: true # Show cp commands
newFiles:
cat: false # Don't show file contents
cp: true # Show cp commands
targets:
- folders:
path: "./by-section" # Base path for section folders
skip: ["cleanup"] # Sections to skip
final:
dirName: "final" # Name for final state directory
Each section represents a logical step in your tutorial:
sections:
- name: setup # Used for folder naming and skip array
title: "Initial Setup" # Display title
text: "Setup steps..." # Section description
steps:
# ... steps ...
Steps define the actions to take:
steps:
- text: "Copy package.json"
file:
src: ./files/package.json
dest: package.json
steps:
- text: "Create src directory"
dir:
create: true
path: src
steps:
- text: "Install dependencies"
command: "npm install"
incremental: true # run when building up folders target
steps:
- command: "npm run test"
results:
- text: "You should see:"
code: |
All tests passed!
Example markdown output:
# Initial Setup
Copy the package.json:
cp ./files/package.json package.json
<details>
<summary>show file</summary>
```json
{
"name": "my-project",
"version": "1.0.0"
}
```
</details>
Install dependencies:
npm install
You should see:
added 123 packages
The folders target creates:
See the examples directory for complete examples:
incremental: true for commands that modify stateskip array to exclude setup/cleanup sections from outputContributions welcome! Please read CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.