@@ -48,16 +48,16 @@ pub struct StructDocs {
48
48
/// All fields are XML parts, escaped where necessary.
49
49
#[ derive( Default , Copy , Clone , Debug ) ]
50
50
pub 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 > ,
54
54
}
55
55
56
56
#[ derive( Default ) ]
57
57
struct DocPieces {
58
58
definition : StructDocs ,
59
59
inherent : InherentImplDocs ,
60
- virtual_methods : & ' static str ,
60
+ virtual_methods : Vec < & ' static str > ,
61
61
}
62
62
63
63
/// This function scours the registered plugins to find their documentation pieces,
@@ -79,51 +79,65 @@ pub fn gather_xml_docs() -> impl Iterator<Item = String> {
79
79
crate :: private:: iterate_plugins ( |x| {
80
80
let class_name = x. class_name ;
81
81
82
- match x. item {
82
+ match & x. item {
83
83
PluginItem :: InherentImpl ( InherentImpl { docs, .. } ) => {
84
- map. entry ( class_name) . or_default ( ) . inherent = docs
84
+ map. entry ( class_name) . or_default ( ) . inherent = docs. clone ( ) ;
85
85
}
86
-
87
86
PluginItem :: ITraitImpl ( ITraitImpl {
88
87
virtual_method_docs,
89
88
..
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) ,
91
94
92
95
PluginItem :: Struct ( Struct { docs, .. } ) => {
93
- map. entry ( class_name) . or_default ( ) . definition = docs
96
+ map. entry ( class_name) . or_default ( ) . definition = * docs;
94
97
}
95
98
96
99
_ => ( ) ,
97
100
}
98
101
} ) ;
99
102
100
103
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"?>
127
141
<class name="{class}" inherits="{base}"{deprecated}{experimental} xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
128
142
<brief_description>{brief}</brief_description>
129
143
<description>{description}</description>
@@ -132,8 +146,8 @@ pub fn gather_xml_docs() -> impl Iterator<Item = String> {
132
146
{signals_block}
133
147
<members>{members}</members>
134
148
</class>"# )
135
- } ,
136
- )
149
+ } ,
150
+ )
137
151
}
138
152
139
153
/// # Safety
0 commit comments