API documentation¶
Complete API reference for Griffonner’s Python modules.
Core modules¶
griffonner.core¶
Main generation functionality.
Main generation logic for Griffonner.
Classes:
-
GenerationError–Base exception for generation errors.
Functions:
-
categorise_files–Categorise files into frontmatter files and passthrough files.
-
copy_file_passthrough–Copy a file from source to output preserving directory structure.
-
find_all_files–Find all files in a directory recursively, excluding ignored patterns.
-
generate–Generate documentation from a file or directory.
-
generate_directory–Generate documentation from all files in a directory.
-
generate_file–Generate documentation files from a source file with frontmatter.
categorise_files
¶
copy_file_passthrough
¶
copy_file_passthrough(source_file: Path, source_dir: Path, output_dir: Path) -> Path
find_all_files
¶
generate
¶
generate(source: Path, output_dir: Path, template_dirs: Optional[List[Path]] = None, plugin_manager: Optional[PluginManager] = None, ignore_patterns: Optional[List[str]] = None, default_griffe_config: Optional[Dict[str, Any]] = None) -> List[Path]
Generate documentation from a file or directory.
Parameters:
-
(source¶Path) –Source file or directory path
-
(output_dir¶Path) –Output directory path
-
(template_dirs¶Optional[List[Path]], default:None) –Additional template search directories
-
(plugin_manager¶Optional[PluginManager], default:None) –Optional plugin manager for processors/filters
-
(ignore_patterns¶Optional[List[str]], default:None) –Glob patterns to ignore
-
(default_griffe_config¶Optional[Dict[str, Any]], default:None) –Default Griffe configuration to merge with frontmatter
Returns:
Raises:
-
GenerationError–If generation fails
generate_directory
¶
generate_directory(pages_dir: Path, output_dir: Path, template_dirs: Optional[List[Path]] = None, plugin_manager: Optional[PluginManager] = None, ignore_patterns: Optional[List[str]] = None, default_griffe_config: Optional[Dict[str, Any]] = None) -> List[Path]
Generate documentation from all files in a directory.
Parameters:
-
(pages_dir¶Path) –Directory containing source files (with or without frontmatter)
-
(output_dir¶Path) –Base output directory
-
(template_dirs¶Optional[List[Path]], default:None) –Additional template search directories
-
(plugin_manager¶Optional[PluginManager], default:None) –Optional plugin manager for processors/filters
-
(ignore_patterns¶Optional[List[str]], default:None) –Glob patterns to ignore
-
(default_griffe_config¶Optional[Dict[str, Any]], default:None) –Default Griffe configuration to merge with frontmatter
Returns:
Raises:
-
GenerationError–If generation fails
generate_file
¶
generate_file(source_file: Path, source_dir: Path, output_dir: Path, template_dirs: Optional[List[Path]] = None, plugin_manager: Optional[PluginManager] = None, default_griffe_config: Optional[Dict[str, Any]] = None) -> List[Path]
Generate documentation files from a source file with frontmatter.
Parameters:
-
(source_file¶Path) –Path to source file with frontmatter
-
(source_dir¶Path) –Base source directory for calculating relative paths
-
(output_dir¶Path) –Base output directory
-
(template_dirs¶Optional[List[Path]], default:None) –Additional template search directories
-
(plugin_manager¶Optional[PluginManager], default:None) –Optional plugin manager for processors/filters
-
(default_griffe_config¶Optional[Dict[str, Any]], default:None) –Default Griffe configuration to merge with frontmatter
Returns:
Raises:
-
GenerationError–If generation fails
griffonner.cli¶
Command-line interface implementation.
Typer-based CLI for Griffonner.
Functions:
-
bundle_info_cmd–Show detailed information about a specific bundle.
-
generate_cmd–Generate documentation from source files with frontmatter.
-
main–Main entry point for the CLI.
-
main_callback–Main callback to handle global options.
-
plugins_cmd–List all available plugins (processors, filters, bundles).
-
setup_logging–Set up logging configuration.
-
templates–List available templates.
-
validate–Validate template syntax and structure.
-
version_callback–Print version and exit if –version is provided.
-
watch–Watch source directory for changes and regenerate documentation.
bundle_info_cmd
¶
bundle_info_cmd(bundle_name: Annotated[str, Argument(help='Bundle name to inspect')], verbose: Annotated[Optional[bool], Option(--verbose, -v, help='Enable verbose output')] = None) -> None
Show detailed information about a specific bundle.
Configuration is loaded from griffonner.yml/griffonner.yaml or pyproject.toml for verbose setting.
generate_cmd
¶
generate_cmd(source: Annotated[Path, Argument(help='Source file or directory with frontmatter')], output_dir: Annotated[Optional[Path], Option(--output, -o, help='Output directory')] = None, template_dirs: Annotated[Optional[List[Path]], Option(--template - dir, -t, help='Additional template directories')] = None, local_plugins: Annotated[Optional[List[str]], Option(--local - plugins, -l, help='Python modules containing local plugins')] = None, ignore: Annotated[Optional[List[str]], Option(--ignore, help='Glob patterns to ignore in source directory')] = None, verbose: Annotated[Optional[bool], Option(--verbose, -v, help='Enable verbose output')] = None) -> None
Generate documentation from source files with frontmatter.
Configuration is loaded from griffonner.yml/griffonner.yaml or pyproject.toml. CLI arguments override configuration file values.
main_callback
¶
main_callback(version: Annotated[Optional[bool], Option(--version, callback=version_callback, is_eager=True, help='Show version')] = None) -> None
Main callback to handle global options.
plugins_cmd
¶
plugins_cmd(local_plugins: Annotated[Optional[List[str]], Option(--local - plugins, -l, help='Python modules containing local plugins')] = None, verbose: Annotated[Optional[bool], Option(--verbose, -v, help='Enable verbose output')] = None) -> None
List all available plugins (processors, filters, bundles).
Configuration is loaded from griffonner.yml/griffonner.yaml or pyproject.toml. CLI arguments override configuration file values.
setup_logging
¶
templates
¶
templates(template_dirs: Annotated[Optional[List[Path]], Option(--template - dir, -t, help='Template directories to search')] = None, pattern: Annotated[Optional[str], Option(--pattern, -p, help='Pattern to match templates')] = None, verbose: Annotated[Optional[bool], Option(--verbose, -v, help='Enable verbose output')] = None) -> None
List available templates.
Configuration is loaded from griffonner.yml/griffonner.yaml or pyproject.toml. CLI arguments override configuration file values.
validate
¶
validate(template_path: Annotated[str, Argument(help='Template path to validate')], template_dirs: Annotated[Optional[List[Path]], Option(--template - dir, -t, help='Template directories to search')] = None, verbose: Annotated[Optional[bool], Option(--verbose, -v, help='Enable verbose output')] = None) -> None
Validate template syntax and structure.
Configuration is loaded from griffonner.yml/griffonner.yaml or pyproject.toml. CLI arguments override configuration file values.
version_callback
¶
version_callback(value: bool) -> None
Print version and exit if –version is provided.
watch
¶
watch(source: Annotated[Path, Argument(help='Source directory to watch')], output_dir: Annotated[Optional[Path], Option(--output, -o, help='Output directory')] = None, template_dirs: Annotated[Optional[List[Path]], Option(--template - dir, -t, help='Additional template directories')] = None, local_plugins: Annotated[Optional[List[str]], Option(--local - plugins, -l, help='Python modules containing local plugins')] = None, ignore: Annotated[Optional[List[str]], Option(--ignore, help='Glob patterns to ignore in source directory')] = None, verbose: Annotated[Optional[bool], Option(--verbose, -v, help='Enable verbose output')] = None) -> None
Watch source directory for changes and regenerate documentation.
Configuration is loaded from griffonner.yml/griffonner.yaml or pyproject.toml. CLI arguments override configuration file values.
griffonner.frontmatter¶
YAML frontmatter parsing and validation.
YAML frontmatter parsing for Griffonner.
Classes:
-
FrontmatterConfig–Configuration parsed from frontmatter.
-
OutputItem–Single output configuration.
-
ParsedFile–A parsed file with frontmatter and content.
-
ProcessorConfig–Configuration for processors.
Functions:
-
find_frontmatter_files–Find all files with frontmatter in a directory.
-
parse_frontmatter_file–Parse a file with YAML frontmatter.
FrontmatterConfig
¶
Bases: BaseModel
Configuration parsed from frontmatter.
Methods:
-
validate_template–Validate template path format.
OutputItem
¶
Bases: BaseModel
Single output configuration.
ParsedFile
¶
Bases: BaseModel
A parsed file with frontmatter and content.
ProcessorConfig
¶
Bases: BaseModel
Configuration for processors.
find_frontmatter_files
¶
Find all files with frontmatter in a directory.
Parameters:
Returns:
Raises:
-
NotADirectoryError–If directory doesn’t exist or isn’t a directory
parse_frontmatter_file
¶
parse_frontmatter_file(file_path: Path) -> ParsedFile
Parse a file with YAML frontmatter.
Parameters:
Returns:
-
ParsedFile–ParsedFile with frontmatter config and content
Raises:
-
ValueError–If frontmatter is invalid or missing
-
FileNotFoundError–If file doesn’t exist
griffonner.griffe_wrapper¶
Griffe integration for Python code analysis.
Minimal Griffe integration for Griffonner.
Classes:
-
GriffeError–Base exception for Griffe-related errors.
-
ModuleLoadError–Exception raised when a module cannot be loaded.
Functions:
-
load_griffe_object–Load a Griffe object using flexible configuration.
ModuleLoadError
¶
Bases: GriffeError
Exception raised when a module cannot be loaded.
load_griffe_object
¶
load_griffe_object(target: str, search_paths: Optional[List[Path]] = None, griffe_config: Optional[Dict[str, Any]] = None) -> Union[Object, Alias]
Load a Griffe object using flexible configuration.
Parameters:
-
(target¶str) –Module name (e.g., ‘mypackage.utils’, ‘os’, ‘pathlib’)
-
(search_paths¶Optional[List[Path]], default:None) –Additional paths to search for modules
-
(griffe_config¶Optional[Dict[str, Any]], default:None) –Griffe configuration with loader options and method calls
Returns:
-
Union[Object, Alias]–Raw Griffe object
Raises:
-
ModuleLoadError–If target cannot be loaded
griffonner.templates¶
Template discovery, loading, and validation.
Template discovery and loading for Griffonner.
Classes:
-
TemplateError–Base exception for template-related errors.
-
TemplateLoader–Handles template discovery and loading.
-
TemplateNotFoundError–Exception raised when a template cannot be found.
-
TemplateValidationError–Exception raised when a template fails validation.
TemplateLoader
¶
TemplateLoader(template_dirs: Optional[List[Path]] = None, plugin_manager: Optional[PluginManager] = None)
Handles template discovery and loading.
Parameters:
-
(template_dirs¶Optional[List[Path]], default:None) –Directories to search for templates
-
(plugin_manager¶Optional[PluginManager], default:None) –Optional plugin manager for custom filters
Methods:
-
find_default_template–Find the default template for a given object kind.
-
find_templates–Find all templates matching a pattern.
-
get_available_template_sets–Get list of available template sets.
-
load_template–Load a template by path.
-
render_template–Render a template with the given context.
-
suggest_template–Suggest alternative templates when a template is not found.
-
validate_template–Validate a template for syntax errors.
find_default_template
¶
find_templates
¶
get_available_template_sets
¶
load_template
¶
load_template(template_path: str) -> Template
Load a template by path.
Parameters:
Returns:
-
Template–Loaded Jinja2 template
Raises:
-
TemplateNotFoundError–If template cannot be found
render_template
¶
Render a template with the given context.
Parameters:
-
(template_path¶str) –Relative path to template
-
(context¶Dict[str, Any]) –Template context variables
Returns:
-
str–Rendered template content
Raises:
-
TemplateNotFoundError–If template cannot be found
-
TemplateError–If template rendering fails
suggest_template
¶
suggest_template(template_path: str) -> List[str]
validate_template
¶
validate_template(template_path: str) -> None
Validate a template for syntax errors.
Parameters:
Raises:
-
TemplateValidationError–If template has syntax errors
-
TemplateNotFoundError–If template cannot be found
TemplateNotFoundError
¶
Bases: TemplateError
Exception raised when a template cannot be found.
TemplateValidationError
¶
Bases: TemplateError
Exception raised when a template fails validation.
griffonner.watcher¶
File system watcher for development workflows.
File system watcher for Griffonner.
Classes:
-
DocumentationWatcher–Watches for changes in documentation source files.
-
GriffonnerEventHandler–Handles file system events for Griffonner.
DocumentationWatcher
¶
DocumentationWatcher(source_dir: Path, output_dir: Path, template_dirs: Optional[List[Path]] = None, plugin_manager: Optional[PluginManager] = None, ignore_patterns: Optional[List[str]] = None, default_griffe_config: Optional[Dict[str, Any]] = None)
Watches for changes in documentation source files.
Parameters:
-
(source_dir¶Path) –Directory to watch for changes
-
(output_dir¶Path) –Output directory for generated files
-
(template_dirs¶Optional[List[Path]], default:None) –Additional template directories
-
(plugin_manager¶Optional[PluginManager], default:None) –Optional plugin manager for processors/filters
-
(ignore_patterns¶Optional[List[str]], default:None) –Glob patterns to ignore
-
(default_griffe_config¶Optional[Dict[str, Any]], default:None) –Default Griffe config to merge with frontmatter
Methods:
GriffonnerEventHandler
¶
GriffonnerEventHandler(source_dir: Path, output_dir: Path, template_dirs: Optional[List[Path]] = None, plugin_manager: Optional[PluginManager] = None, ignore_patterns: Optional[List[str]] = None, default_griffe_config: Optional[Dict[str, Any]] = None)
Bases: FileSystemEventHandler
Handles file system events for Griffonner.
Parameters:
-
(source_dir¶Path) –Directory to watch for changes
-
(output_dir¶Path) –Output directory for generated files
-
(template_dirs¶Optional[List[Path]], default:None) –Additional template directories
-
(plugin_manager¶Optional[PluginManager], default:None) –Optional plugin manager for processors/filters
-
(ignore_patterns¶Optional[List[str]], default:None) –Glob patterns to ignore
-
(default_griffe_config¶Optional[Dict[str, Any]], default:None) –Default Griffe config to merge with frontmatter
Methods:
-
on_created–Handle file creation events.
-
on_modified–Handle file modification events.