mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-03 10:14:40 +00:00
implement dump_section_config
This commit is contained in:
parent
67c7699b23
commit
133209c14a
@ -4,9 +4,13 @@ use anyhow::{bail, Error};
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
use crate::api::router::ReturnType;
|
||||
use crate::api::schema::*;
|
||||
use crate::api::{ApiHandler, ApiMethod};
|
||||
use crate::api::{
|
||||
ApiHandler,
|
||||
ApiMethod,
|
||||
router::ReturnType,
|
||||
section_config::SectionConfig,
|
||||
schema::*,
|
||||
};
|
||||
|
||||
/// Enumerate different styles to display parameters/properties.
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
@ -514,3 +518,30 @@ pub fn dump_api(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Generate ReST Documentaion for ``SectionConfig``
|
||||
pub fn dump_section_config(config: &SectionConfig) -> String {
|
||||
|
||||
let mut res = String::new();
|
||||
|
||||
let plugin_count = config.plugins().len();
|
||||
|
||||
for plugin in config.plugins().values() {
|
||||
|
||||
let name = plugin.type_name();
|
||||
let properties = plugin.properties();
|
||||
let skip = match plugin.id_property() {
|
||||
Some(id) => vec![id],
|
||||
None => Vec::new(),
|
||||
};
|
||||
|
||||
if plugin_count > 1 {
|
||||
let description = wrap_text("", "", &properties.description, 80);
|
||||
res.push_str(&format!("\n**Section type** \'``{}``\': {}\n\n", name, description));
|
||||
}
|
||||
|
||||
res.push_str(&dump_properties(properties, "", ParameterDisplayStyle::Config, &skip));
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user