Plating API Reference¶
This page contains the complete API reference for the Plating package, automatically generated from source code docstrings.
Quick Links¶
For practical guides and usage examples, see:
- Getting Started - Installation and quick start guide
- API Reference - Comprehensive API documentation with examples
- Authoring Guide - Creating and maintaining plating bundles
- CLAUDE.md - Development setup and architecture overview
API Documentation¶
Auto-generated API documentation for plating:
Modern async documentation generation with full foundation integration.
A clean, type-safe API for generating high-quality Terraform/OpenTofu provider documentation with foundation patterns.
Key Features: - Type-safe async-first API - Full foundation integration (retry, metrics, circuit breakers) - Registry-based component discovery - Integrated markdown validation with configurable rules - Context-aware template rendering with Jinja2 - Support for resources, data sources, functions, and provider docs
Example Usage
import asyncio
from pathlib import Path
from plating import Plating, ComponentType, PlatingContext
from provide.foundation import pout
async def main():
# Initialize with foundation context
context = PlatingContext(
provider_name="my_provider",
log_level="INFO",
no_color=False
)
api = Plating(context)
# Create missing templates
adorn_result = await api.adorn(component_types=[ComponentType.RESOURCE])
pout(f"✅ Created {adorn_result.templates_generated} templates")
# Generate docs with validation
plate_result = await api.plate(
Path("docs"),
component_types=[ComponentType.RESOURCE],
validate_markdown=True,
force=True
)
if plate_result.success:
pout(f"✅ Generated {len(plate_result.output_files)} files")
# Validate existing documentation
validation_result = await api.validate()
pout(f"📊 Validation: {validation_result.passed}/{validation_result.total} passed")
# Run the async main
asyncio.run(main())
CLI Usage
Attributes¶
__all__
module-attribute
¶
__all__ = [
"AdornResult",
"ArgumentInfo",
"AsyncTemplateEngine",
"ComponentType",
"DocumentationAdorner",
"DocumentationPlater",
"FunctionPlatingBundle",
"ModularPlatingBundle",
"ModularPlatingDiscovery",
"PlateResult",
"Plating",
"PlatingContext",
"PlatingRegistry",
"SchemaInfo",
"TemplateMetadataExtractor",
"ValidationResult",
"__version__",
"get_plating_registry",
"plating",
"plating_metrics",
"reset_plating_registry",
"template_engine",
"with_circuit_breaker",
"with_metrics",
"with_retry",
"with_timing",
]
Classes¶
FunctionPlatingBundle
¶
Bases: PlatingBundle
Specialized PlatingBundle for individual function templates.
ModularPlatingBundle
¶
Represents a single .plating bundle with its assets.
Attributes¶
Functions¶
has_main_template
¶
Check if bundle has a main template file.
Source code in plating/bundles/base.py
has_examples
¶
Check if bundle has example files (flat .tf or grouped).
Source code in plating/bundles/base.py
load_main_template
¶
Load the main template file for this component.
Source code in plating/bundles/base.py
load_examples
¶
Load all example files - both flat .tf and grouped subdirs.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary mapping example name to content: |
dict[str, str]
|
|
dict[str, str]
|
|
Source code in plating/bundles/base.py
load_partials
¶
Load all partial files from docs directory.
Source code in plating/bundles/base.py
load_fixtures
¶
Load all fixture files from fixtures directory.
Source code in plating/bundles/base.py
get_example_groups
¶
Get names of example groups (subdirectories with main.tf).
Returns:
| Type | Description |
|---|---|
list[str]
|
List of group names (subdirectory names) |
Source code in plating/bundles/base.py
load_group_fixtures
¶
Load fixture files from a specific example group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_name
|
str
|
Name of the example group |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Path]
|
Dictionary mapping relative path to source Path object |
Source code in plating/bundles/base.py
ModularPlatingDiscovery
¶
Discovers .plating bundles from installed packages.
Initialize discovery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_name
|
str | None
|
Specific package to search, or None to search all packages |
None
|
Source code in plating/discovery/finder.py
Attributes¶
Functions¶
discover_bundles
¶
Discover all .plating bundles from installed package(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_type
|
str | None
|
Optional filter for specific component type |
None
|
Returns:
| Type | Description |
|---|---|
list[PlatingBundle]
|
List of discovered PlatingBundle objects |
Source code in plating/discovery/finder.py
DocumentationAdorner
¶
Enhances documentation content with metadata and template variables.
Source code in plating/generation/adorner.py
Attributes¶
Functions¶
adorn_function_template
¶
adorn_function_template(
template_content: str,
function_name: str,
metadata: dict[str, Any],
) -> dict[str, Any]
Create template context for function documentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_content
|
str
|
Raw template content |
required |
function_name
|
str
|
Name of the function |
required |
metadata
|
dict[str, Any]
|
Function metadata from extractor |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing all template variables |
Source code in plating/generation/adorner.py
adorn_resource_template
¶
adorn_resource_template(
template_content: str,
resource_name: str,
metadata: dict[str, Any],
) -> dict[str, Any]
Create template context for resource documentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_content
|
str
|
Raw template content |
required |
resource_name
|
str
|
Name of the resource |
required |
metadata
|
dict[str, Any]
|
Resource metadata |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing all template variables |
Source code in plating/generation/adorner.py
enhance_template_context
¶
enhance_template_context(
context: dict[str, Any], additional_data: dict[str, Any]
) -> dict[str, Any]
Enhance template context with additional metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Base template context |
required |
additional_data
|
dict[str, Any]
|
Additional data to merge |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Enhanced template context |
Source code in plating/generation/adorner.py
DocumentationPlater
¶
Orchestrates the complete documentation generation process using async rendering.
Source code in plating/generation/plater.py
Attributes¶
Functions¶
generate_documentation
async
¶
generate_documentation(
output_dir: Path, component_type: str | None = None
) -> list[tuple[Path, str]]
Generate documentation for all discovered components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path
|
Directory to write generated documentation |
required |
component_type
|
str | None
|
Optional filter for component type |
None
|
Returns:
| Type | Description |
|---|---|
list[tuple[Path, str]]
|
List of (file_path, content) tuples for generated files |
Source code in plating/generation/plater.py
Plating
¶
Modern async API for all plating operations with foundation integration.
Initialize plating API with foundation context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
PlatingContext
|
PlatingContext with configuration (required) |
required |
package_name
|
str | None
|
Package to search for plating bundles, or None to search all packages |
None
|
Source code in plating/plating.py
Attributes¶
retry_policy
instance-attribute
¶
retry_policy = RetryPolicy(
max_attempts=3,
backoff=EXPONENTIAL,
base_delay=0.5,
max_delay=10.0,
retryable_errors=(
IOError,
OSError,
TimeoutError,
ConnectionError,
),
)
Functions¶
adorn
async
¶
Generate template structure for discovered components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_types
|
list[ComponentType] | None
|
Specific component types to adorn |
None
|
Returns:
| Type | Description |
|---|---|
AdornResult
|
AdornResult with generation statistics |
Source code in plating/plating.py
plate
async
¶
plate(
output_dir: Path | None = None,
component_types: list[ComponentType] | None = None,
force: bool = False,
validate_markdown: bool = True,
project_root: Path | None = None,
flat_nav: bool = False,
) -> PlateResult
Generate documentation from plating bundles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path | None
|
Output directory for documentation |
None
|
component_types
|
list[ComponentType] | None
|
Component types to generate |
None
|
force
|
bool
|
Overwrite existing files |
False
|
validate_markdown
|
bool
|
Enable markdown validation |
True
|
project_root
|
Path | None
|
Project root directory (auto-detected if not provided) |
None
|
flat_nav
|
bool
|
Generate flat registry-style navigation (default: grouped by capability) |
False
|
Returns:
| Type | Description |
|---|---|
PlateResult
|
PlateResult with generation statistics |
Source code in plating/plating.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
validate
async
¶
validate(
output_dir: Path | None = None,
component_types: list[ComponentType] | None = None,
project_root: Path | None = None,
) -> ValidationResult
Validate generated documentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path | None
|
Directory containing documentation |
None
|
component_types
|
list[ComponentType] | None
|
Component types to validate |
None
|
project_root
|
Path | None
|
Project root directory (auto-detected if not provided) |
None
|
Returns:
| Type | Description |
|---|---|
ValidationResult
|
ValidationResult with any errors found |
Source code in plating/plating.py
get_registry_stats
¶
Get registry statistics.
Source code in plating/plating.py
PlatingRegistry
¶
Bases: Registry
Component registry using foundation Registry pattern with ComponentSet support.
Initialize registry with package discovery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_name
|
str | None
|
Package to search for plating bundles, or None to search all packages |
None
|
Source code in plating/registry.py
Attributes¶
Functions¶
get_components
¶
Get all components of a specific type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_type
|
ComponentType
|
The component type to filter by |
required |
Returns:
| Type | Description |
|---|---|
list[PlatingBundle]
|
List of PlatingBundle objects |
Source code in plating/registry.py
get_component
¶
Get a specific component by type and name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_type
|
ComponentType
|
The component type |
required |
name
|
str
|
The component name |
required |
Returns:
| Type | Description |
|---|---|
PlatingBundle | None
|
PlatingBundle if found, None otherwise |
Source code in plating/registry.py
get_components_with_templates
¶
Get components of a type that have templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_type
|
ComponentType
|
The component type to filter by |
required |
Returns:
| Type | Description |
|---|---|
list[PlatingBundle]
|
List of PlatingBundle objects with templates |
Source code in plating/registry.py
get_components_with_examples
¶
Get components of a type that have examples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_type
|
ComponentType
|
The component type to filter by |
required |
Returns:
| Type | Description |
|---|---|
list[PlatingBundle]
|
List of PlatingBundle objects with examples |
Source code in plating/registry.py
get_all_component_types
¶
Get all registered component types.
Returns:
| Type | Description |
|---|---|
list[ComponentType]
|
List of ComponentType enums found in registry |
Source code in plating/registry.py
refresh
¶
get_registry_stats
¶
Get statistics about the registry contents.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with registry statistics |
Source code in plating/registry.py
AsyncTemplateEngine
¶
Async-first template engine with foundation integration.
Source code in plating/templating/engine.py
Functions¶
render
async
¶
Render template with context and partials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundle
|
PlatingBundle
|
PlatingBundle containing template and assets |
required |
context
|
PlatingContext
|
Type-safe context for rendering |
required |
Returns:
| Type | Description |
|---|---|
str
|
Rendered template string |
Raises:
| Type | Description |
|---|---|
TemplateError
|
If template rendering fails |
FileSystemError
|
If template loading fails |
Source code in plating/templating/engine.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
render_batch
async
¶
Render multiple templates in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
list[tuple[PlatingBundle, PlatingContext]]
|
List of (bundle, context) tuples to render |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of rendered template strings |
Raises:
| Type | Description |
|---|---|
TemplateError
|
If any template rendering fails |
FileSystemError
|
If any template loading fails |
Source code in plating/templating/engine.py
TemplateMetadataExtractor
¶
Extracts metadata from function implementations for template rendering.
Source code in plating/templating/metadata.py
Attributes¶
Functions¶
extract_function_metadata
¶
Extract metadata for a function to populate templates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_name
|
str
|
Name of the function |
required |
component_type
|
str
|
Type of component (function, resource, etc.) |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing metadata for template rendering |
Source code in plating/templating/metadata.py
discover_template_files
¶
Discover all template files in a docs directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
docs_dir
|
Path
|
Directory containing template files |
required |
Returns:
| Type | Description |
|---|---|
list[Path]
|
List of template file paths |
Source code in plating/templating/metadata.py
ArgumentInfo
¶
ComponentType
¶
Bases: Enum
Type-safe component types for Terraform/OpenTofu providers.
Supported types: - RESOURCE: Terraform resources - DATA_SOURCE: Terraform data sources - FUNCTION: Provider-defined functions - PROVIDER: Provider configuration
SchemaInfo
¶
Structured schema information.
Attributes¶
attributes
class-attribute
instance-attribute
¶
Functions¶
from_dict
classmethod
¶
Create SchemaInfo from a raw schema dictionary.
Source code in plating/types.py
to_markdown
¶
Convert schema to markdown format.
Source code in plating/types.py
Functions¶
with_circuit_breaker
¶
with_circuit_breaker(
failure_threshold: int = 3,
recovery_timeout: float = 30.0,
expected_exception: type[Exception] = Exception,
) -> Callable[[F], F]
Decorator for circuit breaker protection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
failure_threshold
|
int
|
Number of failures before opening circuit |
3
|
recovery_timeout
|
float
|
Time to wait before attempting recovery |
30.0
|
expected_exception
|
type[Exception]
|
Exception type that triggers circuit breaker |
Exception
|
Source code in plating/decorators.py
with_metrics
¶
Decorator for automatic metrics collection via structured logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_name
|
str
|
Name for the operation metrics |
required |
Source code in plating/decorators.py
with_retry
¶
with_retry(
max_attempts: int = 3,
backoff: str = "exponential",
base_delay: float = 1.0,
max_delay: float = 60.0,
retryable_errors: tuple[type[Exception], ...] = (
Exception,
),
) -> Callable[[F], F]
Decorator for automatic retry with exponential backoff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_attempts
|
int
|
Maximum number of retry attempts |
3
|
backoff
|
str
|
Backoff strategy ("exponential", "linear", "constant") |
'exponential'
|
base_delay
|
float
|
Base delay between retries |
1.0
|
max_delay
|
float
|
Maximum delay between retries |
60.0
|
retryable_errors
|
tuple[type[Exception], ...]
|
Tuple of exception types that should trigger retry |
(Exception,)
|
Source code in plating/decorators.py
with_timing
¶
Decorator for automatic timing with structured logging.
Uses foundation's timed_block for consistent timing and logging.
Source code in plating/decorators.py
get_plating_registry
¶
Get or create the global plating registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package_name
|
str | None
|
Package to search for components, or None to search all packages |
None
|
Returns:
| Type | Description |
|---|---|
PlatingRegistry
|
PlatingRegistry instance |