docs: Add comprehensive documentation for modes, services, and plugins
Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use super::{MetaPlugin, MetaPluginType, process_metadata_outputs};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
/// Meta plugin that extracts environment variables prefixed with KEEP_META_ as metadata.
|
||||
pub struct EnvMetaPlugin {
|
||||
is_finalized: bool,
|
||||
outputs: std::collections::HashMap<String, serde_yaml::Value>,
|
||||
@@ -10,10 +11,12 @@ pub struct EnvMetaPlugin {
|
||||
impl EnvMetaPlugin {
|
||||
/// Creates a new `EnvMetaPlugin` instance.
|
||||
///
|
||||
/// Collects environment variables starting with KEEP_META_ and sets up default output mappings.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `_options` - Optional configuration options for the plugin (unused in this implementation).
|
||||
/// * `outputs` - Optional output mappings for metadata.
|
||||
/// * `outputs` - Optional output mappings for metadata (overrides defaults).
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
@@ -83,6 +86,8 @@ impl MetaPlugin for EnvMetaPlugin {
|
||||
|
||||
/// Initializes the plugin, processing environment variables.
|
||||
///
|
||||
/// Processes all KEEP_META_* variables and generates metadata using output mappings.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A `MetaPluginResponse` with environment metadata and finalized state set to `true`.
|
||||
@@ -118,13 +123,15 @@ impl MetaPlugin for EnvMetaPlugin {
|
||||
|
||||
/// Updates the plugin with new data (unused in this implementation).
|
||||
///
|
||||
/// This plugin does not process streaming data; returns empty response.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `_data` - The data chunk (unused).
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A `MetaPluginResponse` with empty metadata and finalized state.
|
||||
/// A `MetaPluginResponse` with empty metadata and current finalized state.
|
||||
fn update(&mut self, _data: &[u8]) -> crate::meta_plugin::MetaPluginResponse {
|
||||
// If already finalized, don't process more data
|
||||
if self.is_finalized {
|
||||
@@ -142,6 +149,8 @@ impl MetaPlugin for EnvMetaPlugin {
|
||||
|
||||
/// Finalizes the plugin, calling initialize if not already done.
|
||||
///
|
||||
/// Ensures environment metadata is processed if not previously initialized.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A `MetaPluginResponse` with environment metadata if not finalized, or empty if already done.
|
||||
@@ -179,7 +188,7 @@ impl MetaPlugin for EnvMetaPlugin {
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A vector of environment variable names.
|
||||
/// A vector of environment variable names (stripped of KEEP_META_ prefix).
|
||||
fn default_outputs(&self) -> Vec<String> {
|
||||
self.env_vars.iter()
|
||||
.map(|(name, _)| name.clone())
|
||||
@@ -188,6 +197,8 @@ impl MetaPlugin for EnvMetaPlugin {
|
||||
|
||||
/// Returns a reference to the options mapping (empty for this plugin).
|
||||
///
|
||||
/// This plugin has no configurable options.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// An empty `HashMap`.
|
||||
@@ -209,7 +220,7 @@ impl MetaPlugin for EnvMetaPlugin {
|
||||
}
|
||||
use crate::meta_plugin::register_meta_plugin;
|
||||
|
||||
// Register the plugin at module initialization time
|
||||
/// Registers the EnvMetaPlugin with the global registry at module initialization.
|
||||
#[ctor::ctor]
|
||||
fn register_env_plugin() {
|
||||
register_meta_plugin(MetaPluginType::Env, |options, outputs| {
|
||||
|
||||
Reference in New Issue
Block a user