From 04440edce870f9d06055616034941d79443d5a87 Mon Sep 17 00:00:00 2001 From: Vitor Ayres Date: Wed, 28 Feb 2024 13:15:44 -0300 Subject: [PATCH] feat(utils): generate table markdown of permissions (#9019) * generate table * Create permission-table.md --- .changes/permission-table.md | 5 +++++ core/tauri-utils/src/acl/build.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changes/permission-table.md diff --git a/.changes/permission-table.md b/.changes/permission-table.md new file mode 100644 index 000000000..d31dadd9e --- /dev/null +++ b/.changes/permission-table.md @@ -0,0 +1,5 @@ +--- +"tauri-utils": patch:enhance +--- + +Changed plugin markdown docs generation to table format. diff --git a/core/tauri-utils/src/acl/build.rs b/core/tauri-utils/src/acl/build.rs index 3d8d11fd6..678a4ac44 100644 --- a/core/tauri-utils/src/acl/build.rs +++ b/core/tauri-utils/src/acl/build.rs @@ -235,12 +235,12 @@ pub fn generate_schema>( /// Generate a markdown documentation page containing the list of permissions of the plugin. pub fn generate_docs(permissions: &[PermissionFile], out_dir: &Path) -> Result<(), Error> { - let mut docs = "# Permissions\n\n".to_string(); + let mut docs = "| Permission | Description |\n|------|-----|\n".to_string(); fn docs_from(id: &str, description: Option<&str>) -> String { - let mut docs = format!("## {id}"); + let mut docs = format!("|`{id}`"); if let Some(d) = description { - docs.push_str(&format!("\n\n{d}")); + docs.push_str(&format!("|{d}|")); } docs } @@ -248,12 +248,12 @@ pub fn generate_docs(permissions: &[PermissionFile], out_dir: &Path) -> Result<( for permission in permissions { for set in &permission.set { docs.push_str(&docs_from(&set.identifier, Some(&set.description))); - docs.push_str("\n\n"); + docs.push('\n'); } if let Some(default) = &permission.default { docs.push_str(&docs_from("default", default.description.as_deref())); - docs.push_str("\n\n"); + docs.push('\n'); } for permission in &permission.permission { @@ -261,7 +261,7 @@ pub fn generate_docs(permissions: &[PermissionFile], out_dir: &Path) -> Result<( &permission.identifier, permission.description.as_deref(), )); - docs.push_str("\n\n"); + docs.push('\n'); } }