|
1
|
# Phase 2: Writing the Tutorial Documentation |
|
2
|
|
|
3
|
Follow these steps after the build phase is confirmed complete by the user. |
|
4
|
|
|
5
|
> **Prerequisites:** Building phase is done and user has confirmed the feature works. You know the example project path and all implemented features. |
|
6
|
|
|
7
|
Also load `reference/tutorial-conventions.md` and `reference/concept-definitions.md` before starting. |
|
8
|
|
|
9
|
## Step 1 — Create Step Diagram |
|
10
|
|
|
11
|
Map out all tutorial steps in the logical order a developer would execute them. Write this to a temp file `_step-diagram.md` in the project root. |
|
12
|
|
|
13
|
**Always start with Step 1 (Medusa installation) — it is always the first step.** |
|
14
|
|
|
15
|
Typical step order: |
|
16
|
1. Install Medusa Application (always first — use pre-written template) |
|
17
|
2. Create custom module + data models (if any) |
|
18
|
3. Run database migrations (immediately after module creation) |
|
19
|
4. Create workflow steps |
|
20
|
5. Create workflows |
|
21
|
6. Create API routes (store and/or admin) |
|
22
|
7. Create subscribers or scheduled jobs (if any) |
|
23
|
8. Admin UI customizations (widgets, pages — if applicable) |
|
24
|
9. Storefront customizations (if applicable) |
|
25
|
|
|
26
|
> **Rule:** A step that creates something used by another step must come first. You can't write "Create API route" before "Create workflow" because the route uses the workflow. |
|
27
|
|
|
28
|
Include "Test it Out" sub-steps for each major piece (API routes, subscribers, admin UI, storefront). |
|
29
|
|
|
30
|
Example `_step-diagram.md`: |
|
31
|
``` |
|
32
|
1. Install Medusa Application |
|
33
|
2. Create Product Review Module (data models: ProductReview) |
|
34
|
3. Run migrations |
|
35
|
4. Create createProductReviewWorkflow (step: createProductReviewStep) |
|
36
|
5. Create GET /store/products/:id/reviews route |
|
37
|
6. Create POST /store/products/:id/reviews route |
|
38
|
- Test: Submit a review via API |
|
39
|
7. Create GET /admin/product-reviews route |
|
40
|
- Test: List reviews in Admin |
|
41
|
8. Create Admin UI widget (product reviews tab on product page) |
|
42
|
- Test: View reviews widget in Admin |
|
43
|
9. Storefront: Display reviews on product page |
|
44
|
10. Storefront: Add review submission form |
|
45
|
- Test: Submit and see review in storefront |
|
46
|
``` |
|
47
|
|
|
48
|
## Step 2 — Write Per-Step MD Files |
|
49
|
|
|
50
|
For each step in the diagram, write a separate temp file in the Medusa project root: |
|
51
|
- `_step-01-install.md` |
|
52
|
- `_step-02-module.md` |
|
53
|
- `_step-03-migrations.md` |
|
54
|
- etc. |
|
55
|
|
|
56
|
**Step 1 (Medusa installation):** Copy the pre-written template directly from `tutorial-conventions.md`. Do not rewrite it. |
|
57
|
|
|
58
|
For each other step file: |
|
59
|
- Start with `## Step N: Step Title` |
|
60
|
- Write 1-2 sentences explaining what this step does and why |
|
61
|
- **First-use concept definitions:** The first time a Medusa concept is introduced (module, workflow, API route, subscriber, etc.), include its definition from `reference/concept-definitions.md` before the implementation. Do NOT repeat the definition in later steps that use the same concept. |
|
62
|
- **Service method implementations:** When a step implements methods on a service class, give each method its own sub-step (e.g., `### b. Implement send Method`). Each sub-step must: (1) explain in 1-2 sentences what the method does and when Medusa calls it, (2) show the code for that method only, (3) explain relevant implementation details below the code block. See `tutorial-conventions.md` for the pattern. |
|
63
|
- Show all code needed for this step with proper code block attributes (title, badgeLabel, highlights) |
|
64
|
- End with a `### Test it Out` section showing how to verify this step works |
|
65
|
- Follow all MDX patterns from `tutorial-conventions.md` |
|
66
|
|
|
67
|
Load `writing-docs` skill to apply prose quality rules while writing step content. |
|
68
|
|
|
69
|
> Write one step file at a time. Complete each file fully before moving to the next. |
|
70
|
|
|
71
|
## Step 3 — Combine Into Final MDX |
|
72
|
|
|
73
|
Once all step files are written, create the final tutorial file. |
|
74
|
|
|
75
|
**Determine the path:** |
|
76
|
- How-to tutorial: `www/apps/resources/app/how-to-tutorials/tutorials/{name}/page.mdx` |
|
77
|
- Integration guide: `www/apps/resources/app/integrations/guides/{name}/page.mdx` |
|
78
|
|
|
79
|
Create a `page.mdx` file with this structure (in order): |
|
80
|
|
|
81
|
``` |
|
82
|
1. Frontmatter (sidebar_label, tags, products) |
|
83
|
2. Imports (Github icon, Prerequisites, WorkflowDiagram, CardList from docs-ui) |
|
84
|
3. export const metadata = { title: `...` } |
|
85
|
4. export const highlights arrays (if any) |
|
86
|
5. # {metadata.title} |
|
87
|
6. Intro paragraph |
|
88
|
7. ## Summary (bullet list) |
|
89
|
8. Overview image placeholder |
|
90
|
9. CardList (GitHub repo + OpenAPI specs if applicable) |
|
91
|
10. --- |
|
92
|
11. [All step content from per-step files, combined in order] |
|
93
|
12. ## Next Steps |
|
94
|
13. ## Troubleshooting |
|
95
|
14. ## Getting Help |
|
96
|
``` |
|
97
|
|
|
98
|
See `tutorial-conventions.md` for exact templates for each section. |
|
99
|
|
|
100
|
## Step 4 — Update Sidebar |
|
101
|
|
|
102
|
After writing the MDX file, verify the tutorial appears in the sidebar. |
|
103
|
|
|
104
|
**For how-to tutorials** — open `www/apps/resources/sidebars/how-to-tutorials.mjs`: |
|
105
|
- Find the relevant `sub-category` that has `autogenerate_tags` matching your tutorial's tags |
|
106
|
- If a matching category exists (e.g., `autogenerate_tags: "howTo+server"`), ensure your tutorial's frontmatter `tags` array includes `server` and `tutorial` — no manual entry needed |
|
107
|
- If no matching category exists, add a manual `link` entry in the appropriate section |
|
108
|
|
|
109
|
**For integration guides** — open `www/apps/resources/sidebars/integrations.mjs`: |
|
110
|
- Same approach: check for autogenerate tags or add a manual entry |
|
111
|
|
|
112
|
## Step 5 — Cleanup |
|
113
|
|
|
114
|
Delete all temp files from the Medusa project root: |
|
115
|
- `_step-diagram.md` |
|
116
|
- `_step-01-install.md`, `_step-02-module.md`, etc. (all `_step-*.md` files) |
|
117
|
|
|
118
|
Verify the final `page.mdx` looks complete and correct before finishing. |