docspec 0.1.0 → 0.2.0
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.docspec.md +180 -0
- package/README.md +127 -31
- package/dist/__tests__/cli.test.js +27 -39
- package/dist/__tests__/cli.test.js.map +1 -1
- package/dist/__tests__/constants.test.js +8 -18
- package/dist/__tests__/constants.test.js.map +1 -1
- package/dist/__tests__/generator.test.js +16 -16
- package/dist/__tests__/generator.test.js.map +1 -1
- package/dist/__tests__/validator.test.js +50 -94
- package/dist/__tests__/validator.test.js.map +1 -1
- package/dist/cli.js +3 -4
- package/dist/cli.js.map +1 -1
- package/dist/constants.d.ts +3 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +52 -40
- package/dist/constants.js.map +1 -1
- package/dist/format-parser.d.ts +23 -0
- package/dist/format-parser.d.ts.map +1 -0
- package/dist/format-parser.js +175 -0
- package/dist/format-parser.js.map +1 -0
- package/dist/generator.d.ts +4 -5
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +9 -20
- package/dist/generator.js.map +1 -1
- package/dist/validator.js +5 -0
- package/dist/validator.js.map +1 -1
- package/docspec-format.md +45 -0
- package/package.json +4 -3
|
@@ -47,12 +47,12 @@ describe("generator", () => {
|
|
|
47
47
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
48
48
|
});
|
|
49
49
|
describe("generateDocspecContent", () => {
|
|
50
|
-
it("should generate content with
|
|
51
|
-
const content = (0, generator_1.generateDocspecContent)("
|
|
52
|
-
expect(content).toContain("# DOCSPEC:
|
|
50
|
+
it("should generate content with link to target file", () => {
|
|
51
|
+
const content = (0, generator_1.generateDocspecContent)("README.md");
|
|
52
|
+
expect(content).toContain("# DOCSPEC: [README.md](/README.md)");
|
|
53
53
|
});
|
|
54
54
|
it("should include all required sections", () => {
|
|
55
|
-
const content = (0, generator_1.generateDocspecContent)("
|
|
55
|
+
const content = (0, generator_1.generateDocspecContent)("test.md");
|
|
56
56
|
constants_1.REQUIRED_SECTIONS.forEach((section) => {
|
|
57
57
|
expect(content).toContain(section);
|
|
58
58
|
});
|
|
@@ -61,53 +61,53 @@ describe("generator", () => {
|
|
|
61
61
|
describe("generateDocspec", () => {
|
|
62
62
|
it("should generate a file at the specified path", async () => {
|
|
63
63
|
const filePath = path.join(tempDir, "test.docspec.md");
|
|
64
|
-
await (0, generator_1.generateDocspec)(filePath
|
|
64
|
+
await (0, generator_1.generateDocspec)(filePath);
|
|
65
65
|
const exists = await fs.access(filePath).then(() => true).catch(() => false);
|
|
66
66
|
expect(exists).toBe(true);
|
|
67
67
|
});
|
|
68
|
-
it("should
|
|
68
|
+
it("should generate link to target markdown file", async () => {
|
|
69
69
|
const filePath = path.join(tempDir, "test.docspec.md");
|
|
70
|
-
await (0, generator_1.generateDocspec)(filePath
|
|
70
|
+
await (0, generator_1.generateDocspec)(filePath);
|
|
71
71
|
const content = await fs.readFile(filePath, "utf-8");
|
|
72
|
-
expect(content).toContain("# DOCSPEC:
|
|
72
|
+
expect(content).toContain("# DOCSPEC: [test.md](/test.md)");
|
|
73
73
|
});
|
|
74
|
-
it("should extract
|
|
74
|
+
it("should extract target filename from docspec path", async () => {
|
|
75
75
|
const filePath = path.join(tempDir, "my-awesome-doc.docspec.md");
|
|
76
76
|
await (0, generator_1.generateDocspec)(filePath);
|
|
77
77
|
const content = await fs.readFile(filePath, "utf-8");
|
|
78
|
-
expect(content).toContain("# DOCSPEC:
|
|
78
|
+
expect(content).toContain("# DOCSPEC: [my-awesome-doc.md](/my-awesome-doc.md)");
|
|
79
79
|
});
|
|
80
80
|
it("should handle kebab-case filenames", async () => {
|
|
81
81
|
const filePath = path.join(tempDir, "api-reference.docspec.md");
|
|
82
82
|
await (0, generator_1.generateDocspec)(filePath);
|
|
83
83
|
const content = await fs.readFile(filePath, "utf-8");
|
|
84
|
-
expect(content).toContain("# DOCSPEC:
|
|
84
|
+
expect(content).toContain("# DOCSPEC: [api-reference.md](/api-reference.md)");
|
|
85
85
|
});
|
|
86
86
|
it("should handle snake_case filenames", async () => {
|
|
87
87
|
const filePath = path.join(tempDir, "user_guide.docspec.md");
|
|
88
88
|
await (0, generator_1.generateDocspec)(filePath);
|
|
89
89
|
const content = await fs.readFile(filePath, "utf-8");
|
|
90
|
-
expect(content).toContain("# DOCSPEC:
|
|
90
|
+
expect(content).toContain("# DOCSPEC: [user_guide.md](/user_guide.md)");
|
|
91
91
|
});
|
|
92
92
|
it("should create parent directories if they don't exist", async () => {
|
|
93
93
|
const filePath = path.join(tempDir, "nested", "deep", "test.docspec.md");
|
|
94
|
-
await (0, generator_1.generateDocspec)(filePath
|
|
94
|
+
await (0, generator_1.generateDocspec)(filePath);
|
|
95
95
|
const exists = await fs.access(filePath).then(() => true).catch(() => false);
|
|
96
96
|
expect(exists).toBe(true);
|
|
97
97
|
});
|
|
98
98
|
it("should generate valid markdown content", async () => {
|
|
99
99
|
const filePath = path.join(tempDir, "test.docspec.md");
|
|
100
|
-
await (0, generator_1.generateDocspec)(filePath
|
|
100
|
+
await (0, generator_1.generateDocspec)(filePath);
|
|
101
101
|
const content = await fs.readFile(filePath, "utf-8");
|
|
102
102
|
// Check structure
|
|
103
|
-
expect(content).toContain("---");
|
|
104
103
|
expect(content).toContain("# DOCSPEC:");
|
|
105
104
|
expect(content).toContain("## 1.");
|
|
106
105
|
expect(content).toContain("## 5.");
|
|
106
|
+
expect(content).toContain("[test.md](/test.md)");
|
|
107
107
|
});
|
|
108
108
|
it("should include all required sections in generated file", async () => {
|
|
109
109
|
const filePath = path.join(tempDir, "test.docspec.md");
|
|
110
|
-
await (0, generator_1.generateDocspec)(filePath
|
|
110
|
+
await (0, generator_1.generateDocspec)(filePath);
|
|
111
111
|
const content = await fs.readFile(filePath, "utf-8");
|
|
112
112
|
constants_1.REQUIRED_SECTIONS.forEach((section) => {
|
|
113
113
|
expect(content).toContain(section);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.test.js","sourceRoot":"","sources":["../../src/__tests__/generator.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,uCAAyB;AACzB,4CAAuE;AACvE,4CAAiD;AAEjD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"generator.test.js","sourceRoot":"","sources":["../../src/__tests__/generator.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,uCAAyB;AACzB,4CAAuE;AACvE,4CAAiD;AAEjD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAA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AO,EAAE,iBAAiB,CAAC,CAAC;YACvD,MAAM,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;YAEhC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACrD,6BAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBACpC,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -51,31 +51,27 @@ describe("validator", () => {
|
|
|
51
51
|
it("should validate a properly customized docspec file", async () => {
|
|
52
52
|
const filePath = path.join(tempDir, "valid.docspec.md");
|
|
53
53
|
// Create a valid docspec with customized content
|
|
54
|
-
const validContent =
|
|
55
|
-
|
|
56
|
-
# DOCSPEC: Test Document
|
|
54
|
+
const validContent = `# DOCSPEC: Test Document
|
|
57
55
|
|
|
58
56
|
> Short phrase: *Test document*
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## 1. Purpose of This Document
|
|
58
|
+
## 1. Document Purpose
|
|
63
59
|
|
|
64
60
|
This document describes the test suite for the docspec validator. It provides comprehensive test coverage for all validation scenarios and edge cases that the validator needs to handle correctly.
|
|
65
61
|
|
|
66
|
-
## 2.
|
|
62
|
+
## 2. Update Triggers
|
|
67
63
|
|
|
68
64
|
Update this document when adding new test cases or when the validation logic changes. It should always reflect the current state of the test suite.
|
|
69
65
|
|
|
70
|
-
## 3. Structure
|
|
66
|
+
## 3. Expected Structure
|
|
71
67
|
|
|
72
68
|
This section describes the test structure and how tests are organized. Each test file covers a specific module or functionality area of the docspec package.
|
|
73
69
|
|
|
74
|
-
## 4.
|
|
70
|
+
## 4. Editing Guidelines
|
|
75
71
|
|
|
76
72
|
Keep test descriptions clear and concise. Use descriptive test names that explain what is being tested. Follow the AAA pattern: Arrange, Act, Assert. Do: Write comprehensive tests that cover edge cases. Don't: Skip edge cases or write tests that are too simple. Always test both success and failure scenarios.
|
|
77
73
|
|
|
78
|
-
## 5.
|
|
74
|
+
## 5. Intentional Omissions
|
|
79
75
|
|
|
80
76
|
No gaps at this time. All major functionality is covered by the test suite.
|
|
81
77
|
`;
|
|
@@ -86,7 +82,7 @@ No gaps at this time. All major functionality is covered by the test suite.
|
|
|
86
82
|
});
|
|
87
83
|
it("should reject a file with only boilerplate content", async () => {
|
|
88
84
|
const filePath = path.join(tempDir, "boilerplate.docspec.md");
|
|
89
|
-
await (0, generator_1.generateDocspec)(filePath
|
|
85
|
+
await (0, generator_1.generateDocspec)(filePath);
|
|
90
86
|
const result = await (0, validator_1.validateDocspec)(filePath);
|
|
91
87
|
expect(result.valid).toBe(false);
|
|
92
88
|
expect(result.errors.length).toBeGreaterThan(0);
|
|
@@ -94,17 +90,13 @@ No gaps at this time. All major functionality is covered by the test suite.
|
|
|
94
90
|
});
|
|
95
91
|
it("should detect missing sections", async () => {
|
|
96
92
|
const filePath = path.join(tempDir, "incomplete.docspec.md");
|
|
97
|
-
const incompleteContent =
|
|
93
|
+
const incompleteContent = `# DOCSPEC: Test
|
|
98
94
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
## 1. Purpose of This Document
|
|
95
|
+
## 1. Document Purpose
|
|
104
96
|
|
|
105
97
|
Custom content here.
|
|
106
98
|
|
|
107
|
-
## 2.
|
|
99
|
+
## 2. Update Triggers
|
|
108
100
|
|
|
109
101
|
More custom content.
|
|
110
102
|
`;
|
|
@@ -116,11 +108,7 @@ More custom content.
|
|
|
116
108
|
});
|
|
117
109
|
it("should detect empty sections", async () => {
|
|
118
110
|
const filePath = path.join(tempDir, "empty-section.docspec.md");
|
|
119
|
-
let content =
|
|
120
|
-
|
|
121
|
-
# DOCSPEC: Test
|
|
122
|
-
|
|
123
|
-
---
|
|
111
|
+
let content = `# DOCSPEC: Test
|
|
124
112
|
|
|
125
113
|
`;
|
|
126
114
|
// Add all sections but leave one empty
|
|
@@ -133,7 +121,7 @@ More custom content.
|
|
|
133
121
|
else {
|
|
134
122
|
content += "Custom content for this section.\n";
|
|
135
123
|
}
|
|
136
|
-
content += "\n
|
|
124
|
+
content += "\n\n";
|
|
137
125
|
});
|
|
138
126
|
await fs.writeFile(filePath, content, "utf-8");
|
|
139
127
|
const result = await (0, validator_1.validateDocspec)(filePath);
|
|
@@ -142,29 +130,25 @@ More custom content.
|
|
|
142
130
|
});
|
|
143
131
|
it("should handle files with section numbers in headers", async () => {
|
|
144
132
|
const filePath = path.join(tempDir, "numbered.docspec.md");
|
|
145
|
-
const content =
|
|
133
|
+
const content = `# DOCSPEC: Test
|
|
146
134
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## 1. Purpose of This Document
|
|
135
|
+
## 1. Document Purpose
|
|
152
136
|
|
|
153
137
|
This document serves as a test case for validating docspec files with numbered section headers. It contains custom content that is different from the boilerplate template.
|
|
154
138
|
|
|
155
|
-
## 2.
|
|
139
|
+
## 2. Update Triggers
|
|
156
140
|
|
|
157
141
|
This document should be updated whenever the validation logic for numbered headers changes. It tests the parser's ability to handle section numbers correctly.
|
|
158
142
|
|
|
159
|
-
## 3. Structure
|
|
143
|
+
## 3. Expected Structure
|
|
160
144
|
|
|
161
145
|
This section describes the structure of the test document. It includes all required sections with sufficient content to pass validation checks.
|
|
162
146
|
|
|
163
|
-
## 4.
|
|
147
|
+
## 4. Editing Guidelines
|
|
164
148
|
|
|
165
149
|
The style for this test document is straightforward and technical. It focuses on clarity and precision in describing test scenarios. Do: Ensure all sections have adequate content. Don't: Use boilerplate text or leave sections empty. Always provide meaningful test data.
|
|
166
150
|
|
|
167
|
-
## 5.
|
|
151
|
+
## 5. Intentional Omissions
|
|
168
152
|
|
|
169
153
|
There are no known gaps in this test document. All sections are complete and properly formatted.
|
|
170
154
|
`;
|
|
@@ -174,29 +158,27 @@ There are no known gaps in this test document. All sections are complete and pro
|
|
|
174
158
|
});
|
|
175
159
|
it("should handle files without section numbers in headers", async () => {
|
|
176
160
|
const filePath = path.join(tempDir, "unnumbered.docspec.md");
|
|
177
|
-
const content =
|
|
178
|
-
|
|
179
|
-
# DOCSPEC: Test
|
|
161
|
+
const content = `# DOCSPEC: Test
|
|
180
162
|
|
|
181
163
|
---
|
|
182
164
|
|
|
183
|
-
## Purpose
|
|
165
|
+
## Document Purpose
|
|
184
166
|
|
|
185
167
|
This document serves as a test case for validating docspec files without numbered section headers. It contains custom content that differs from the boilerplate template.
|
|
186
168
|
|
|
187
|
-
##
|
|
169
|
+
## Update Triggers
|
|
188
170
|
|
|
189
171
|
This document should be updated whenever the validation logic for unnumbered headers changes. It tests the parser's flexibility in handling different header formats.
|
|
190
172
|
|
|
191
|
-
## Structure
|
|
173
|
+
## Expected Structure
|
|
192
174
|
|
|
193
175
|
This section describes the structure of the test document. It includes all required sections with sufficient content to pass validation checks.
|
|
194
176
|
|
|
195
|
-
##
|
|
177
|
+
## Editing Guidelines
|
|
196
178
|
|
|
197
179
|
The style for this test document is straightforward and technical. It focuses on clarity and precision in describing test scenarios. Do: Ensure all sections have adequate content. Don't: Use boilerplate text or leave sections empty. Always provide meaningful test data.
|
|
198
180
|
|
|
199
|
-
##
|
|
181
|
+
## Intentional Omissions
|
|
200
182
|
|
|
201
183
|
There are no known gaps in this test document. All sections are complete and properly formatted.
|
|
202
184
|
`;
|
|
@@ -204,54 +186,38 @@ There are no known gaps in this test document. All sections are complete and pro
|
|
|
204
186
|
const result = await (0, validator_1.validateDocspec)(filePath);
|
|
205
187
|
expect(result.valid).toBe(true);
|
|
206
188
|
});
|
|
207
|
-
it("should
|
|
208
|
-
const filePath = path.join(tempDir, "
|
|
209
|
-
const content =
|
|
210
|
-
|
|
211
|
-
# DOCSPEC: Test
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## 1. Purpose of This Document
|
|
189
|
+
it("should handle files without separators between sections", async () => {
|
|
190
|
+
const filePath = path.join(tempDir, "no-separators.docspec.md");
|
|
191
|
+
const content = `# DOCSPEC: Test
|
|
216
192
|
|
|
217
|
-
|
|
193
|
+
## 1. Document Purpose
|
|
218
194
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
## 2. When This Document Should Be Updated
|
|
195
|
+
This document tests the validator's ability to handle files without separator lines between sections. The content here is custom and different from boilerplate.
|
|
222
196
|
|
|
223
|
-
|
|
197
|
+
## 2. Update Triggers
|
|
224
198
|
|
|
225
|
-
|
|
199
|
+
This document should be updated when testing files without separators. The content is sufficient to pass validation.
|
|
226
200
|
|
|
227
|
-
## 3. Structure
|
|
201
|
+
## 3. Expected Structure
|
|
228
202
|
|
|
229
203
|
This section describes the document structure. It includes all required sections with adequate content length.
|
|
230
204
|
|
|
231
|
-
|
|
205
|
+
## 4. Editing Guidelines
|
|
232
206
|
|
|
233
|
-
|
|
207
|
+
The style rules for this test document are straightforward. Content is technical and precise. Do: Test files without separators. Don't: Require separators for validation. Ensure content is meaningful.
|
|
234
208
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
## 5. Known Gaps or Intentional Omissions
|
|
209
|
+
## 5. Intentional Omissions
|
|
240
210
|
|
|
241
211
|
No gaps in this test document. All sections are complete with sufficient content.
|
|
242
212
|
`;
|
|
243
213
|
await fs.writeFile(filePath, content, "utf-8");
|
|
244
214
|
const result = await (0, validator_1.validateDocspec)(filePath);
|
|
245
|
-
// Should be valid
|
|
215
|
+
// Should be valid without separators
|
|
246
216
|
expect(result.valid).toBe(true);
|
|
247
217
|
});
|
|
248
218
|
it("should reject content that only differs by whitespace from boilerplate", async () => {
|
|
249
219
|
const filePath = path.join(tempDir, "whitespace-only.docspec.md");
|
|
250
|
-
let content =
|
|
251
|
-
|
|
252
|
-
# DOCSPEC: Test
|
|
253
|
-
|
|
254
|
-
---
|
|
220
|
+
let content = `# DOCSPEC: Test
|
|
255
221
|
|
|
256
222
|
`;
|
|
257
223
|
// Create content that's just boilerplate with different whitespace
|
|
@@ -260,7 +226,7 @@ No gaps in this test document. All sections are complete with sufficient content
|
|
|
260
226
|
// Use boilerplate but with extra spaces
|
|
261
227
|
const boilerplate = constants_1.SECTION_BOILERPLATE[section];
|
|
262
228
|
content += boilerplate.replace(/\n/g, " \n") + "\n";
|
|
263
|
-
content += "\n
|
|
229
|
+
content += "\n\n";
|
|
264
230
|
});
|
|
265
231
|
await fs.writeFile(filePath, content, "utf-8");
|
|
266
232
|
const result = await (0, validator_1.validateDocspec)(filePath);
|
|
@@ -269,11 +235,7 @@ No gaps in this test document. All sections are complete with sufficient content
|
|
|
269
235
|
});
|
|
270
236
|
it("should reject sections that are too short", async () => {
|
|
271
237
|
const filePath = path.join(tempDir, "short-section.docspec.md");
|
|
272
|
-
let content =
|
|
273
|
-
|
|
274
|
-
# DOCSPEC: Test
|
|
275
|
-
|
|
276
|
-
---
|
|
238
|
+
let content = `# DOCSPEC: Test
|
|
277
239
|
|
|
278
240
|
`;
|
|
279
241
|
constants_1.REQUIRED_SECTIONS.forEach((section, index) => {
|
|
@@ -285,7 +247,7 @@ No gaps in this test document. All sections are complete with sufficient content
|
|
|
285
247
|
else {
|
|
286
248
|
content += "This is a longer section with enough content to pass validation.\n";
|
|
287
249
|
}
|
|
288
|
-
content += "\n
|
|
250
|
+
content += "\n\n";
|
|
289
251
|
});
|
|
290
252
|
await fs.writeFile(filePath, content, "utf-8");
|
|
291
253
|
const result = await (0, validator_1.validateDocspec)(filePath);
|
|
@@ -301,29 +263,25 @@ No gaps in this test document. All sections are complete with sufficient content
|
|
|
301
263
|
});
|
|
302
264
|
it("should handle files with extra sections (non-required)", async () => {
|
|
303
265
|
const filePath = path.join(tempDir, "extra-sections.docspec.md");
|
|
304
|
-
const content =
|
|
266
|
+
const content = `# DOCSPEC: Test
|
|
305
267
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
---
|
|
309
|
-
|
|
310
|
-
## 1. Purpose of This Document
|
|
268
|
+
## 1. Document Purpose
|
|
311
269
|
|
|
312
270
|
This document tests the validator's handling of extra sections beyond the required ones. The content is custom and sufficient to pass validation.
|
|
313
271
|
|
|
314
|
-
## 2.
|
|
272
|
+
## 2. Update Triggers
|
|
315
273
|
|
|
316
274
|
This document should be updated when testing extra section handling. The content is meaningful and not boilerplate.
|
|
317
275
|
|
|
318
|
-
## 3. Structure
|
|
276
|
+
## 3. Expected Structure
|
|
319
277
|
|
|
320
278
|
This section describes the document structure including both required and optional sections. All content is customized.
|
|
321
279
|
|
|
322
|
-
## 4.
|
|
280
|
+
## 4. Editing Guidelines
|
|
323
281
|
|
|
324
282
|
The style rules for this test document are clear and technical. Content is sufficient in length. Do: Test extra sections. Don't: Reject valid documents with additional sections. Ensure all required sections are present.
|
|
325
283
|
|
|
326
|
-
## 5.
|
|
284
|
+
## 5. Intentional Omissions
|
|
327
285
|
|
|
328
286
|
No gaps in this test document. All sections are complete with adequate content.
|
|
329
287
|
|
|
@@ -338,9 +296,7 @@ This is an extra section that shouldn't cause validation to fail. It contains ad
|
|
|
338
296
|
});
|
|
339
297
|
it("should handle case-insensitive section matching", async () => {
|
|
340
298
|
const filePath = path.join(tempDir, "case-test.docspec.md");
|
|
341
|
-
const content =
|
|
342
|
-
|
|
343
|
-
# DOCSPEC: Test
|
|
299
|
+
const content = `# DOCSPEC: Test
|
|
344
300
|
|
|
345
301
|
---
|
|
346
302
|
|
|
@@ -352,15 +308,15 @@ Custom content.
|
|
|
352
308
|
|
|
353
309
|
Custom content.
|
|
354
310
|
|
|
355
|
-
## 3. Structure
|
|
311
|
+
## 3. Expected Structure
|
|
356
312
|
|
|
357
313
|
Custom content.
|
|
358
314
|
|
|
359
|
-
## 4.
|
|
315
|
+
## 4. Editing Guidelines
|
|
360
316
|
|
|
361
317
|
Custom style and editing guidelines content.
|
|
362
318
|
|
|
363
|
-
## 5.
|
|
319
|
+
## 5. Intentional Omissions
|
|
364
320
|
|
|
365
321
|
Custom gaps content.
|
|
366
322
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.test.js","sourceRoot":"","sources":["../../src/__tests__/validator.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,uCAAyB;AACzB,4CAA+C;AAC/C,4CAA+C;AAC/C,4CAAsE;AAEtE,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC/B,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;YAClE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;YAExD,iDAAiD;YACjD,MAAM,YAAY,GAAG
|
|
1
|
+
{"version":3,"file":"validator.test.js","sourceRoot":"","sources":["../../src/__tests__/validator.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,uCAAyB;AACzB,4CAA+C;AAC/C,4CAA+C;AAC/C,4CAAsE;AAEtE,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KA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AEH,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;YAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;YAE5D,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;CAuBrB,CAAC;YAEI,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/C,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;YAE/C,+DAA+D;YAC/D,iEAAiE;YACjE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -83,15 +83,14 @@ program
|
|
|
83
83
|
program
|
|
84
84
|
.command("generate")
|
|
85
85
|
.description("Generate a new docspec file")
|
|
86
|
-
.argument("<path>", "Path where the docspec file should be created")
|
|
87
|
-
.
|
|
88
|
-
.action(async (filePath, options) => {
|
|
86
|
+
.argument("<path>", "Path where the docspec file should be created (must end with .docspec.md)")
|
|
87
|
+
.action(async (filePath) => {
|
|
89
88
|
try {
|
|
90
89
|
// Ensure the path ends with .docspec.md
|
|
91
90
|
if (!filePath.endsWith(".docspec.md")) {
|
|
92
91
|
filePath = filePath + ".docspec.md";
|
|
93
92
|
}
|
|
94
|
-
await (0, generator_1.generateDocspec)(filePath
|
|
93
|
+
await (0, generator_1.generateDocspec)(filePath);
|
|
95
94
|
console.log(`✅ Generated docspec file: ${filePath}`);
|
|
96
95
|
}
|
|
97
96
|
catch (error) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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AK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Required section headers for docspec files
|
|
3
3
|
*/
|
|
4
|
-
export declare const REQUIRED_SECTIONS: readonly [
|
|
4
|
+
export declare const REQUIRED_SECTIONS: readonly string[];
|
|
5
5
|
/**
|
|
6
6
|
* Boilerplate template text for each section
|
|
7
7
|
*/
|
|
8
8
|
export declare const SECTION_BOILERPLATE: Record<string, string>;
|
|
9
9
|
/**
|
|
10
10
|
* Generate the full docspec template
|
|
11
|
+
* @param targetFilePath The path to the target markdown file (e.g., "README.md")
|
|
11
12
|
*/
|
|
12
|
-
export declare function getDocspecTemplate(
|
|
13
|
+
export declare function getDocspecTemplate(targetFilePath: string): string;
|
|
13
14
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,eAAO,MAAM,iBAAiB,mBAG1B,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOnD,CAAC;AAEL;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CA0BjE"}
|
package/dist/constants.js
CHANGED
|
@@ -2,54 +2,66 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SECTION_BOILERPLATE = exports.REQUIRED_SECTIONS = void 0;
|
|
4
4
|
exports.getDocspecTemplate = getDocspecTemplate;
|
|
5
|
+
const format_parser_1 = require("./format-parser");
|
|
6
|
+
let cachedFormat = null;
|
|
7
|
+
/**
|
|
8
|
+
* Load and cache the format definition
|
|
9
|
+
*/
|
|
10
|
+
function loadFormat() {
|
|
11
|
+
if (cachedFormat) {
|
|
12
|
+
return cachedFormat;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const formatPath = (0, format_parser_1.getFormatFilePath)();
|
|
16
|
+
cachedFormat = (0, format_parser_1.parseFormatFile)(formatPath);
|
|
17
|
+
return cachedFormat;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new Error(`Failed to load docspec format file: ${error instanceof Error ? error.message : String(error)}\n` +
|
|
21
|
+
`Make sure docspec-format.md exists in the project root.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
5
24
|
/**
|
|
6
25
|
* Required section headers for docspec files
|
|
7
26
|
*/
|
|
8
|
-
exports.REQUIRED_SECTIONS =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"Style & Editing Guidelines",
|
|
13
|
-
"Known Gaps or Intentional Omissions",
|
|
14
|
-
];
|
|
27
|
+
exports.REQUIRED_SECTIONS = (() => {
|
|
28
|
+
const format = loadFormat();
|
|
29
|
+
return format.sections.map(s => s.name);
|
|
30
|
+
})();
|
|
15
31
|
/**
|
|
16
32
|
* Boilerplate template text for each section
|
|
17
33
|
*/
|
|
18
|
-
exports.SECTION_BOILERPLATE = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
For each section, specify: its name/role, what it should cover (conceptual, not literal), and any constraints (e.g., "Keep high-level; don't enumerate every file").`,
|
|
28
|
-
"Style & Editing Guidelines": `Rules **specific to this doc or directory**, not global writing rules.
|
|
29
|
-
|
|
30
|
-
Include both style preferences (e.g., "Use non-technical language" or "Prefer bullet lists") and concrete editing guidelines (e.g., "Do: Update examples when APIs change" or "Don't: Remove placeholder sections").`,
|
|
31
|
-
"Known Gaps or Intentional Omissions": `Note things that **should not be documented yet** or are deliberately vague.
|
|
32
|
-
|
|
33
|
-
Examples: "Auth design is intentionally not detailed here; see \`/security/README.md\`" or "This doc avoids internal business logic; keep it conceptual."`,
|
|
34
|
-
};
|
|
34
|
+
exports.SECTION_BOILERPLATE = (() => {
|
|
35
|
+
const format = loadFormat();
|
|
36
|
+
const boilerplate = {};
|
|
37
|
+
for (const section of format.sections) {
|
|
38
|
+
boilerplate[section.name] = section.boilerplate;
|
|
39
|
+
}
|
|
40
|
+
return boilerplate;
|
|
41
|
+
})();
|
|
35
42
|
/**
|
|
36
43
|
* Generate the full docspec template
|
|
44
|
+
* @param targetFilePath The path to the target markdown file (e.g., "README.md")
|
|
37
45
|
*/
|
|
38
|
-
function getDocspecTemplate(
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`;
|
|
46
|
+
function getDocspecTemplate(targetFilePath) {
|
|
47
|
+
const format = loadFormat();
|
|
48
|
+
// Replace {{TARGET_FILE}} in template
|
|
49
|
+
let template = format.template.replace(/\{\{TARGET_FILE\}\}/g, targetFilePath);
|
|
50
|
+
// Handle agent instructions if present
|
|
51
|
+
let agentInstructionsSection = "";
|
|
52
|
+
if (format.agentInstructions) {
|
|
53
|
+
// Replace {{TARGET_FILE}} in agent instructions
|
|
54
|
+
const agentContent = format.agentInstructions.replace(/\{\{TARGET_FILE\}\}/g, targetFilePath);
|
|
55
|
+
agentInstructionsSection = `## AGENT INSTRUCTIONS\n\n${agentContent}\n\n`;
|
|
56
|
+
}
|
|
57
|
+
// Replace {{AGENT_INSTRUCTIONS}} placeholder
|
|
58
|
+
template = template.replace(/\{\{AGENT_INSTRUCTIONS\}\}/g, agentInstructionsSection);
|
|
59
|
+
// Generate sections
|
|
60
|
+
const sections = format.sections.map((section) => {
|
|
61
|
+
return `## ${section.number}. ${section.name}\n\n${section.boilerplate}`;
|
|
62
|
+
}).join("\n\n");
|
|
63
|
+
// Replace {{SECTIONS}} placeholder
|
|
64
|
+
template = template.replace(/\{\{SECTIONS\}\}/g, sections);
|
|
65
|
+
return template;
|
|
54
66
|
}
|
|
55
67
|
//# sourceMappingURL=constants.js.map
|