NAME
extract-schemas - Extract test schemas from Perl modules
SYNOPSIS
extract-schemas [options] <module.pm>
Options:
--output-dir DIR Output directory for schema files (default: schemas/)
--verbose Show detailed analysis
--help Show this help message
--man Show full documentation
Examples:
extract-schemas lib/MyModule.pm
extract-schemas --output-dir my_schemas --verbose lib/MyModule.pm
extract-schemas --help
DESCRIPTION
This tool analyzes a Perl module and generates YAML schema files for each method, suitable for use with App::Test::Generator.
The extractor uses three sources of information:
- 1. POD Documentation
-
Parses parameter descriptions from POD to extract types and constraints.
- 2. Code Analysis
-
Analyzes validation patterns in the code (ref checks, length checks, etc.)
- 3. Method Signatures
-
Extracts parameter names from method signatures.
The tool assigns a confidence level (high/medium/low) to each schema based on how much information it could infer.
SCHEMA FORMAT
The generated YAML files have the following structure:
method: method_name
confidence: high|medium|low
notes:
- Any warnings or suggestions
input:
param_name:
type: string|integer|number|boolean|arrayref|hashref
min: 5
max: 100
optional: 0
matches: /pattern/
CONFIDENCE LEVELS
- high
-
Strong evidence from POD and code analysis. Schema should be accurate.
- medium
-
Partial information available. Review recommended.
- low
-
Limited information. Manual review required.
EXAMPLES
Basic Usage
extract-schemas lib/MyModule.pm
Extracts schemas to ./schemas/ directory.
Custom Output Directory
extract-schemas --output-dir test_schemas lib/MyModule.pm
Verbose Mode
extract-schemas --verbose lib/MyModule.pm
Shows detailed analysis of each method.
NEXT STEPS
After extracting schemas:
1. Review the generated YAML files, especially those marked low confidence 2. Edit the schemas to add missing information or correct errors 3. Use the schemas with App::Test::Generator:
test-generator --schema schemas/my_method.yaml
SEE ALSO
App::Test::Generator, PPI, Pod::Simple
AUTHOR
Nigel Horne