Contents
Plugin Manager API
The PluginManager class in Uchū Docs namespace is responsible for managing plugin registration and execution throughout the documentation lifecycle.
Plugin Manager Diagram
classDiagram
class PluginManager {
- PluginInterface[] plugins
+ registerPlugin(PluginInterface): self
+ getPluginsByType(string): PluginInterface[]
+ modifyContent(string, string): string
+ executePreRenderPlugins(string): void
+ executePostRenderPlugins(string, string): void
}
class PluginInterface {
+ getPriority(): int
}
class ContentModifierPluginInterface {
+ modifyContent(string, string): string
}
class PreRenderPluginInterface {
+ preRender(string): void
}
class PostRenderPluginInterface {
+ postRender(string, string): void
}
PluginManager --> PluginInterface : uses
PluginManager --> ContentModifierPluginInterface : filters
PluginManager --> PreRenderPluginInterface : filters
PluginManager --> PostRenderPluginInterface : filters
ContentModifierPluginInterface ..|> PluginInterface
PreRenderPluginInterface ..|> PluginInterface
PostRenderPluginInterface ..|> PluginInterface
Interfaces Used
PluginInterface: Base interface for all plugins, must includegetPriority(): int.ContentModifierPluginInterface: Modifies the content of a documentation page.PreRenderPluginInterface: Executes logic before a page is rendered.PostRenderPluginInterface: Executes logic after a page is rendered.
Constructor
__construct()
Initializes an empty plugin manager.
Public Methods
registerPlugin
registerPlugin(PluginInterface $plugin): self
Registers a new plugin and sorts all plugins by their priority.
plugin: Instance of a class implementingPluginInterface.
getPluginsByType
getPluginsByType(string $interfaceType): array
Filters and returns plugins matching the specified interface type.
interfaceType: Fully qualified interface name.
modifyContent
modifyContent(string $content, string $pageName): string
Passes content through all registered content modifier plugins.
content: Original Markdown content.pageName: Page name used for context.
executePreRenderPlugins
executePreRenderPlugins(string $pageName): void
Runs all pre-render plugin hooks.
pageName: Name of the page to be rendered.
executePostRenderPlugins
executePostRenderPlugins(string $pageName, string $renderedContent): void
Runs all post-render plugin hooks.
pageName: Name of the rendered page.renderedContent: HTML output after rendering.
Example Usage
$pluginManager = new PluginManager();
$pluginManager->registerPlugin(new MyCustomPlugin());
$pluginManager->executePreRenderPlugins('getting_started');
$content = $pluginManager->modifyContent($markdownContent, 'getting_started');
$pluginManager->executePostRenderPlugins('getting_started', $htmlContent);