@@ -326,11 +326,9 @@ pub fn generate_docs(
326326 out_dir : & Path ,
327327 plugin_identifier : & str ,
328328) -> Result < ( ) , Error > {
329+ let mut default_permission = "" . to_owned ( ) ;
329330 let mut permission_table = "" . to_string ( ) ;
330331
331- let mut default_permission = "## Default Permission\n \n " . to_string ( ) ;
332- let mut contains_default = false ;
333-
334332 fn docs_from ( id : & str , description : Option < & str > , plugin_identifier : & str ) -> String {
335333 let mut docs = format ! ( "\n <tr>\n <td>\n \n `{plugin_identifier}:{id}`\n \n </td>\n " ) ;
336334 if let Some ( d) = description {
@@ -351,15 +349,16 @@ pub fn generate_docs(
351349 }
352350
353351 if let Some ( default) = & permission. default {
354- contains_default = true ;
355-
356- default_permission. push_str ( default. description . as_deref ( ) . unwrap_or_default ( ) ) ;
357- default_permission. push ( '\n' ) ;
352+ default_permission. push_str ( "## Default Permission\n \n " ) ;
353+ default_permission. push_str ( default. description . as_deref ( ) . unwrap_or_default ( ) . trim ( ) ) ;
358354 default_permission. push ( '\n' ) ;
359- default_permission. push_str ( "#### This default permission set includes the following:\n " ) ;
360355 default_permission. push ( '\n' ) ;
361- for permission in & default. permissions {
362- default_permission. push_str ( & format ! ( "- `{permission}`\n " ) ) ;
356+ if !default. permissions . is_empty ( ) {
357+ default_permission. push_str ( "#### This default permission set includes the following:\n \n " ) ;
358+ for permission in & default. permissions {
359+ default_permission. push_str ( & format ! ( "- `{permission}`\n " ) ) ;
360+ }
361+ default_permission. push ( '\n' ) ;
363362 }
364363 }
365364
@@ -373,12 +372,7 @@ pub fn generate_docs(
373372 }
374373 }
375374
376- if !contains_default {
377- default_permission = "" . to_string ( ) ;
378- }
379-
380- let docs =
381- format ! ( "{default_permission}\n {PERMISSION_TABLE_HEADER}\n {permission_table}</table>\n " ) ;
375+ let docs = format ! ( "{default_permission}{PERMISSION_TABLE_HEADER}\n {permission_table}</table>\n " ) ;
382376
383377 let reference_path = out_dir. join ( PERMISSION_DOCS_FILE_NAME ) ;
384378 write_if_changed ( & reference_path, docs) . map_err ( |e| Error :: WriteFile ( e, reference_path) ) ?;
0 commit comments