@@ -163,27 +163,41 @@ fn fmt_param(param: &Entity, builder: &Builder) -> Html {
163163}
164164
165165fn fmt_template_args ( entity : & Entity , _builder : & Builder ) -> Option < Html > {
166- let template_children = if entity. get_kind ( ) == EntityKind :: FunctionTemplate {
167- entity. get_children ( ) . into_iter ( ) . filter ( |e| e. get_kind ( ) == EntityKind :: TemplateTypeParameter ) . collect ( )
168- } else {
169- entity. get_template ( ) ?. get_children ( )
170- } ;
171- Some ( HtmlList :: new (
172- template_children
173- . into_iter ( )
174- . map ( |e|
175- HtmlText :: new ( e. get_name ( ) . unwrap_or ( "_" . to_string ( ) ) ) . into ( )
176- )
177- . collect :: < Vec < _ > > ( )
178- . insert_between ( || {
179- HtmlElement :: new ( "span" )
180- . with_class ( "comma" )
181- . with_class ( "space-after" )
182- . with_child ( HtmlText :: new ( "," ) )
183- . into ( )
184- } )
185- . surround ( HtmlText :: new ( "<" ) . into ( ) , HtmlText :: new ( ">" ) . into ( ) ) ,
186- ) . into ( ) )
166+ let template_children: Vec < Entity > = entity
167+ . get_children ( )
168+ . into_iter ( )
169+ . filter ( |e| e. get_kind ( ) == EntityKind :: TemplateTypeParameter )
170+ . collect ( ) ;
171+ if template_children. is_empty ( ) {
172+ return None ;
173+ }
174+ if entity. get_name ( ) . unwrap_or_default ( ) . contains ( "add" ) {
175+ let first = template_children. first ( ) . unwrap ( ) ;
176+ println ! ( "{:?}" , first) ;
177+ let source = first. extract_source_string_cleaned ( ) . unwrap ( ) ;
178+ println ! ( "{:?}" , source) ;
179+ }
180+ Some ( HtmlElement :: new ( "span" )
181+ . with_class ( "template-params" )
182+ . with_child ( Html :: span ( & [ "keyword" , "space-after" ] , "template" ) )
183+ . with_children (
184+ template_children
185+ . into_iter ( )
186+ . map ( |e|
187+ HtmlText :: new ( e. extract_source_string_cleaned ( ) . or_else ( || e. get_name ( ) . map ( |x| format ! ( "typename {x}" ) ) ) . unwrap_or ( "_" . into ( ) ) ) . into ( )
188+ )
189+ . collect :: < Vec < _ > > ( )
190+ . insert_between ( || {
191+ HtmlElement :: new ( "span" )
192+ . with_class ( "comma" )
193+ . with_class ( "space-after" )
194+ . with_child ( HtmlText :: new ( "," ) )
195+ . into ( )
196+ } )
197+ . surround ( HtmlText :: new ( "<" ) . into ( ) , HtmlText :: new ( ">" ) . into ( ) ) ,
198+ )
199+ . into ( )
200+ )
187201}
188202
189203pub fn fmt_field ( field : & Entity , builder : & Builder ) -> Html {
@@ -213,46 +227,49 @@ pub fn fmt_fun_decl(fun: &Entity, builder: &Builder) -> Html {
213227 . with_child (
214228 HtmlElement :: new ( "summary" )
215229 . with_classes ( & [ "entity" , "fun" ] )
216- . with_child_opt (
217- fun. is_static_method ( )
218- . then_some ( Html :: span ( & [ "keyword" , "space-after" ] , "static" ) ) ,
219- )
220- . with_child_opt (
221- fun. is_virtual_method ( )
222- . then_some ( Html :: span ( & [ "keyword" , "space-after" ] , "virtual" ) ) ,
223- )
224- . with_child_opt ( fun. get_result_type ( ) . map ( |t| fmt_type ( & t, builder) ) )
225- . with_child ( Html :: span (
226- & [ "name" , "space-before" ] ,
227- & fun. get_name ( ) . unwrap_or ( "_anon" . into ( ) ) ,
228- ) )
229230 . with_child_opt ( fmt_template_args ( fun, builder) )
230- . with_child (
231- HtmlElement :: new ( "span" ) . with_class ( "params" ) . with_children (
232- fun. get_function_arguments ( )
233- . map ( |args| {
234- args. iter ( )
235- . map ( |arg| fmt_param ( arg, builder) )
236- . collect :: < Vec < _ > > ( )
237- } )
238- . unwrap_or ( Vec :: new ( ) )
239- . insert_between ( || Html :: span ( & [ "comma" , "space-after" ] , "," ) )
240- . surround ( HtmlText :: new ( "(" ) . into ( ) , HtmlText :: new ( ")" ) . into ( ) ) ,
241- ) ,
242- )
243- . with_child_opt (
244- fun. is_const_method ( )
245- . then_some ( Html :: span ( & [ "keyword" , "space-before" ] , "const" ) ) ,
231+ . with_child ( HtmlElement :: new ( "span" )
232+ . with_class ( "function-signature" )
233+ . with_child_opt (
234+ fun. is_static_method ( )
235+ . then_some ( Html :: span ( & [ "keyword" , "space-after" ] , "static" ) ) ,
236+ )
237+ . with_child_opt (
238+ fun. is_virtual_method ( )
239+ . then_some ( Html :: span ( & [ "keyword" , "space-after" ] , "virtual" ) ) ,
240+ )
241+ . with_child_opt ( fun. get_result_type ( ) . map ( |t| fmt_type ( & t, builder) ) )
242+ . with_child ( Html :: span (
243+ & [ "name" , "space-before" ] ,
244+ & fun. get_name ( ) . unwrap_or ( "_anon" . into ( ) ) ,
245+ ) )
246+ . with_child (
247+ HtmlElement :: new ( "span" ) . with_class ( "params" ) . with_children (
248+ fun. get_function_arguments ( )
249+ . map ( |args| {
250+ args. iter ( )
251+ . map ( |arg| fmt_param ( arg, builder) )
252+ . collect :: < Vec < _ > > ( )
253+ } )
254+ . unwrap_or ( Vec :: new ( ) )
255+ . insert_between ( || Html :: span ( & [ "comma" , "space-after" ] , "," ) )
256+ . surround ( HtmlText :: new ( "(" ) . into ( ) , HtmlText :: new ( ")" ) . into ( ) ) ,
257+ ) ,
258+ )
259+ . with_child_opt (
260+ fun. is_const_method ( )
261+ . then_some ( Html :: span ( & [ "keyword" , "space-before" ] , "const" ) ) ,
262+ )
263+ . with_child_opt (
264+ fun. is_pure_virtual_method ( ) . then_some :: < Html > (
265+ HtmlList :: new ( vec ! [
266+ Html :: span( & [ "space-before" ] , "=" ) ,
267+ Html :: span( & [ "space-before" , "literal" ] , "0" ) ,
268+ ] )
269+ . into ( ) ,
270+ )
271+ )
246272 )
247- . with_child_opt (
248- fun. is_pure_virtual_method ( ) . then_some :: < Html > (
249- HtmlList :: new ( vec ! [
250- Html :: span( & [ "space-before" ] , "=" ) ,
251- Html :: span( & [ "space-before" , "literal" ] , "0" ) ,
252- ] )
253- . into ( ) ,
254- ) ,
255- ) ,
256273 )
257274 . with_child (
258275 HtmlElement :: new ( "div" ) . with_child (
0 commit comments