Skip to content

Commit 04440ed

Browse files
authored
feat(utils): generate table markdown of permissions (#9019)
* generate table * Create permission-table.md
1 parent 3657ad8 commit 04440ed

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎.changes/permission-table.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": patch:enhance
3+
---
4+
5+
Changed plugin markdown docs generation to table format.

‎core/tauri-utils/src/acl/build.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,33 +235,33 @@ pub fn generate_schema<P: AsRef<Path>>(
235235

236236
/// Generate a markdown documentation page containing the list of permissions of the plugin.
237237
pub fn generate_docs(permissions: &[PermissionFile], out_dir: &Path) -> Result<(), Error> {
238-
let mut docs = "# Permissions\n\n".to_string();
238+
let mut docs = "| Permission | Description |\n|------|-----|\n".to_string();
239239

240240
fn docs_from(id: &str, description: Option<&str>) -> String {
241-
let mut docs = format!("## {id}");
241+
let mut docs = format!("|`{id}`");
242242
if let Some(d) = description {
243-
docs.push_str(&format!("\n\n{d}"));
243+
docs.push_str(&format!("|{d}|"));
244244
}
245245
docs
246246
}
247247

248248
for permission in permissions {
249249
for set in &permission.set {
250250
docs.push_str(&docs_from(&set.identifier, Some(&set.description)));
251-
docs.push_str("\n\n");
251+
docs.push('\n');
252252
}
253253

254254
if let Some(default) = &permission.default {
255255
docs.push_str(&docs_from("default", default.description.as_deref()));
256-
docs.push_str("\n\n");
256+
docs.push('\n');
257257
}
258258

259259
for permission in &permission.permission {
260260
docs.push_str(&docs_from(
261261
&permission.identifier,
262262
permission.description.as_deref(),
263263
));
264-
docs.push_str("\n\n");
264+
docs.push('\n');
265265
}
266266
}
267267

0 commit comments

Comments
 (0)