Skip to content

Commit 412e870

Browse files
azuclaude
andauthored
docs: improve textlint-website-generator README with comprehensive usage instructions (#114)
- Add clear overview and features section - Expand usage examples from basic to advanced - Document all CLI options with detailed explanations - Add 'How It Works' technical explanation - Include configuration details for package.json and .textlintrc - Document project structure for developers - Add integration notes for textlint-editor browser extension 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent d590063 commit 412e870

File tree

1 file changed

+118
-6
lines changed
  • packages/@textlint/website-generator

1 file changed

+118
-6
lines changed

packages/@textlint/website-generator/README.md

Lines changed: 118 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
# @textlint/website-generator
22

3-
Website generator using @textlint/script-compiler
3+
A website generator that creates a standalone web application for textlint, allowing users to lint text directly in the browser using your configured textlint rules.
4+
5+
## Overview
6+
7+
`@textlint/website-generator` compiles your textlint configuration and rules into a web worker script and generates a complete website with an interactive text editor. This enables users to experience your textlint rules without any installation.
8+
9+
## Features
10+
11+
- Generates a standalone website with textlint functionality
12+
- Compiles textlint rules to run in web workers
13+
- Creates an interactive text editor with real-time linting
14+
- Supports custom styling with title and placeholder text
15+
- Works with existing `.textlintrc` configuration files
16+
- Automatically infers metadata from `package.json`
417

518
## Install
619

@@ -10,6 +23,16 @@ Install with [npm](https://www.npmjs.com/):
1023

1124
## Usage
1225

26+
### Basic Usage
27+
28+
Generate a website using your existing `.textlintrc` configuration:
29+
30+
```bash
31+
textlint-website-generator --output-dir ./dist
32+
```
33+
34+
### Command Line Options
35+
1336
Usage
1437
$ textlint-website-generator
1538

@@ -18,13 +41,102 @@ Install with [npm](https://www.npmjs.com/):
1841
--placeholder [String] Placeholder text in generated website
1942
--cwd current working directory
2043
--textlintrc [path:String] path to .textlintrc file. Default: load .textlintrc.{json,yaml,js}
21-
--output-dir [path:String] output file path that is written of reported result.
22-
--metadataName [String] generated script name
23-
--metadataNamespace [String] generated script namespace
44+
--output-dir [path:String] output directory for generated website files (required)
45+
46+
Metadata Options
47+
Metadata is inferred from package.json by default.
48+
If you want to set metadata manually, use these flags:
49+
50+
--metadataName [String] generated script name
51+
--metadataNamespace [String] generated script namespace (URL)
52+
--metadataHomepage [String] generated script homepage URL
53+
--metadataVersion [String] generated script version
2454

2555
Examples
26-
$ textlint-website-generator --output-dir ./dist --metadataName "script name" --metadataNamespace "https://example.com"
27-
$ textlint-website-generator --output-dir ./dist --metadataName "script name" --metadataNamespace "https://example.com" --title "rule tester" --placeholder "default text"
56+
# Basic usage with package.json metadata
57+
$ textlint-website-generator --output-dir ./dist
58+
59+
# Custom title and placeholder
60+
$ textlint-website-generator --output-dir ./dist --title "My Textlint Rules" --placeholder "Type or paste your text here..."
61+
62+
# Manual metadata configuration
63+
$ textlint-website-generator --output-dir ./dist --metadataName "my-rules" --metadataNamespace "https://example.com"
64+
65+
# Full customization
66+
$ textlint-website-generator --output-dir ./dist --metadataName "script name" --metadataNamespace "https://example.com" --title "rule tester" --placeholder "default text"
67+
68+
## How It Works
69+
70+
1. **Compilation**: The generator uses `@textlint/script-compiler` to compile your textlint configuration and rules into a web worker script (`textlint-worker.js`)
71+
72+
2. **Template Generation**: It creates an HTML page with:
73+
- An interactive textarea for text input
74+
- Integration with `textchecker-element` for real-time linting
75+
- Support for the textlint-editor browser extension
76+
77+
3. **Output**: The generator produces:
78+
- `index.html` - The main webpage
79+
- `textlint-worker.js` - Compiled textlint rules as a web worker
80+
- `textchecker-element.esm.js` - UI component for text checking
81+
82+
## Configuration
83+
84+
### Using package.json
85+
86+
By default, the generator reads metadata from your `package.json`:
87+
88+
```json
89+
{
90+
"name": "my-textlint-rules",
91+
"version": "1.0.0",
92+
"homepage": "https://github.com/username/my-textlint-rules"
93+
}
94+
```
95+
96+
### Using .textlintrc
97+
98+
The generator automatically loads your textlint configuration from:
99+
- `.textlintrc`
100+
- `.textlintrc.json`
101+
- `.textlintrc.yaml`
102+
- `.textlintrc.js`
103+
104+
Or specify a custom path:
105+
106+
```bash
107+
textlint-website-generator --textlintrc ./config/.textlintrc.json --output-dir ./dist
108+
```
109+
110+
## Development Workflow
111+
112+
### Building the Template
113+
114+
The package includes a script to generate the template files:
115+
116+
```bash
117+
npm run generate-template
118+
```
119+
120+
This runs before packaging to ensure the latest template is included.
121+
122+
### Project Structure
123+
124+
```
125+
packages/@textlint/website-generator/
126+
├── bin/
127+
│ └── cmd.js # CLI entry point
128+
├── src/
129+
│ ├── cli.ts # CLI implementation
130+
│ └── website-generator.ts # Core generator logic
131+
├── template/
132+
│ ├── index.html # HTML template
133+
│ └── textchecker-element.esm.js # UI component
134+
└── lib/ # Compiled JavaScript output
135+
```
136+
137+
## Integration with textlint-editor
138+
139+
The generated website can work with the [textlint-editor browser extension](https://github.com/textlint/editor) for enhanced functionality. Users can install custom rule scripts using the "Install" button on the generated page.
28140

29141
## Changelog
30142

0 commit comments

Comments
 (0)