serde_doc/generators/
mod.rs1pub mod markdown;
2pub mod jsonschema;
3use anyhow::{bail, Result};
4
5use crate::Context;
6
7pub struct GeneratorConfig {
8 pub output: Option<String>,
9 pub structs: Option<Vec<String>>,
10 pub files: Option<Vec<String>>,
11
12}
13pub trait Generator {
14 fn generate(&self, ctx: &Context, config:&GeneratorConfig) -> Result<()>;
15}
16
17pub fn get_generator(name: &str) -> Result<Box<dyn Generator>> {
18 match name {
19 "markdown" => Ok(Box::new(markdown::MarkdownGenerator::new())),
20 "jsonschema" => Ok(Box::new(jsonschema::JsonSchemaGenerator::new())),
21 _ => bail!("Unknown generator: {}", name),
22 }
23}