docsguard 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
**Leer en otros idiomas: [Español](README.es.md)**
|
|
4
|
+
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
# DocsGuard
|
|
8
|
+
|
|
9
|
+
**Documentation Integrity Engine** — Eliminates code-documentation drift through heuristic validation, multi-format parsing, and interactive correction.
|
|
10
|
+
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## The Problem
|
|
16
|
+
|
|
17
|
+
Documentation drifts from code silently. Arguments get renamed, parameters get added, types change — and the docs stay frozen in time. By the time someone notices, the damage is done.
|
|
18
|
+
|
|
19
|
+
## The Solution
|
|
20
|
+
|
|
21
|
+
DocsGuard links functions directly to their documentation sections and validates them automatically:
|
|
22
|
+
|
|
23
|
+
- **Static link validation** — Does the documented section actually exist?
|
|
24
|
+
- **Ghost argument detection** — Is something documented that doesn't exist in code?
|
|
25
|
+
- **Missing argument detection** — Is there a code parameter missing from docs?
|
|
26
|
+
- **Type mismatch detection** — Does `string` in docs match `i32` in code?
|
|
27
|
+
- **Interactive scaffold** — Never modifies code without explicit permission
|
|
28
|
+
- **Baseline system** — Adopt on legacy projects with zero CI breakage on Day 1
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
### Installation
|
|
33
|
+
|
|
34
|
+
**Via npm (Recommended):**
|
|
35
|
+
```bash
|
|
36
|
+
npm install -g docsguard
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**From source (Rust):**
|
|
40
|
+
```bash
|
|
41
|
+
cargo install --path .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 1. Annotate your code
|
|
45
|
+
|
|
46
|
+
Add `@docs` annotations above functions to link them to documentation:
|
|
47
|
+
|
|
48
|
+
```rust
|
|
49
|
+
/// @docs: [auth-login]
|
|
50
|
+
fn login(username: &str, password: &str) -> Result<Token> {
|
|
51
|
+
// ...
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 2. Mark your docs
|
|
56
|
+
|
|
57
|
+
Add invisible markers in your Markdown documentation:
|
|
58
|
+
|
|
59
|
+
```markdown
|
|
60
|
+
<!-- @docs-id: auth-login -->
|
|
61
|
+
## Login
|
|
62
|
+
|
|
63
|
+
Authenticates a user with credentials.
|
|
64
|
+
|
|
65
|
+
| Param | Type | Description |
|
|
66
|
+
|----------|--------|----------------------|
|
|
67
|
+
| username | string | The user's login name |
|
|
68
|
+
| password | string | The user's password |
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 3. Validate
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
docsguard check src/auth.rs docs/api.md
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
[i] Info en fn login (src/auth.rs:3)
|
|
79
|
+
-> Enlace verificado: fn login <-> sección 'Login'
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
Resumen: 0 errores, 0 advertencias, 1 total
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Commands
|
|
86
|
+
|
|
87
|
+
### `docsguard check <doc_file> <code_files>...`
|
|
88
|
+
|
|
89
|
+
Validates links between code and documentation. Exits with code 1 if errors are found (CI-friendly).
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
docsguard check docs/api.md src/main.rs
|
|
93
|
+
docsguard check docs/api.md src/core/validator.rs src/parser/*.rs
|
|
94
|
+
docsguard check docs/api.md src/main.rs --project-root . # use baseline
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `docsguard scaffold <code_file> <doc_file>`
|
|
98
|
+
|
|
99
|
+
Interactive TUI that suggests links between unlinked functions and doc sections using Levenshtein heuristics (>80% confidence).
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
docsguard scaffold src/main.rs docs/api.md # interactive
|
|
103
|
+
docsguard scaffold src/main.rs docs/api.md --dry-run # preview only
|
|
104
|
+
docsguard scaffold src/main.rs docs/api.md --force # accept all
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `docsguard watch <code_file> <doc_file>`
|
|
108
|
+
|
|
109
|
+
Watches files for changes and re-validates automatically (<200ms response).
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
docsguard watch src/main.rs docs/api.md
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### `docsguard baseline <code_file> <doc_file>`
|
|
116
|
+
|
|
117
|
+
Dumps current errors to `.docsguard/baseline.yaml` so CI passes immediately. Only *new* regressions will be blocked.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
docsguard baseline src/main.rs docs/api.md --project-root .
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Supported Languages
|
|
124
|
+
|
|
125
|
+
| Language | Extensions | Parser |
|
|
126
|
+
|------------|------------------|-------------|
|
|
127
|
+
| TypeScript | `.ts`, `.tsx` | tree-sitter |
|
|
128
|
+
| JavaScript | `.js`, `.jsx` | tree-sitter |
|
|
129
|
+
| Rust | `.rs` | tree-sitter |
|
|
130
|
+
|
|
131
|
+
## Documentation Formats
|
|
132
|
+
|
|
133
|
+
DocsGuard parses three argument documentation formats automatically:
|
|
134
|
+
|
|
135
|
+
**Tables:**
|
|
136
|
+
```markdown
|
|
137
|
+
| Param | Type | Description |
|
|
138
|
+
|-------|------|-------------|
|
|
139
|
+
| name | string | The user's name |
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Lists:**
|
|
143
|
+
```markdown
|
|
144
|
+
- name: The user's name
|
|
145
|
+
- `email` (`string`): The user's email
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Definitions:**
|
|
149
|
+
```markdown
|
|
150
|
+
`name` (`string`): The user's name
|
|
151
|
+
`email` (`string`): The user's email
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Docker
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
docker build -t docsguard .
|
|
158
|
+
docker run --rm -v $(pwd):/workspace docsguard check src/main.rs docs/api.md
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## CI Integration
|
|
162
|
+
|
|
163
|
+
Add to your GitHub Actions workflow:
|
|
164
|
+
|
|
165
|
+
```yaml
|
|
166
|
+
- name: DocsGuard Check
|
|
167
|
+
run: |
|
|
168
|
+
cargo install --path .
|
|
169
|
+
docsguard check src/main.rs docs/api.md
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Or use the baseline for gradual adoption:
|
|
173
|
+
|
|
174
|
+
```yaml
|
|
175
|
+
- name: DocsGuard Check (with baseline)
|
|
176
|
+
run: |
|
|
177
|
+
cargo install --path .
|
|
178
|
+
docsguard check src/main.rs docs/api.md --project-root .
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Type Normalization
|
|
182
|
+
|
|
183
|
+
DocsGuard normalizes types before comparison, so these are considered equivalent:
|
|
184
|
+
|
|
185
|
+
| Code Type | Doc Type | Normalized |
|
|
186
|
+
|-----------|----------|------------|
|
|
187
|
+
| `&str` | `String` | string |
|
|
188
|
+
| `i32` | `number` | number |
|
|
189
|
+
| `bool` | `Boolean`| boolean |
|
|
190
|
+
| `UUID` | `String` | string |
|
|
191
|
+
|
|
192
|
+
## Architecture
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
src/
|
|
196
|
+
main.rs CLI entry point (clap)
|
|
197
|
+
core/
|
|
198
|
+
types.rs Domain types: CodeEntity, DocSection, Arg, ValidationResult
|
|
199
|
+
validator.rs Link validation + argument checking + type mismatch
|
|
200
|
+
heuristic.rs Levenshtein-based matching (strsim)
|
|
201
|
+
parser/
|
|
202
|
+
code_parser.rs Language detection + @docs annotation extraction
|
|
203
|
+
doc_parser.rs pulldown-cmark: Table, List, Definition strategies
|
|
204
|
+
lang/
|
|
205
|
+
typescript.rs tree-sitter TypeScript/JavaScript parser
|
|
206
|
+
rust.rs tree-sitter Rust parser
|
|
207
|
+
interactive/mod.rs Scaffold TUI (dialoguer)
|
|
208
|
+
watch/mod.rs File watch mode (notify)
|
|
209
|
+
baseline/mod.rs Baseline system (serde_yaml)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
package/package.json
CHANGED