mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-08-17 03:40:23 +03:00
feat(utils): generate table markdown of permissions (#9019)
* generate table * Create permission-table.md
This commit is contained in:
parent
3657ad82f8
commit
04440edce8
5
.changes/permission-table.md
Normal file
5
.changes/permission-table.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"tauri-utils": patch:enhance
|
||||||
|
---
|
||||||
|
|
||||||
|
Changed plugin markdown docs generation to table format.
|
@ -235,12 +235,12 @@ pub fn generate_schema<P: AsRef<Path>>(
|
|||||||
|
|
||||||
/// Generate a markdown documentation page containing the list of permissions of the plugin.
|
/// Generate a markdown documentation page containing the list of permissions of the plugin.
|
||||||
pub fn generate_docs(permissions: &[PermissionFile], out_dir: &Path) -> Result<(), Error> {
|
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 {
|
fn docs_from(id: &str, description: Option<&str>) -> String {
|
||||||
let mut docs = format!("## {id}");
|
let mut docs = format!("|`{id}`");
|
||||||
if let Some(d) = description {
|
if let Some(d) = description {
|
||||||
docs.push_str(&format!("\n\n{d}"));
|
docs.push_str(&format!("|{d}|"));
|
||||||
}
|
}
|
||||||
docs
|
docs
|
||||||
}
|
}
|
||||||
@ -248,12 +248,12 @@ pub fn generate_docs(permissions: &[PermissionFile], out_dir: &Path) -> Result<(
|
|||||||
for permission in permissions {
|
for permission in permissions {
|
||||||
for set in &permission.set {
|
for set in &permission.set {
|
||||||
docs.push_str(&docs_from(&set.identifier, Some(&set.description)));
|
docs.push_str(&docs_from(&set.identifier, Some(&set.description)));
|
||||||
docs.push_str("\n\n");
|
docs.push('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(default) = &permission.default {
|
if let Some(default) = &permission.default {
|
||||||
docs.push_str(&docs_from("default", default.description.as_deref()));
|
docs.push_str(&docs_from("default", default.description.as_deref()));
|
||||||
docs.push_str("\n\n");
|
docs.push('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
for permission in &permission.permission {
|
for permission in &permission.permission {
|
||||||
@ -261,7 +261,7 @@ pub fn generate_docs(permissions: &[PermissionFile], out_dir: &Path) -> Result<(
|
|||||||
&permission.identifier,
|
&permission.identifier,
|
||||||
permission.description.as_deref(),
|
permission.description.as_deref(),
|
||||||
));
|
));
|
||||||
docs.push_str("\n\n");
|
docs.push('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user