mcp-wordpress 1.1.7 → 1.2.2
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 +388 -66
- package/dist/cache/CacheInvalidation.d.ts +118 -0
- package/dist/cache/CacheInvalidation.d.ts.map +1 -0
- package/dist/cache/CacheInvalidation.js +349 -0
- package/dist/cache/CacheInvalidation.js.map +1 -0
- package/dist/cache/CacheManager.d.ts +143 -0
- package/dist/cache/CacheManager.d.ts.map +1 -0
- package/dist/cache/CacheManager.js +308 -0
- package/dist/cache/CacheManager.js.map +1 -0
- package/dist/cache/HttpCacheWrapper.d.ts +121 -0
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -0
- package/dist/cache/HttpCacheWrapper.js +280 -0
- package/dist/cache/HttpCacheWrapper.js.map +1 -0
- package/dist/cache/__tests__/CacheInvalidation.test.d.ts +5 -0
- package/dist/cache/__tests__/CacheInvalidation.test.d.ts.map +1 -0
- package/dist/cache/__tests__/CacheInvalidation.test.js +236 -0
- package/dist/cache/__tests__/CacheInvalidation.test.js.map +1 -0
- package/dist/cache/__tests__/CacheManager.test.d.ts +5 -0
- package/dist/cache/__tests__/CacheManager.test.d.ts.map +1 -0
- package/dist/cache/__tests__/CacheManager.test.js +233 -0
- package/dist/cache/__tests__/CacheManager.test.js.map +1 -0
- package/dist/cache/__tests__/CachedWordPressClient.test.d.ts +5 -0
- package/dist/cache/__tests__/CachedWordPressClient.test.d.ts.map +1 -0
- package/dist/cache/__tests__/CachedWordPressClient.test.js +228 -0
- package/dist/cache/__tests__/CachedWordPressClient.test.js.map +1 -0
- package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts +5 -0
- package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts.map +1 -0
- package/dist/cache/__tests__/HttpCacheWrapper.test.js +296 -0
- package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -0
- package/dist/cache/index.d.ts +12 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +9 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/client/CachedWordPressClient.d.ts +160 -0
- package/dist/client/CachedWordPressClient.d.ts.map +1 -0
- package/dist/client/CachedWordPressClient.js +338 -0
- package/dist/client/CachedWordPressClient.js.map +1 -0
- package/dist/client/WordPressClient.d.ts +81 -0
- package/dist/client/WordPressClient.d.ts.map +1 -0
- package/dist/client/WordPressClient.js +354 -0
- package/dist/client/WordPressClient.js.map +1 -0
- package/dist/config/ConfigurationSchema.d.ts +281 -0
- package/dist/config/ConfigurationSchema.d.ts.map +1 -0
- package/dist/config/ConfigurationSchema.js +205 -0
- package/dist/config/ConfigurationSchema.js.map +1 -0
- package/dist/config/ServerConfiguration.d.ts +38 -0
- package/dist/config/ServerConfiguration.d.ts.map +1 -0
- package/dist/config/ServerConfiguration.js +158 -0
- package/dist/config/ServerConfiguration.js.map +1 -0
- package/dist/docs/DocumentationGenerator.d.ts +184 -0
- package/dist/docs/DocumentationGenerator.d.ts.map +1 -0
- package/dist/docs/DocumentationGenerator.js +735 -0
- package/dist/docs/DocumentationGenerator.js.map +1 -0
- package/dist/docs/MarkdownFormatter.d.ts +84 -0
- package/dist/docs/MarkdownFormatter.d.ts.map +1 -0
- package/dist/docs/MarkdownFormatter.js +448 -0
- package/dist/docs/MarkdownFormatter.js.map +1 -0
- package/dist/docs/index.d.ts +8 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +7 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -212
- package/dist/index.js.map +1 -1
- package/dist/performance/AnomalyDetector.d.ts +63 -0
- package/dist/performance/AnomalyDetector.d.ts.map +1 -0
- package/dist/performance/AnomalyDetector.js +222 -0
- package/dist/performance/AnomalyDetector.js.map +1 -0
- package/dist/performance/BenchmarkAnalyzer.d.ts +67 -0
- package/dist/performance/BenchmarkAnalyzer.d.ts.map +1 -0
- package/dist/performance/BenchmarkAnalyzer.js +301 -0
- package/dist/performance/BenchmarkAnalyzer.js.map +1 -0
- package/dist/performance/MetricsCollector.d.ts +139 -0
- package/dist/performance/MetricsCollector.d.ts.map +1 -0
- package/dist/performance/MetricsCollector.js +320 -0
- package/dist/performance/MetricsCollector.js.map +1 -0
- package/dist/performance/PerformanceAnalytics.d.ts +162 -0
- package/dist/performance/PerformanceAnalytics.d.ts.map +1 -0
- package/dist/performance/PerformanceAnalytics.js +554 -0
- package/dist/performance/PerformanceAnalytics.js.map +1 -0
- package/dist/performance/PerformanceMonitor.d.ts +202 -0
- package/dist/performance/PerformanceMonitor.d.ts.map +1 -0
- package/dist/performance/PerformanceMonitor.js +478 -0
- package/dist/performance/PerformanceMonitor.js.map +1 -0
- package/dist/performance/TrendAnalyzer.d.ts +69 -0
- package/dist/performance/TrendAnalyzer.d.ts.map +1 -0
- package/dist/performance/TrendAnalyzer.js +203 -0
- package/dist/performance/TrendAnalyzer.js.map +1 -0
- package/dist/performance/index.d.ts +11 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/index.js +8 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/security/InputValidator.d.ts +215 -0
- package/dist/security/InputValidator.d.ts.map +1 -0
- package/dist/security/InputValidator.js +278 -0
- package/dist/security/InputValidator.js.map +1 -0
- package/dist/security/SecurityConfig.d.ts +129 -0
- package/dist/security/SecurityConfig.d.ts.map +1 -0
- package/dist/security/SecurityConfig.js +262 -0
- package/dist/security/SecurityConfig.js.map +1 -0
- package/dist/server/ConnectionTester.d.ts +24 -0
- package/dist/server/ConnectionTester.d.ts.map +1 -0
- package/dist/server/ConnectionTester.js +61 -0
- package/dist/server/ConnectionTester.js.map +1 -0
- package/dist/server/ToolRegistry.d.ts +46 -0
- package/dist/server/ToolRegistry.d.ts.map +1 -0
- package/dist/server/ToolRegistry.js +148 -0
- package/dist/server/ToolRegistry.js.map +1 -0
- package/dist/tools/BaseToolClass.d.ts +76 -0
- package/dist/tools/BaseToolClass.d.ts.map +1 -0
- package/dist/tools/BaseToolClass.js +104 -0
- package/dist/tools/BaseToolClass.js.map +1 -0
- package/dist/tools/BaseToolManager.d.ts +26 -0
- package/dist/tools/BaseToolManager.d.ts.map +1 -0
- package/dist/tools/BaseToolManager.js +56 -0
- package/dist/tools/BaseToolManager.js.map +1 -0
- package/dist/tools/base.d.ts +37 -0
- package/dist/tools/base.d.ts.map +1 -0
- package/dist/tools/base.js +60 -0
- package/dist/tools/base.js.map +1 -0
- package/dist/tools/cache.d.ts +260 -0
- package/dist/tools/cache.d.ts.map +1 -0
- package/dist/tools/cache.js +237 -0
- package/dist/tools/cache.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/performance.d.ts +63 -0
- package/dist/tools/performance.d.ts.map +1 -0
- package/dist/tools/performance.js +865 -0
- package/dist/tools/performance.js.map +1 -0
- package/dist/types/client.d.ts +1 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts +4 -0
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/dist/utils/toolWrapper.js +11 -0
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation.d.ts +68 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +185 -0
- package/dist/utils/validation.js.map +1 -0
- package/docs/CACHING.md +340 -0
- package/docs/DOCKER.md +451 -0
- package/docs/PERFORMANCE_MONITORING.md +471 -0
- package/docs/SECURITY_TESTING.md +393 -0
- package/docs/api/README.md +200 -0
- package/docs/api/categories/auth.md +40 -0
- package/docs/api/categories/cache.md +41 -0
- package/docs/api/categories/comment.md +44 -0
- package/docs/api/categories/media.md +43 -0
- package/docs/api/categories/page.md +43 -0
- package/docs/api/categories/performance.md +44 -0
- package/docs/api/categories/post.md +43 -0
- package/docs/api/categories/site.md +43 -0
- package/docs/api/categories/taxonomy.md +47 -0
- package/docs/api/categories/user.md +43 -0
- package/docs/api/openapi.json +3305 -0
- package/docs/api/summary.json +12 -0
- package/docs/api/tools/wp_approve_comment.md +98 -0
- package/docs/api/tools/wp_cache_clear.md +120 -0
- package/docs/api/tools/wp_cache_info.md +119 -0
- package/docs/api/tools/wp_cache_stats.md +119 -0
- package/docs/api/tools/wp_cache_warm.md +119 -0
- package/docs/api/tools/wp_create_application_password.md +102 -0
- package/docs/api/tools/wp_create_category.md +102 -0
- package/docs/api/tools/wp_create_comment.md +128 -0
- package/docs/api/tools/wp_create_page.md +135 -0
- package/docs/api/tools/wp_create_post.md +147 -0
- package/docs/api/tools/wp_create_tag.md +101 -0
- package/docs/api/tools/wp_create_user.md +135 -0
- package/docs/api/tools/wp_delete_application_password.md +101 -0
- package/docs/api/tools/wp_delete_category.md +100 -0
- package/docs/api/tools/wp_delete_comment.md +101 -0
- package/docs/api/tools/wp_delete_media.md +108 -0
- package/docs/api/tools/wp_delete_page.md +108 -0
- package/docs/api/tools/wp_delete_post.md +117 -0
- package/docs/api/tools/wp_delete_tag.md +100 -0
- package/docs/api/tools/wp_delete_user.md +108 -0
- package/docs/api/tools/wp_get_application_passwords.md +103 -0
- package/docs/api/tools/wp_get_auth_status.md +101 -0
- package/docs/api/tools/wp_get_category.md +103 -0
- package/docs/api/tools/wp_get_comment.md +103 -0
- package/docs/api/tools/wp_get_current_user.md +101 -0
- package/docs/api/tools/wp_get_media.md +103 -0
- package/docs/api/tools/wp_get_page.md +103 -0
- package/docs/api/tools/wp_get_page_revisions.md +103 -0
- package/docs/api/tools/wp_get_post.md +112 -0
- package/docs/api/tools/wp_get_post_revisions.md +103 -0
- package/docs/api/tools/wp_get_site_settings.md +108 -0
- package/docs/api/tools/wp_get_tag.md +103 -0
- package/docs/api/tools/wp_get_user.md +103 -0
- package/docs/api/tools/wp_list_categories.md +111 -0
- package/docs/api/tools/wp_list_comments.md +111 -0
- package/docs/api/tools/wp_list_media.md +145 -0
- package/docs/api/tools/wp_list_pages.md +145 -0
- package/docs/api/tools/wp_list_posts.md +156 -0
- package/docs/api/tools/wp_list_tags.md +110 -0
- package/docs/api/tools/wp_list_users.md +111 -0
- package/docs/api/tools/wp_performance_alerts.md +162 -0
- package/docs/api/tools/wp_performance_benchmark.md +160 -0
- package/docs/api/tools/wp_performance_export.md +162 -0
- package/docs/api/tools/wp_performance_history.md +161 -0
- package/docs/api/tools/wp_performance_optimize.md +162 -0
- package/docs/api/tools/wp_performance_stats.md +160 -0
- package/docs/api/tools/wp_search_site.md +99 -0
- package/docs/api/tools/wp_spam_comment.md +98 -0
- package/docs/api/tools/wp_switch_auth_method.md +122 -0
- package/docs/api/tools/wp_test_auth.md +96 -0
- package/docs/api/tools/wp_update_category.md +102 -0
- package/docs/api/tools/wp_update_comment.md +127 -0
- package/docs/api/tools/wp_update_media.md +129 -0
- package/docs/api/tools/wp_update_page.md +135 -0
- package/docs/api/tools/wp_update_post.md +144 -0
- package/docs/api/tools/wp_update_site_settings.md +127 -0
- package/docs/api/tools/wp_update_tag.md +102 -0
- package/docs/api/tools/wp_update_user.md +134 -0
- package/docs/api/tools/wp_upload_media.md +131 -0
- package/docs/api/types/WordPressPost.md +39 -0
- package/docs/contract-testing.md +183 -0
- package/docs/developer/NPM_AUTH_SETUP.md +3 -3
- package/docs/wordpress-rest-api-authentication-troubleshooting.md +218 -0
- package/package.json +84 -64
- package/src/cache/CacheInvalidation.ts +421 -0
- package/src/cache/CacheManager.ts +391 -0
- package/src/cache/HttpCacheWrapper.ts +372 -0
- package/src/cache/__tests__/CacheInvalidation.test.ts +299 -0
- package/src/cache/__tests__/CacheManager.test.ts +300 -0
- package/src/cache/__tests__/CachedWordPressClient.test.ts +304 -0
- package/src/cache/__tests__/HttpCacheWrapper.test.ts +359 -0
- package/src/cache/index.ts +26 -0
- package/src/client/CachedWordPressClient.ts +442 -0
- package/src/config/ConfigurationSchema.ts +246 -0
- package/src/config/ServerConfiguration.ts +215 -0
- package/src/docs/DocumentationGenerator.ts +952 -0
- package/src/docs/MarkdownFormatter.ts +494 -0
- package/src/docs/index.ts +21 -0
- package/src/index.ts +14 -274
- package/src/performance/MetricsCollector.ts +447 -0
- package/src/performance/PerformanceAnalytics.ts +762 -0
- package/src/performance/PerformanceMonitor.ts +649 -0
- package/src/performance/index.ts +28 -0
- package/src/security/InputValidator.ts +319 -0
- package/src/security/SecurityConfig.ts +301 -0
- package/src/server/ConnectionTester.ts +74 -0
- package/src/server/ToolRegistry.ts +194 -0
- package/src/tools/BaseToolManager.ts +66 -0
- package/src/tools/cache.ts +259 -0
- package/src/tools/index.ts +2 -0
- package/src/tools/performance.ts +948 -0
- package/src/types/client.ts +1 -0
- package/src/utils/toolWrapper.ts +11 -0
- package/src/utils/validation.ts +259 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown Documentation Formatter
|
|
3
|
+
* Converts documentation objects to well-formatted markdown files
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ToolDocumentation,
|
|
8
|
+
CategoryDocumentation,
|
|
9
|
+
TypeDocumentation,
|
|
10
|
+
DocumentationOutput,
|
|
11
|
+
ExampleUsage,
|
|
12
|
+
ParameterDocumentation
|
|
13
|
+
} from './DocumentationGenerator.js';
|
|
14
|
+
|
|
15
|
+
export class MarkdownFormatter {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generate main API overview documentation
|
|
19
|
+
*/
|
|
20
|
+
generateApiOverview(output: DocumentationOutput): string {
|
|
21
|
+
const { tools, categories, summary } = output;
|
|
22
|
+
|
|
23
|
+
return `# WordPress MCP Server - API Documentation
|
|
24
|
+
|
|
25
|
+
${this.generateBadges()}
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
The WordPress MCP Server provides **${summary.totalTools} tools** across **${summary.totalCategories} categories** for comprehensive WordPress management through the Model Context Protocol.
|
|
30
|
+
|
|
31
|
+
**Last Updated:** ${new Date(summary.lastUpdated).toLocaleDateString()}
|
|
32
|
+
**Version:** ${summary.version}
|
|
33
|
+
**Coverage:** ${summary.coverage.toolsWithExamples}/${summary.totalTools} tools with examples
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
### Basic Usage
|
|
38
|
+
\`\`\`bash
|
|
39
|
+
# List all posts
|
|
40
|
+
wp_list_posts
|
|
41
|
+
|
|
42
|
+
# Get specific post
|
|
43
|
+
wp_get_post --id=123
|
|
44
|
+
|
|
45
|
+
# Create new post
|
|
46
|
+
wp_create_post --title="My Post" --content="Post content"
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
### Multi-Site Usage
|
|
50
|
+
\`\`\`bash
|
|
51
|
+
# Target specific site
|
|
52
|
+
wp_list_posts --site=site1
|
|
53
|
+
|
|
54
|
+
# Use with different authentication
|
|
55
|
+
wp_get_site_settings --site=production
|
|
56
|
+
\`\`\`
|
|
57
|
+
|
|
58
|
+
## Tool Categories
|
|
59
|
+
|
|
60
|
+
${this.generateCategoriesTable(categories)}
|
|
61
|
+
|
|
62
|
+
## Available Tools
|
|
63
|
+
|
|
64
|
+
${this.generateToolsTable(tools)}
|
|
65
|
+
|
|
66
|
+
## Authentication
|
|
67
|
+
|
|
68
|
+
All tools support multiple authentication methods:
|
|
69
|
+
- **Application Passwords** (recommended)
|
|
70
|
+
- **JWT Authentication**
|
|
71
|
+
- **Basic Authentication** (development only)
|
|
72
|
+
- **API Key Authentication**
|
|
73
|
+
|
|
74
|
+
## Error Handling
|
|
75
|
+
|
|
76
|
+
Standard error response format:
|
|
77
|
+
\`\`\`json
|
|
78
|
+
{
|
|
79
|
+
"error": "Error type",
|
|
80
|
+
"message": "Human-readable error message",
|
|
81
|
+
"code": "ERROR_CODE",
|
|
82
|
+
"details": {
|
|
83
|
+
"endpoint": "/wp-json/wp/v2/posts",
|
|
84
|
+
"method": "GET"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
\`\`\`
|
|
88
|
+
|
|
89
|
+
## Configuration
|
|
90
|
+
|
|
91
|
+
### Multi-Site Configuration
|
|
92
|
+
\`\`\`json
|
|
93
|
+
{
|
|
94
|
+
"sites": [
|
|
95
|
+
{
|
|
96
|
+
"id": "site1",
|
|
97
|
+
"name": "My WordPress Site",
|
|
98
|
+
"config": {
|
|
99
|
+
"WORDPRESS_SITE_URL": "https://example.com",
|
|
100
|
+
"WORDPRESS_USERNAME": "username",
|
|
101
|
+
"WORDPRESS_APP_PASSWORD": "app_password"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
\`\`\`
|
|
107
|
+
|
|
108
|
+
## Response Formats
|
|
109
|
+
|
|
110
|
+
All tools return responses in this format:
|
|
111
|
+
\`\`\`json
|
|
112
|
+
{
|
|
113
|
+
"success": true,
|
|
114
|
+
"data": {
|
|
115
|
+
// Tool-specific response data
|
|
116
|
+
},
|
|
117
|
+
"metadata": {
|
|
118
|
+
"timestamp": "2024-01-01T00:00:00.000Z",
|
|
119
|
+
"site": "site1",
|
|
120
|
+
"tool": "wp_list_posts"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
\`\`\`
|
|
124
|
+
|
|
125
|
+
## Performance Monitoring
|
|
126
|
+
|
|
127
|
+
The server includes comprehensive performance monitoring:
|
|
128
|
+
- Real-time metrics collection
|
|
129
|
+
- Historical performance analysis
|
|
130
|
+
- Industry benchmark comparisons
|
|
131
|
+
- Automated optimization recommendations
|
|
132
|
+
|
|
133
|
+
See [Performance Monitoring Guide](./performance/README.md) for details.
|
|
134
|
+
|
|
135
|
+
## Additional Resources
|
|
136
|
+
|
|
137
|
+
- [Tool Reference](./tools/README.md) - Detailed tool documentation
|
|
138
|
+
- [Type Definitions](./types/README.md) - TypeScript type definitions
|
|
139
|
+
- [Examples](./examples/README.md) - Usage examples and workflows
|
|
140
|
+
- [OpenAPI Specification](./openapi.json) - Machine-readable API spec
|
|
141
|
+
|
|
142
|
+
## Support
|
|
143
|
+
|
|
144
|
+
- **Documentation:** [GitHub Repository](https://github.com/docdyhr/mcp-wordpress)
|
|
145
|
+
- **Issues:** [GitHub Issues](https://github.com/docdyhr/mcp-wordpress/issues)
|
|
146
|
+
- **Discussions:** [GitHub Discussions](https://github.com/docdyhr/mcp-wordpress/discussions)
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Generate tool documentation
|
|
152
|
+
*/
|
|
153
|
+
generateToolDocumentation(tool: ToolDocumentation): string {
|
|
154
|
+
return `# ${tool.name}
|
|
155
|
+
|
|
156
|
+
${this.generateToolBadge(tool.category)}
|
|
157
|
+
|
|
158
|
+
${tool.description}
|
|
159
|
+
|
|
160
|
+
## Parameters
|
|
161
|
+
|
|
162
|
+
${this.generateParametersTable(tool.parameters)}
|
|
163
|
+
|
|
164
|
+
## Examples
|
|
165
|
+
|
|
166
|
+
${this.generateExamples(tool.examples)}
|
|
167
|
+
|
|
168
|
+
${tool.wordpressEndpoint ? this.generateWordPressMapping(tool.wordpressEndpoint) : ''}
|
|
169
|
+
|
|
170
|
+
${tool.requiredPermissions ? this.generatePermissions(tool.requiredPermissions) : ''}
|
|
171
|
+
|
|
172
|
+
## Response Format
|
|
173
|
+
|
|
174
|
+
**Return Type:** \`${tool.returnType}\`
|
|
175
|
+
|
|
176
|
+
${this.generateResponseExample(tool)}
|
|
177
|
+
|
|
178
|
+
## Error Handling
|
|
179
|
+
|
|
180
|
+
${this.generateErrorDocumentation(tool.errorCodes)}
|
|
181
|
+
|
|
182
|
+
${tool.relatedTools.length > 0 ? this.generateRelatedTools(tool.relatedTools) : ''}
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
*Generated automatically from tool definitions - Do not edit manually*
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Generate category documentation
|
|
192
|
+
*/
|
|
193
|
+
generateCategoryDocumentation(category: CategoryDocumentation): string {
|
|
194
|
+
return `# ${category.name} Tools
|
|
195
|
+
|
|
196
|
+
${category.description}
|
|
197
|
+
|
|
198
|
+
**Tool Count:** ${category.toolCount}
|
|
199
|
+
|
|
200
|
+
## Available Tools
|
|
201
|
+
|
|
202
|
+
${category.tools.map(tool => `- [\`${tool}\`](./tools/${tool}.md)`).join('\n')}
|
|
203
|
+
|
|
204
|
+
## Common Usage Patterns
|
|
205
|
+
|
|
206
|
+
${category.usagePatterns.map(pattern => `- ${pattern}`).join('\n')}
|
|
207
|
+
|
|
208
|
+
## Examples
|
|
209
|
+
|
|
210
|
+
### Basic ${category.name} Workflow
|
|
211
|
+
\`\`\`bash
|
|
212
|
+
# List all ${category.name.toLowerCase()}
|
|
213
|
+
wp_list_${category.name.toLowerCase()}
|
|
214
|
+
|
|
215
|
+
# Get specific item
|
|
216
|
+
wp_get_${category.name.toLowerCase().slice(0, -1)} --id=123
|
|
217
|
+
|
|
218
|
+
# Create new item
|
|
219
|
+
wp_create_${category.name.toLowerCase().slice(0, -1)} --title="Example"
|
|
220
|
+
\`\`\`
|
|
221
|
+
|
|
222
|
+
### Multi-Site ${category.name} Management
|
|
223
|
+
\`\`\`bash
|
|
224
|
+
# Work with specific site
|
|
225
|
+
wp_list_${category.name.toLowerCase()} --site=production
|
|
226
|
+
|
|
227
|
+
# Bulk operations
|
|
228
|
+
wp_list_${category.name.toLowerCase()} --site=staging --limit=50
|
|
229
|
+
\`\`\`
|
|
230
|
+
`;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Generate type documentation
|
|
235
|
+
*/
|
|
236
|
+
generateTypeDocumentation(type: TypeDocumentation): string {
|
|
237
|
+
return `# ${type.name}
|
|
238
|
+
|
|
239
|
+
${type.description}
|
|
240
|
+
|
|
241
|
+
${type.wordpressSource ? `**WordPress Source:** \`${type.wordpressSource}\`` : ''}
|
|
242
|
+
|
|
243
|
+
## Properties
|
|
244
|
+
|
|
245
|
+
${this.generateTypePropertiesTable(type.properties)}
|
|
246
|
+
|
|
247
|
+
## Example
|
|
248
|
+
|
|
249
|
+
\`\`\`json
|
|
250
|
+
${JSON.stringify(type.examples[0] || {}, null, 2)}
|
|
251
|
+
\`\`\`
|
|
252
|
+
|
|
253
|
+
${type.examples.length > 1 ? this.generateAdditionalExamples(type.examples.slice(1)) : ''}
|
|
254
|
+
`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Generate parameters table
|
|
259
|
+
*/
|
|
260
|
+
private generateParametersTable(parameters: ParameterDocumentation[]): string {
|
|
261
|
+
if (parameters.length === 0) {
|
|
262
|
+
return '*No parameters required.*';
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const headers = '| Parameter | Type | Required | Description | Default | Examples |';
|
|
266
|
+
const separator = '|-----------|------|----------|-------------|---------|----------|';
|
|
267
|
+
|
|
268
|
+
const rows = parameters.map(param => {
|
|
269
|
+
const examples = param.examples.slice(0, 2).map(ex => `\`${ex}\``).join(', ');
|
|
270
|
+
const defaultVal = param.defaultValue !== undefined ? `\`${param.defaultValue}\`` : '-';
|
|
271
|
+
const required = param.required ? '✅' : '❌';
|
|
272
|
+
|
|
273
|
+
return `| \`${param.name}\` | \`${param.type}\` | ${required} | ${param.description} | ${defaultVal} | ${examples || '-'} |`;
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
return [headers, separator, ...rows].join('\n');
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Generate examples section
|
|
281
|
+
*/
|
|
282
|
+
private generateExamples(examples: ExampleUsage[]): string {
|
|
283
|
+
if (examples.length === 0) {
|
|
284
|
+
return '*No examples available.*';
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return examples.map(example => `### ${example.title}
|
|
288
|
+
|
|
289
|
+
${example.description}
|
|
290
|
+
|
|
291
|
+
**Command:**
|
|
292
|
+
\`\`\`bash
|
|
293
|
+
${example.command} ${this.formatParameters(example.parameters)}
|
|
294
|
+
\`\`\`
|
|
295
|
+
|
|
296
|
+
**Response:**
|
|
297
|
+
\`\`\`json
|
|
298
|
+
${JSON.stringify(example.expectedResponse, null, 2)}
|
|
299
|
+
\`\`\`
|
|
300
|
+
|
|
301
|
+
${example.errorExample ? this.generateErrorExample(example.errorExample) : ''}
|
|
302
|
+
`).join('\n\n');
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Generate error example
|
|
307
|
+
*/
|
|
308
|
+
private generateErrorExample(errorExample: { scenario: string; error: any }): string {
|
|
309
|
+
return `**Error Example (${errorExample.scenario}):**
|
|
310
|
+
\`\`\`json
|
|
311
|
+
${JSON.stringify(errorExample.error, null, 2)}
|
|
312
|
+
\`\`\``;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Generate WordPress mapping section
|
|
317
|
+
*/
|
|
318
|
+
private generateWordPressMapping(endpoint: string): string {
|
|
319
|
+
return `## WordPress REST API Mapping
|
|
320
|
+
|
|
321
|
+
**Endpoint:** \`${endpoint}\`
|
|
322
|
+
|
|
323
|
+
This tool directly interfaces with the WordPress REST API endpoint above. The response format and available parameters are determined by WordPress core functionality.
|
|
324
|
+
|
|
325
|
+
### WordPress Documentation
|
|
326
|
+
- [WordPress REST API Handbook](https://developer.wordpress.org/rest-api/)
|
|
327
|
+
- [Endpoint Reference](https://developer.wordpress.org/rest-api/reference/)
|
|
328
|
+
`;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Generate permissions section
|
|
333
|
+
*/
|
|
334
|
+
private generatePermissions(permissions: string[]): string {
|
|
335
|
+
return `## Required Permissions
|
|
336
|
+
|
|
337
|
+
This tool requires the following WordPress user capabilities:
|
|
338
|
+
|
|
339
|
+
${permissions.map(perm => `- \`${perm}\``).join('\n')}
|
|
340
|
+
|
|
341
|
+
**Note:** The authenticated user must have these capabilities to successfully execute this tool.
|
|
342
|
+
`;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Generate response example
|
|
347
|
+
*/
|
|
348
|
+
private generateResponseExample(tool: ToolDocumentation): string {
|
|
349
|
+
return `\`\`\`json
|
|
350
|
+
{
|
|
351
|
+
"success": true,
|
|
352
|
+
"data": {
|
|
353
|
+
// ${tool.returnType} response data
|
|
354
|
+
},
|
|
355
|
+
"metadata": {
|
|
356
|
+
"timestamp": "2024-01-01T00:00:00.000Z",
|
|
357
|
+
"tool": "${tool.name}",
|
|
358
|
+
"site": "site1"
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
\`\`\``;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Generate error documentation
|
|
366
|
+
*/
|
|
367
|
+
private generateErrorDocumentation(errorCodes: any[]): string {
|
|
368
|
+
if (errorCodes.length === 0) {
|
|
369
|
+
return `### Common Errors
|
|
370
|
+
|
|
371
|
+
- **Authentication Error**: Invalid credentials or insufficient permissions
|
|
372
|
+
- **Validation Error**: Invalid or missing required parameters
|
|
373
|
+
- **Not Found Error**: Requested resource does not exist
|
|
374
|
+
- **Server Error**: Internal WordPress or network error
|
|
375
|
+
|
|
376
|
+
See [Error Handling Guide](../error-handling.md) for complete error reference.`;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return errorCodes.map(error => `### ${error.code}
|
|
380
|
+
|
|
381
|
+
**Message:** ${error.message}
|
|
382
|
+
**Description:** ${error.description}
|
|
383
|
+
**Resolution:** ${error.resolution}
|
|
384
|
+
`).join('\n\n');
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Generate related tools section
|
|
389
|
+
*/
|
|
390
|
+
private generateRelatedTools(relatedTools: string[]): string {
|
|
391
|
+
return `## Related Tools
|
|
392
|
+
|
|
393
|
+
${relatedTools.map(tool => `- [\`${tool}\`](./${tool}.md)`).join('\n')}
|
|
394
|
+
`;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Generate categories table
|
|
399
|
+
*/
|
|
400
|
+
private generateCategoriesTable(categories: CategoryDocumentation[]): string {
|
|
401
|
+
const headers = '| Category | Tools | Description |';
|
|
402
|
+
const separator = '|----------|-------|-------------|';
|
|
403
|
+
|
|
404
|
+
const rows = categories.map(cat =>
|
|
405
|
+
`| [${cat.name}](./categories/${cat.name.toLowerCase()}.md) | ${cat.toolCount} | ${cat.description} |`
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
return [headers, separator, ...rows].join('\n');
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Generate tools table
|
|
413
|
+
*/
|
|
414
|
+
private generateToolsTable(tools: ToolDocumentation[]): string {
|
|
415
|
+
const headers = '| Tool | Category | Description |';
|
|
416
|
+
const separator = '|------|----------|-------------|';
|
|
417
|
+
|
|
418
|
+
const rows = tools.map(tool =>
|
|
419
|
+
`| [\`${tool.name}\`](./tools/${tool.name}.md) | ${tool.category} | ${tool.description} |`
|
|
420
|
+
);
|
|
421
|
+
|
|
422
|
+
return [headers, separator, ...rows].join('\n');
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Generate type properties table
|
|
427
|
+
*/
|
|
428
|
+
private generateTypePropertiesTable(properties: any[]): string {
|
|
429
|
+
const headers = '| Property | Type | Required | Description |';
|
|
430
|
+
const separator = '|----------|------|----------|-------------|';
|
|
431
|
+
|
|
432
|
+
const rows = properties.map(prop => {
|
|
433
|
+
const required = prop.required ? '✅' : '❌';
|
|
434
|
+
return `| \`${prop.name}\` | \`${prop.type}\` | ${required} | ${prop.description} |`;
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
return [headers, separator, ...rows].join('\n');
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Generate badges for overview
|
|
442
|
+
*/
|
|
443
|
+
private generateBadges(): string {
|
|
444
|
+
return `
|
|
445
|
+

|
|
446
|
+

|
|
447
|
+

|
|
448
|
+

|
|
449
|
+
`;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Generate tool category badge
|
|
454
|
+
*/
|
|
455
|
+
private generateToolBadge(category: string): string {
|
|
456
|
+
const colors = {
|
|
457
|
+
posts: 'blue',
|
|
458
|
+
pages: 'green',
|
|
459
|
+
media: 'purple',
|
|
460
|
+
users: 'orange',
|
|
461
|
+
comments: 'red',
|
|
462
|
+
taxonomies: 'yellow',
|
|
463
|
+
site: 'lightblue',
|
|
464
|
+
auth: 'darkblue',
|
|
465
|
+
cache: 'grey',
|
|
466
|
+
performance: 'brightgreen'
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
const color = colors[category.toLowerCase() as keyof typeof colors] || 'lightgrey';
|
|
470
|
+
return ``;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Format parameters for command examples
|
|
475
|
+
*/
|
|
476
|
+
private formatParameters(params: Record<string, any>): string {
|
|
477
|
+
return Object.entries(params)
|
|
478
|
+
.map(([key, value]) => `--${key}="${value}"`)
|
|
479
|
+
.join(' ');
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Generate additional examples
|
|
484
|
+
*/
|
|
485
|
+
private generateAdditionalExamples(examples: any[]): string {
|
|
486
|
+
return `## Additional Examples
|
|
487
|
+
|
|
488
|
+
${examples.map((example, index) => `### Example ${index + 2}
|
|
489
|
+
\`\`\`json
|
|
490
|
+
${JSON.stringify(example, null, 2)}
|
|
491
|
+
\`\`\`
|
|
492
|
+
`).join('\n')}`;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documentation System Entry Point
|
|
3
|
+
* Exports all documentation generation components
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { DocumentationGenerator } from './DocumentationGenerator.js';
|
|
7
|
+
export { MarkdownFormatter } from './MarkdownFormatter.js';
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
DocumentationConfig,
|
|
11
|
+
ToolDocumentation,
|
|
12
|
+
ParameterDocumentation,
|
|
13
|
+
ExampleUsage,
|
|
14
|
+
ErrorDocumentation,
|
|
15
|
+
DocumentationOutput,
|
|
16
|
+
CategoryDocumentation,
|
|
17
|
+
TypeDocumentation,
|
|
18
|
+
PropertyDocumentation,
|
|
19
|
+
OpenAPISpecification,
|
|
20
|
+
DocumentationSummary
|
|
21
|
+
} from './DocumentationGenerator.js';
|