@@ -48,16 +48,16 @@ pub struct StructDocs {
4848/// All fields are XML parts, escaped where necessary.
4949#[ derive( Default , Copy , Clone , Debug ) ]
5050pub struct InherentImplDocs {
51- pub methods : & ' static str ,
52- pub signals_block : & ' static str ,
53- pub constants_block : & ' static str ,
51+ pub methods : Vec < & ' static str > ,
52+ pub signals : Vec < & ' static str > ,
53+ pub constants : Vec < & ' static str > ,
5454}
5555
5656#[ derive( Default ) ]
5757struct DocPieces {
5858 definition : StructDocs ,
5959 inherent : InherentImplDocs ,
60- virtual_methods : & ' static str ,
60+ virtual_methods : Vec < & ' static str > ,
6161}
6262
6363/// This function scours the registered plugins to find their documentation pieces,
@@ -79,51 +79,65 @@ pub fn gather_xml_docs() -> impl Iterator<Item = String> {
7979 crate :: private:: iterate_plugins ( |x| {
8080 let class_name = x. class_name ;
8181
82- match x. item {
82+ match & x. item {
8383 PluginItem :: InherentImpl ( InherentImpl { docs, .. } ) => {
84- map. entry ( class_name) . or_default ( ) . inherent = docs
84+ map. entry ( class_name) . or_default ( ) . inherent = docs. clone ( ) ;
8585 }
86-
8786 PluginItem :: ITraitImpl ( ITraitImpl {
8887 virtual_method_docs,
8988 ..
90- } ) => map. entry ( class_name) . or_default ( ) . virtual_methods = virtual_method_docs,
89+ } ) => map
90+ . entry ( class_name)
91+ . or_default ( )
92+ . virtual_methods
93+ . push ( virtual_method_docs) ,
9194
9295 PluginItem :: Struct ( Struct { docs, .. } ) => {
93- map. entry ( class_name) . or_default ( ) . definition = docs
96+ map. entry ( class_name) . or_default ( ) . definition = * docs;
9497 }
9598
9699 _ => ( ) ,
97100 }
98101 } ) ;
99102
100103 map. into_iter ( ) . map ( |( class, pieces) | {
101- let StructDocs {
102- base,
103- description,
104- experimental,
105- deprecated,
106- members,
107- } = pieces. definition ;
108-
109- let InherentImplDocs {
110- methods,
111- signals_block,
112- constants_block,
113- } = pieces. inherent ;
114-
115- let virtual_methods = pieces. virtual_methods ;
116- let methods_block = ( virtual_methods. is_empty ( ) && methods. is_empty ( ) )
117- . then ( String :: new)
118- . unwrap_or_else ( || format ! ( "<methods>{methods}{virtual_methods}</methods>" ) ) ;
119-
120- let ( brief, description) = match description
121- . split_once ( "[br]" ) {
122- Some ( ( brief, description) ) => ( brief, description. trim_start_matches ( "[br]" ) ) ,
123- None => ( description, "" ) ,
124- } ;
125-
126- format ! ( r#"<?xml version="1.0" encoding="UTF-8"?>
104+ let StructDocs {
105+ base,
106+ description,
107+ experimental,
108+ deprecated,
109+ members,
110+ } = pieces. definition ;
111+
112+ let virtual_methods = pieces. virtual_methods ;
113+
114+ let mut method_docs = String :: from_iter ( pieces. inherent . methods ) ;
115+ let signal_docs = String :: from_iter ( pieces. inherent . signals ) ;
116+ let constant_docs = String :: from_iter ( pieces. inherent . constants ) ;
117+
118+ method_docs. extend ( virtual_methods) ;
119+ let methods_block = if method_docs. is_empty ( ) {
120+ String :: new ( )
121+ } else {
122+ format ! ( "<methods>{method_docs}</methods>" )
123+ } ;
124+ let signals_block = if signal_docs. is_empty ( ) {
125+ String :: new ( )
126+ } else {
127+ format ! ( "<signals>{signal_docs}</signals>" )
128+ } ;
129+ let constants_block = if constant_docs. is_empty ( ) {
130+ String :: new ( )
131+ } else {
132+ format ! ( "<constants>{constant_docs}</constants>" )
133+ } ;
134+ let ( brief, description) = match description
135+ . split_once ( "[br]" ) {
136+ Some ( ( brief, description) ) => ( brief, description. trim_start_matches ( "[br]" ) ) ,
137+ None => ( description, "" ) ,
138+ } ;
139+
140+ format ! ( r#"<?xml version="1.0" encoding="UTF-8"?>
127141<class name="{class}" inherits="{base}"{deprecated}{experimental} xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
128142<brief_description>{brief}</brief_description>
129143<description>{description}</description>
@@ -132,8 +146,8 @@ pub fn gather_xml_docs() -> impl Iterator<Item = String> {
132146{signals_block}
133147<members>{members}</members>
134148</class>"# )
135- } ,
136- )
149+ } ,
150+ )
137151}
138152
139153/// # Safety
0 commit comments