|
1 | | -# PHP README and Documentation Generation |
| 1 | +# PHP README/WRITEME and Documentation Generation |
2 | 2 |
|
3 | | -## MANDATORY: Knowledge Base Consultation (FIRST STEP) |
4 | | -**🚨 CRITICAL - Must be completed BEFORE any code generation** |
| 3 | +## Purpose |
| 4 | +Generate and update README files and documentation using the writeme tool to ensure consistency and completeness. |
| 5 | + |
| 6 | +## Requirements |
| 7 | +- **Automated Generation**: Use writeme tool for README generation |
| 8 | +- **Metadata Dependency**: Requires complete metadata files |
| 9 | +- **Virtual Environment**: Run writeme in isolated environment |
| 10 | +- **Validation**: Ensure all documentation is up-to-date |
| 11 | + |
| 12 | +## File Structure |
| 13 | +``` |
| 14 | +php/example_code/{service}/ |
| 15 | +├── README.md # Generated service README |
| 16 | +├── composer.json # Dependencies |
| 17 | +└── {service}_metadata.yaml # Metadata (in .doc_gen/metadata/) |
| 18 | +``` |
| 19 | + |
| 20 | +## README Generation Process |
5 | 21 |
|
| 22 | +### Step 1: Setup Writeme Environment |
6 | 23 | ```bash |
7 | | -# Step 1: List available knowledge bases |
8 | | -ListKnowledgeBases() |
| 24 | +cd .tools/readmes |
9 | 25 |
|
10 | | -# Step 2: Query coding standards (REQUIRED) |
11 | | -QueryKnowledgeBases("coding-standards-KB", "PHP-code-example-standards") |
| 26 | +# Create virtual environment |
| 27 | +python -m venv .venv |
12 | 28 |
|
13 | | -# Step 3: Query implementation patterns (REQUIRED) |
14 | | -QueryKnowledgeBases("PHP-premium-KB", "PHP implementation patterns documentation") |
| 29 | +# Activate environment (Linux/macOS) |
| 30 | +source .venv/bin/activate |
15 | 31 |
|
16 | | -# Step 4: AWS service research (REQUIRED) |
17 | | -search_documentation("What is [AWS Service] and what are its key API operations?") |
18 | | -read_documentation("https://docs.aws.amazon.com/[service]/latest/[relevant-page]") |
| 32 | +# Activate environment (Windows) |
| 33 | +.venv\Scripts\activate |
| 34 | + |
| 35 | +# Install dependencies |
| 36 | +python -m pip install -r requirements_freeze.txt |
19 | 37 | ``` |
20 | 38 |
|
21 | | -**FAILURE TO COMPLETE KNOWLEDGE BASE CONSULTATION WILL RESULT IN INCORRECT CODE STRUCTURE** |
| 39 | +### Step 2: Generate README |
| 40 | +```bash |
| 41 | +# Generate README for specific service |
| 42 | +python -m writeme --languages PHP:3 --services {service} |
| 43 | +``` |
22 | 44 |
|
23 | | -## Purpose |
24 | | -Generate comprehensive README documentation for PHP AWS SDK examples with setup instructions, usage examples, and troubleshooting guidance. |
| 45 | +### Step 3: Validate Generation |
| 46 | +- ✅ **README.md created/updated** in service directory |
| 47 | +- ✅ **No generation errors** in writeme output |
| 48 | +- ✅ **All examples listed** in README |
| 49 | +- ✅ **Proper formatting** and structure |
| 50 | +- ✅ **Working links** to code files |
| 51 | + |
| 52 | +## README Content Structure |
| 53 | + |
| 54 | +### Generated README Sections |
| 55 | +1. **Service Overview**: Description of AWS service |
| 56 | +2. **Code Examples**: List of available examples |
| 57 | +3. **Prerequisites**: Setup requirements |
| 58 | +4. **Installation**: Dependency installation |
| 59 | +5. **Usage**: How to run examples |
| 60 | +6. **Tests**: Testing instructions |
| 61 | +7. **Additional Resources**: Links to documentation |
25 | 62 |
|
26 | 63 | ## README Structure Template |
27 | 64 |
|
@@ -277,48 +314,74 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
277 | 314 | SPDX-License-Identifier: Apache-2.0 |
278 | 315 | ``` |
279 | 316 |
|
280 | | -## Documentation Requirements |
281 | | -
|
282 | | -### Essential Sections |
283 | | -- ✅ **Overview**: Clear service description and use cases |
284 | | -- ✅ **Prerequisites**: PHP version, SDK version, credentials |
285 | | -- ✅ **Setup**: Step-by-step installation and configuration |
286 | | -- ✅ **Code Examples**: Links to all example files with descriptions |
287 | | -- ✅ **Running Examples**: Clear execution instructions |
288 | | -- ✅ **Testing**: Unit and integration test instructions |
289 | | -- ✅ **Troubleshooting**: Common issues and solutions |
290 | | -- ✅ **Additional Resources**: Links to AWS documentation |
291 | | -
|
292 | | -### Code Example Documentation |
293 | | -- **Hello Examples**: Basic connectivity demonstration |
294 | | -- **Scenarios**: Complete workflow examples |
295 | | -- **Actions**: Individual API operation examples |
296 | | -- **Service Classes**: Wrapper class usage examples |
297 | | -
|
298 | | -### Setup Instructions |
299 | | -- **Dependencies**: Composer install process |
300 | | -- **Credentials**: Multiple configuration methods |
301 | | -- **Verification**: Test setup with Hello example |
302 | | -- **Environment**: PHP and extension requirements |
303 | | -
|
304 | | -### Troubleshooting Guide |
305 | | -- **Common Errors**: Installation, credentials, permissions |
306 | | -- **Debug Methods**: Environment variables, client configuration |
307 | | -- **Service Errors**: Specific error codes and solutions |
308 | | -- **Performance**: Memory and timeout considerations |
309 | | -
|
310 | | -### Testing Documentation |
311 | | -- **Unit Tests**: Mock-based testing approach |
312 | | -- **Integration Tests**: Real AWS service testing |
313 | | -- **Code Quality**: Linting and formatting tools |
314 | | -- **CI/CD**: Automated testing workflows |
315 | | -
|
316 | | -## README Generation Checklist |
317 | | -- ✅ **Service-specific content** customized for the AWS service |
318 | | -- ✅ **Working code examples** with actual file references |
319 | | -- ✅ **Complete setup instructions** from prerequisites to execution |
320 | | -- ✅ **Comprehensive troubleshooting** covering common issues |
321 | | -- ✅ **Testing instructions** for both unit and integration tests |
322 | | -- ✅ **Code quality guidelines** with linting commands |
323 | | -- ✅ **Resource links** to official AWS documentation |
324 | | -- ✅ **Copyright and license** information included |
| 317 | +## Documentation Dependencies |
| 318 | +
|
| 319 | +### Required Files for README Generation |
| 320 | +- ✅ **Metadata file**: `.doc_gen/metadata/{service}_metadata.yaml` |
| 321 | +- ✅ **Code files**: All referenced PHP files must exist |
| 322 | +- ✅ **Snippet tags**: All snippet tags in metadata must exist in code |
| 323 | +- ✅ **Composer file**: `composer.json` with dependencies |
| 324 | +
|
| 325 | +### Metadata Integration |
| 326 | +The writeme tool uses metadata to: |
| 327 | +- Generate example lists and descriptions |
| 328 | +- Create links to specific code sections |
| 329 | +- Include proper service information |
| 330 | +- Format documentation consistently |
| 331 | +
|
| 332 | +## Troubleshooting README Generation |
| 333 | +
|
| 334 | +### Common Issues |
| 335 | +- **Missing metadata**: Ensure metadata file exists and is valid |
| 336 | +- **Broken snippet tags**: Verify all snippet tags exist in code |
| 337 | +- **File not found**: Check all file paths in metadata |
| 338 | +- **Invalid YAML**: Validate metadata YAML syntax |
| 339 | +
|
| 340 | +### Error Resolution |
| 341 | +```bash |
| 342 | +# Check for metadata errors |
| 343 | +python -m writeme --languages PHP:3 --services {service} --verbose |
| 344 | +
|
| 345 | +# Validate specific metadata file |
| 346 | +python -c "import yaml; yaml.safe_load(open('.doc_gen/metadata/{service}_metadata.yaml'))" |
| 347 | +
|
| 348 | +# Check for missing snippet tags |
| 349 | +grep -r "snippet-start" php/example_code/{service}/ |
| 350 | +``` |
| 351 | + |
| 352 | +## README Maintenance |
| 353 | + |
| 354 | +### When to Regenerate README |
| 355 | +- ✅ **After adding new examples** |
| 356 | +- ✅ **After updating metadata** |
| 357 | +- ✅ **After changing code structure** |
| 358 | +- ✅ **Before committing changes** |
| 359 | +- ✅ **During regular maintenance** |
| 360 | + |
| 361 | +### README Quality Checklist |
| 362 | +- ✅ **All examples listed** and properly linked |
| 363 | +- ✅ **Prerequisites accurate** and complete |
| 364 | +- ✅ **Installation instructions** work correctly |
| 365 | +- ✅ **Usage examples** are clear and correct |
| 366 | +- ✅ **Links functional** and point to right locations |
| 367 | +- ✅ **Formatting consistent** with other services |
| 368 | + |
| 369 | +## Integration with CI/CD |
| 370 | + |
| 371 | +### Automated README Validation |
| 372 | +```bash |
| 373 | +# In CI/CD pipeline, validate README is up-to-date |
| 374 | +cd .tools/readmes |
| 375 | +source .venv/bin/activate |
| 376 | +python -m writeme --languages PHP:3 --services {service} --check |
| 377 | + |
| 378 | +# Exit with error if README needs updates |
| 379 | +if git diff --exit-code php/example_code/{service}/README.md; then |
| 380 | + echo "README is up-to-date" |
| 381 | +else |
| 382 | + echo "README needs to be regenerated" |
| 383 | + exit 1 |
| 384 | +fi |
| 385 | +``` |
| 386 | + |
| 387 | +This ensures documentation stays synchronized with code changes. |
0 commit comments