|
3 | 3 | Thank you for your interest in contributing! This project aims to be the best |
4 | 4 | community-driven knowledge base for Effect-TS patterns. Every contribution helps. |
5 | 5 |
|
6 | | -## How to Add a New Pattern |
7 | | - |
8 | | -1. **Create a new file** in the `/content` directory. |
9 | | -2. **Name the file** using a descriptive, kebab-case name, like |
10 | | - `use-gen-for-business-logic.mdx`. |
11 | | -3. **Copy the contents** from the `template.mdx` file into your new file. |
12 | | -4. **Fill out the template** with the details of your pattern. |
13 | | -5. **Submit a Pull Request.** |
| 6 | +## Documentation Pipeline |
| 7 | + |
| 8 | +This project uses a two-stage pipeline system: |
| 9 | + |
| 10 | +### 1. Ingest Stage |
| 11 | + |
| 12 | +New patterns start in `/content/new` and go through validation: |
| 13 | + |
| 14 | +- **Source Files** |
| 15 | + - TypeScript examples in `/content/new/src/*.ts` |
| 16 | + - MDX documentation in `/content/new/*.mdx` |
| 17 | + - Run `npm run ingest` to process |
| 18 | + |
| 19 | +### 2. Publishing Pipeline |
| 20 | + |
| 21 | +The main pipeline has five sequential steps: |
| 22 | + |
| 23 | +1. **Test** (`/content/src`) |
| 24 | + - Run all TypeScript examples |
| 25 | + - Verify code correctness |
| 26 | + |
| 27 | +2. **Publish** (`/content/raw` → `/content/published`) |
| 28 | + - Convert raw MDX to published format |
| 29 | + - Expand TypeScript examples inline |
| 30 | + |
| 31 | +3. **Validate** (`/content/published`) |
| 32 | + - Check frontmatter and sections |
| 33 | + - Verify code block consistency |
| 34 | + |
| 35 | +4. **Generate** (`README.md`) |
| 36 | + - Create main README |
| 37 | + - Group patterns by use case |
| 38 | + |
| 39 | +5. **Rules** (`/rules`) |
| 40 | + - Generate AI coding rules |
| 41 | + - Multiple output formats |
| 42 | + |
| 43 | +### Available Commands |
| 44 | + |
| 45 | +- `npm run ingest` - Process new patterns from `/content/new` |
| 46 | +- `npm run pipeline` - Run all publishing steps in sequence |
| 47 | +- `npm run all` - Alias for pipeline |
| 48 | + |
| 49 | +Individual pipeline steps: |
| 50 | +- `npm run test` - Run TypeScript examples |
| 51 | +- `npm run publish` - Convert raw to published MDX |
| 52 | +- `npm run validate` - Validate published files |
| 53 | +- `npm run generate` - Generate README |
| 54 | +- `npm run rules` - Generate AI rules |
| 55 | + |
| 56 | +### Validation Rules |
| 57 | + |
| 58 | +All patterns must have: |
| 59 | +1. Valid frontmatter with required fields |
| 60 | +2. A Good Example section with TypeScript code |
| 61 | +3. An Anti-Pattern section |
| 62 | +4. Either an Explanation or Rationale section |
| 63 | +5. TypeScript code that matches the source file |
| 64 | + |
| 65 | +## Adding New Patterns |
| 66 | + |
| 67 | +### Step 1: Create New Pattern Files |
| 68 | + |
| 69 | +Create your new pattern in the `/content/new` directory: |
| 70 | + |
| 71 | +1. Create the TypeScript example in `/content/new/src/{pattern-id}.ts` |
| 72 | +2. Create the MDX documentation in `/content/new/{pattern-id}.mdx` |
| 73 | + |
| 74 | +### Step 2: Run the Ingest Process |
| 75 | + |
| 76 | +Run `npm run ingest` to process your new pattern. This will: |
| 77 | +1. Validate your pattern files |
| 78 | +2. Move the TypeScript file to `/content/src` |
| 79 | +3. Move the MDX file to `/content/raw` |
| 80 | + |
| 81 | +If validation fails, fix the issues and try again. |
| 82 | + |
| 83 | +### Step 3: Run the Publishing Pipeline |
| 84 | + |
| 85 | +1. **Fill out your pattern** |
| 86 | + - Add your TypeScript code to the `.ts` file |
| 87 | + - Fill out the MDX template with your pattern details |
| 88 | + - Make sure to include all required sections |
| 89 | + |
| 90 | +2. **Run the pipeline** |
| 91 | + ```bash |
| 92 | + npm run pipeline |
| 93 | + ``` |
| 94 | + This will: |
| 95 | + - Run your TypeScript example |
| 96 | + - Convert and validate your MDX |
| 97 | + - Update README and rules |
| 98 | + |
| 99 | +3. **Submit a Pull Request** |
| 100 | + - Verify all pipeline steps passed |
| 101 | + - Include both your source files and generated files |
14 | 102 |
|
15 | 103 | ## The Pattern Structure |
16 | 104 |
|
|
0 commit comments