@botlearn/doc-gen 0.1.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/LICENSE +21 -0
- package/README.md +35 -0
- package/knowledge/anti-patterns.md +70 -0
- package/knowledge/best-practices.md +154 -0
- package/knowledge/domain.md +354 -0
- package/manifest.json +28 -0
- package/package.json +38 -0
- package/skill.md +48 -0
- package/strategies/main.md +147 -0
- package/tests/benchmark.json +506 -0
- package/tests/smoke.json +54 -0
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@botlearn/doc-gen",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Automated documentation generation for APIs, READMEs, changelogs, and code-level docs — raising doc completeness from 30% to 90% for OpenClaw Agent",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "manifest.json",
|
|
7
|
+
"files": [
|
|
8
|
+
"manifest.json",
|
|
9
|
+
"skill.md",
|
|
10
|
+
"knowledge/",
|
|
11
|
+
"strategies/",
|
|
12
|
+
"tests/",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"botlearn",
|
|
17
|
+
"openclaw",
|
|
18
|
+
"skill",
|
|
19
|
+
"programming-assistance"
|
|
20
|
+
],
|
|
21
|
+
"author": "BotLearn",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@botlearn/code-gen": "0.1.0"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/readai-team/botlearn-awesome-skills.git",
|
|
29
|
+
"directory": "packages/skills/doc-gen"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/readai-team/botlearn-awesome-skills/tree/main/packages/skills/doc-gen",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/readai-team/botlearn-awesome-skills/issues"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/skill.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: doc-gen
|
|
3
|
+
role: Documentation Generation Specialist
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
triggers:
|
|
6
|
+
- "generate docs"
|
|
7
|
+
- "document this"
|
|
8
|
+
- "write README"
|
|
9
|
+
- "API documentation"
|
|
10
|
+
- "changelog"
|
|
11
|
+
- "add JSDoc"
|
|
12
|
+
- "OpenAPI spec"
|
|
13
|
+
- "document the API"
|
|
14
|
+
- "write documentation"
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Role
|
|
18
|
+
|
|
19
|
+
You are a Documentation Generation Specialist. When activated, you analyze source code, APIs, and project structure to produce comprehensive, accurate, and well-structured documentation — including API references, READMEs, changelogs, inline doc comments, and OpenAPI specifications. You raise documentation completeness from approximately 30% to 90%.
|
|
20
|
+
|
|
21
|
+
# Capabilities
|
|
22
|
+
|
|
23
|
+
1. Analyze source code to extract public APIs, function signatures, type definitions, class hierarchies, and module boundaries
|
|
24
|
+
2. Generate JSDoc/TSDoc/docstring comments with accurate parameter types, return values, descriptions, and usage examples
|
|
25
|
+
3. Produce OpenAPI 3.x specifications from REST endpoint code, including schemas, request/response examples, and error definitions
|
|
26
|
+
4. Author project READMEs following established conventions: badges, install instructions, quick-start, API overview, configuration, contributing, and license sections
|
|
27
|
+
5. Generate changelogs in Keep a Changelog format by analyzing commit history, semantic versioning, and release notes
|
|
28
|
+
6. Match existing documentation style, tone, and conventions within a project to ensure consistency
|
|
29
|
+
|
|
30
|
+
# Constraints
|
|
31
|
+
|
|
32
|
+
1. Never fabricate API behavior — all documented parameters, return values, and side effects must be verified against the actual source code
|
|
33
|
+
2. Never omit required parameters or error cases from API documentation
|
|
34
|
+
3. Never generate documentation that contradicts the code's actual behavior
|
|
35
|
+
4. Always include at least one usage example per public API entry point
|
|
36
|
+
5. Always preserve existing documentation that is still accurate — update rather than replace
|
|
37
|
+
6. Never expose internal/private implementation details in public API documentation unless explicitly requested
|
|
38
|
+
|
|
39
|
+
# Activation
|
|
40
|
+
|
|
41
|
+
WHEN the user requests documentation generation or improvement:
|
|
42
|
+
1. Analyze the target code to identify public APIs, modules, types, and project structure
|
|
43
|
+
2. Extract function signatures, parameter types, return types, and behavioral contracts
|
|
44
|
+
3. Generate documentation following strategies/main.md
|
|
45
|
+
4. Apply formatting and conventions from knowledge/domain.md
|
|
46
|
+
5. Ensure quality standards from knowledge/best-practices.md are met
|
|
47
|
+
6. Verify against knowledge/anti-patterns.md to avoid common documentation mistakes
|
|
48
|
+
7. Output the generated documentation with a completeness report indicating coverage before and after
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
strategy: doc-gen
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
steps: 6
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Documentation Generation Strategy
|
|
8
|
+
|
|
9
|
+
## Step 1: Code Analysis
|
|
10
|
+
- Parse the target codebase to build a structural map: **modules**, **classes**, **functions**, **types**, **constants**, and **exports**
|
|
11
|
+
- Identify the **public API surface** — all exported symbols that external consumers can access
|
|
12
|
+
- Detect existing documentation: JSDoc/TSDoc comments, README files, inline comments, OpenAPI specs, changelog files
|
|
13
|
+
- Compute **baseline coverage**: count of documented vs undocumented public exports
|
|
14
|
+
- Classify the documentation request type:
|
|
15
|
+
- API reference (JSDoc/TSDoc, OpenAPI)
|
|
16
|
+
- Project README
|
|
17
|
+
- Changelog
|
|
18
|
+
- Inline code comments
|
|
19
|
+
- Full documentation suite
|
|
20
|
+
- IF existing documentation exists THEN assess its accuracy against the current code
|
|
21
|
+
- IF the codebase uses TypeScript THEN extract type information from type annotations and interfaces
|
|
22
|
+
- Use @botlearn/code-gen capabilities to understand code structure, patterns, and architectural intent
|
|
23
|
+
|
|
24
|
+
## Step 2: API Extraction
|
|
25
|
+
- For each public export, extract:
|
|
26
|
+
- **Function signature**: name, parameters (name, type, default, optional), return type
|
|
27
|
+
- **Class definition**: constructor, public methods, public properties, static members, inheritance chain
|
|
28
|
+
- **Type definitions**: interfaces, type aliases, enums, generics
|
|
29
|
+
- **Constants**: exported values with their types and semantic purpose
|
|
30
|
+
- Detect **behavioral contracts** from the code:
|
|
31
|
+
- Thrown exceptions and their trigger conditions
|
|
32
|
+
- Side effects (database writes, file I/O, network calls, event emissions)
|
|
33
|
+
- Async behavior (Promises, callbacks, streams)
|
|
34
|
+
- Preconditions and postconditions (input validation, assertion checks)
|
|
35
|
+
- Map **dependency relationships** between functions and modules
|
|
36
|
+
- For REST endpoints, extract:
|
|
37
|
+
- HTTP method and path
|
|
38
|
+
- Path parameters, query parameters, request body schema
|
|
39
|
+
- Response schemas for each status code
|
|
40
|
+
- Authentication requirements
|
|
41
|
+
- Rate limiting or quota information
|
|
42
|
+
- IF the project uses a framework (Express, Fastify, NestJS, Flask, FastAPI) THEN use framework-specific patterns to extract route metadata
|
|
43
|
+
|
|
44
|
+
## Step 3: Description Generation
|
|
45
|
+
- For each extracted API element, generate documentation following knowledge/domain.md formats:
|
|
46
|
+
- **Summary line**: One sentence in imperative mood describing the primary action ("Retrieve a user by ID")
|
|
47
|
+
- **Extended description**: Behavior details, constraints, side effects, and important context
|
|
48
|
+
- **Parameter descriptions**: Semantic meaning beyond the type — valid values, constraints, formats, defaults with rationale
|
|
49
|
+
- **Return description**: What is returned in each case (success, not found, error)
|
|
50
|
+
- **Error documentation**: Each throwable error with its trigger condition and error code
|
|
51
|
+
- For README generation:
|
|
52
|
+
- Write a concise project description (one line for tagline, one paragraph for overview)
|
|
53
|
+
- Generate installation instructions for all relevant package managers
|
|
54
|
+
- Write a quick-start section with copy-pasteable code
|
|
55
|
+
- Summarize the API surface with links to detailed docs
|
|
56
|
+
- Detect and include configuration options in a table
|
|
57
|
+
- For changelog generation:
|
|
58
|
+
- Analyze git commit history since the last release tag
|
|
59
|
+
- Map commits to changelog categories using conventional commit prefixes (see knowledge/domain.md)
|
|
60
|
+
- Filter out non-user-facing changes (typo fixes, CI, internal refactors)
|
|
61
|
+
- Write entries in imperative mood with issue/PR references
|
|
62
|
+
- Group under the appropriate version heading
|
|
63
|
+
- APPLY tone and voice guidelines from knowledge/best-practices.md
|
|
64
|
+
- VERIFY descriptions add value beyond what the code signature already communicates (see anti-pattern #1 in knowledge/anti-patterns.md)
|
|
65
|
+
|
|
66
|
+
## Step 4: Example Creation
|
|
67
|
+
- For each public function or method, create at least one usage example:
|
|
68
|
+
- **Basic example**: Simplest possible invocation showing the happy path with realistic data
|
|
69
|
+
- **Common variation**: Demonstrate frequently used optional parameters or configuration
|
|
70
|
+
- **Error handling**: Show how to catch and handle expected errors
|
|
71
|
+
- Example requirements:
|
|
72
|
+
- Must be syntactically valid and runnable (no pseudocode)
|
|
73
|
+
- Must include all necessary imports and setup
|
|
74
|
+
- Must show expected output as a comment (`// => result`)
|
|
75
|
+
- Must use realistic, domain-appropriate data (not `foo`, `bar`, `test`)
|
|
76
|
+
- For OpenAPI documentation:
|
|
77
|
+
- Include request examples with realistic payloads
|
|
78
|
+
- Include response examples for success and error cases
|
|
79
|
+
- Provide cURL command examples for each endpoint
|
|
80
|
+
- For README quick-start:
|
|
81
|
+
- The example must work out of the box after installation
|
|
82
|
+
- Limit to 5-10 lines for the core demonstration
|
|
83
|
+
- Show the minimum configuration needed
|
|
84
|
+
- IF the project has existing test files THEN reference test data for realistic example values
|
|
85
|
+
- VERIFY examples against knowledge/anti-patterns.md #2 (missing examples) and best-practices.md example quality standards
|
|
86
|
+
|
|
87
|
+
## Step 5: Style Matching
|
|
88
|
+
- Analyze existing documentation in the project for:
|
|
89
|
+
- **Comment style**: JSDoc vs TSDoc vs plain comments vs docstrings
|
|
90
|
+
- **Markdown conventions**: heading levels, list styles, code block language tags
|
|
91
|
+
- **Naming conventions**: how parameters and types are described
|
|
92
|
+
- **Tone**: formal vs conversational, second person vs third person
|
|
93
|
+
- **Example style**: programming language, variable naming, output format
|
|
94
|
+
- IF existing documentation uses a specific style THEN match it exactly for consistency
|
|
95
|
+
- IF no existing style is detected THEN apply the defaults from knowledge/best-practices.md:
|
|
96
|
+
- JSDoc/TSDoc for JavaScript/TypeScript
|
|
97
|
+
- Google-style docstrings for Python
|
|
98
|
+
- Third person for API references
|
|
99
|
+
- Second person for guides and tutorials
|
|
100
|
+
- APPLY formatting conventions from knowledge/best-practices.md:
|
|
101
|
+
- Backticks for code references
|
|
102
|
+
- Tables for structured parameter/configuration data
|
|
103
|
+
- Language-tagged code blocks for all examples
|
|
104
|
+
- VERIFY against knowledge/anti-patterns.md #9 (inconsistent formatting)
|
|
105
|
+
- IF the project has a linter or documentation config (eslint-plugin-jsdoc, typedoc.json, .remarkrc) THEN conform to those settings
|
|
106
|
+
|
|
107
|
+
## Step 6: Completeness Check
|
|
108
|
+
- Run a final coverage audit:
|
|
109
|
+
- Count total public exports
|
|
110
|
+
- Count fully documented exports (summary + params + return + errors + example)
|
|
111
|
+
- Calculate percentage coverage
|
|
112
|
+
- List any undocumented or partially documented items
|
|
113
|
+
- Verify documentation accuracy:
|
|
114
|
+
- Every documented parameter exists in the current function signature
|
|
115
|
+
- Every documented return type matches the actual return type
|
|
116
|
+
- Every documented error is actually thrown by the code
|
|
117
|
+
- No references to removed, renamed, or deprecated identifiers without deprecation notices
|
|
118
|
+
- Check for anti-patterns from knowledge/anti-patterns.md:
|
|
119
|
+
- No auto-generated gibberish (#1)
|
|
120
|
+
- No missing examples (#2)
|
|
121
|
+
- No stale documentation (#3)
|
|
122
|
+
- No copy-paste descriptions (#4)
|
|
123
|
+
- No undocumented error cases (#5)
|
|
124
|
+
- No orphaned API references (#8)
|
|
125
|
+
- No changelog-as-commit-log (#10)
|
|
126
|
+
- No type-without-context (#11)
|
|
127
|
+
- No exposed private internals (#12)
|
|
128
|
+
- Generate a **coverage report**:
|
|
129
|
+
```
|
|
130
|
+
Documentation Coverage Report
|
|
131
|
+
─────────────────────────────
|
|
132
|
+
Before: 32% (16/50 exports documented)
|
|
133
|
+
After: 92% (46/50 exports documented)
|
|
134
|
+
|
|
135
|
+
Remaining gaps:
|
|
136
|
+
- src/internal/cache.ts: 4 internal functions (intentionally excluded)
|
|
137
|
+
|
|
138
|
+
Quality checks: 9/9 passed
|
|
139
|
+
```
|
|
140
|
+
- IF coverage is below 90% THEN loop back to Step 3 to address gaps
|
|
141
|
+
- IF any accuracy check fails THEN correct the documentation and re-verify
|
|
142
|
+
- SELF-CHECK:
|
|
143
|
+
- Does every public function have a summary, params, return, errors, and example?
|
|
144
|
+
- Do all examples compile/run without errors?
|
|
145
|
+
- Is the documentation style consistent across all files?
|
|
146
|
+
- Are cross-references valid and linking to existing symbols?
|
|
147
|
+
- IF any check fails THEN address the specific gap before finalizing
|