src/doc: clean signature HTML output with `html_signature` and `html_short_signature`
[nit.git] / src / doc / html_templates / html_model.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # HTML templates for Nit model MEntities.
16 module html_model
17
18 import doc_base
19 import doc_down
20 import html_components
21 import html::bootstrap
22 import ordered_tree
23
24 redef class Location
25 # Github url based on this location
26 fun github(gitdir: String): String do
27 var base_dir = getcwd.join_path(gitdir).simplify_path
28 var file_loc = getcwd.join_path(file.filename).simplify_path
29 var gith_loc = file_loc.substring(base_dir.length + 1, file_loc.length)
30 return "{gith_loc}:{line_start},{column_start}--{line_end},{column_end}"
31 end
32 end
33
34 redef class MEntity
35 # ID used as a HTML unique ID and in file names.
36 #
37 # **Must** match the following (POSIX ERE) regular expression:
38 #
39 # ~~~POSIX ERE
40 # ^[A-Za-z_][A-Za-z0-9._-]*$
41 # ~~~
42 #
43 # That way, the ID is always a valid URI component and a valid XML name.
44 fun nitdoc_id: String is abstract
45
46 # URL of this entity’s Nitdoc page.
47 fun nitdoc_url: String is abstract
48
49 # Returns the mentity name without short signature.
50 #
51 # * MProject: `foo`
52 # * MGroup: `foo`
53 # * MModule: `foo`
54 # * MClass: `Foo[E]`
55 # * MClassDef: `Foo[E]`
56 # * MProperty: `foo(e)`
57 # * MPropdef: `foo(e)`
58 var html_name: String is lazy do return name.html_escape
59
60 # Returns a Link to the mentity `html_url`.
61 #
62 # Example: `<a href="html_url" title="mdoc.short_comment">html_short_name</a>
63 var html_link: Link is lazy do
64 var tpl = new Link(nitdoc_url, html_name)
65 var mdoc = mdoc_or_fallback
66 if mdoc != null then
67 tpl.title = mdoc.short_comment
68 end
69 return tpl
70 end
71
72 # Returns a Link to the mentity `nitdoc_id`.
73 #
74 # Example: `<a href="#nitdoc_id" title="mdoc.short_comment">html_short_name</a>
75 fun html_link_to_anchor: Link do
76 var tpl = new Link("#{nitdoc_id}", html_name)
77 var mdoc = mdoc_or_fallback
78 if mdoc != null then
79 tpl.title = mdoc.short_comment
80 end
81 return tpl
82 end
83
84 # Returns the list of keyword used in `self` declaration.
85 fun html_modifiers: Array[String] is abstract
86
87 # Returns the complete MEntity declaration decorated with HTML.
88 #
89 # * MProject: `project foo`
90 # * MGroup: `group foo`
91 # * MModule: `module foo`
92 # * MClass: `private abstract class Foo[E: Object]`
93 # * MClassDef: `redef class Foo[E]`
94 # * MProperty: `private fun foo(e: Object): Int`
95 # * MPropdef: `redef fun foo(e)`
96 fun html_declaration: Template do
97 var tpl = new Template
98 tpl.add "<span>"
99 tpl.add html_modifiers.join(" ")
100 tpl.add " "
101 tpl.add html_link
102 tpl.add "</span>"
103 return tpl
104 end
105
106 # Returns `self` namespace decorated with HTML links.
107 #
108 # * MProject: `mproject`
109 # * MGroup: `mproject(::group)`
110 # * MModule: `mgroup::mmodule`
111 # * MClass: `mproject::mclass`
112 # * MClassDef: `mmodule::mclassdef`
113 # * MProperty: `mclass::mprop`
114 # * MPropdef: `mclassdef:mpropdef`
115 fun html_namespace: Template is abstract
116
117 # A template article that briefly describe the entity
118 fun tpl_short_article: TplArticle do
119 var tpl = tpl_article
120 var mdoc = mdoc_or_fallback
121 if mdoc != null then
122 tpl.content = mdoc.tpl_short_comment
123 end
124 return tpl
125 end
126
127 # A template article that describe the entity
128 fun tpl_article: TplArticle do
129 var tpl = new TplArticle.with_title(nitdoc_id, tpl_title)
130 tpl.title_classes.add "signature"
131 tpl.subtitle = html_namespace
132 tpl.summary_title = html_name
133 return tpl
134 end
135
136 # A template definition of the mentity
137 # include name, sysnopsys, comment and namespace
138 fun tpl_definition: TplDefinition is abstract
139
140 # A li element that can go in a list
141 fun tpl_list_item: TplListItem do
142 var lnk = new Template
143 lnk.add new TplLabel.with_classes(tpl_css_classes)
144 lnk.add html_link
145 var mdoc = mdoc_or_fallback
146 if mdoc != null then
147 lnk.add ": "
148 lnk.add mdoc.tpl_short_comment
149 end
150 return new TplListItem.with_content(lnk)
151 end
152
153 var tpl_css_classes = new Array[String]
154
155 # Box title for this mentity
156 fun tpl_title: Template do
157 var title = new Template
158 title.add tpl_icon
159 title.add html_namespace
160 return title
161 end
162
163 # Icon that will be displayed before the title
164 fun tpl_icon: TplIcon do
165 var icon = new TplIcon.with_icon("tag")
166 icon.css_classes.add_all(tpl_css_classes)
167 return icon
168 end
169 end
170
171 redef class MConcern
172 # Return a li element for `self` that can be displayed in a concern list
173 private fun tpl_concern_item: TplListItem do
174 var lnk = new Template
175 lnk.add html_link_to_anchor
176 var mdoc = mdoc_or_fallback
177 if mdoc != null then
178 lnk.add ": "
179 lnk.add mdoc.tpl_short_comment
180 end
181 return new TplListItem.with_content(lnk)
182 end
183 end
184
185 redef class MProject
186 redef var nitdoc_id = name.to_cmangle is lazy
187 redef fun nitdoc_url do return root.nitdoc_url
188 redef var html_modifiers = ["project"]
189 redef fun html_namespace do return html_link
190
191 redef fun tpl_definition do
192 var tpl = new TplDefinition
193 var mdoc = mdoc_or_fallback
194 if mdoc != null then
195 tpl.comment = mdoc.tpl_comment
196 end
197 return tpl
198 end
199
200 redef fun tpl_css_classes do return ["public"]
201 end
202
203 redef class MGroup
204 redef var nitdoc_id is lazy do
205 if parent != null then
206 return "{parent.nitdoc_id}__{name.to_cmangle}"
207 end
208 return name.to_cmangle
209 end
210
211 redef fun nitdoc_url do return "group_{nitdoc_id}.html"
212 redef var html_modifiers = ["group"]
213
214 # Depends if `self` is root or not.
215 #
216 # * If root `mproject`.
217 # * Else `mproject::self`.
218 redef fun html_namespace do
219 var tpl = new Template
220 tpl.add mproject.html_namespace
221 if mproject.root != self then
222 tpl.add "::"
223 tpl.add html_link
224 end
225 return tpl
226 end
227
228 redef fun tpl_definition do
229 var tpl = new TplDefinition
230 var mdoc = mdoc_or_fallback
231 if mdoc != null then
232 tpl.comment = mdoc.tpl_comment
233 end
234 return tpl
235 end
236 end
237
238 redef class MModule
239 redef var nitdoc_id is lazy do
240 if mgroup != null then
241 if mgroup.mmodules.length == 1 then
242 return "{mgroup.nitdoc_id}-"
243 else
244 return "{mgroup.nitdoc_id}__{name.to_cmangle}"
245 end
246 end
247 return name.to_cmangle
248 end
249
250 redef fun nitdoc_url do return "module_{nitdoc_id}.html"
251 redef var html_modifiers = ["module"]
252
253 # Depends if `self` belongs to a MGroup.
254 #
255 # * If mgroup `mgroup::self`.
256 # * Else `self`.
257 redef fun html_namespace do
258 var tpl = new Template
259 if mgroup != null then
260 tpl.add mgroup.html_namespace
261 tpl.add "::"
262 end
263 tpl.add html_link
264 return tpl
265 end
266
267 redef fun tpl_definition do
268 var tpl = new TplClassDefinition
269 var mdoc = mdoc_or_fallback
270 if mdoc != null then
271 tpl.comment = mdoc.tpl_comment
272 end
273 return tpl
274 end
275
276 redef fun tpl_css_classes do return ["public"]
277 end
278
279 redef class MClass
280 redef var nitdoc_id = "{intro_mmodule.nitdoc_id}__{name.to_cmangle}" is lazy
281 redef fun nitdoc_url do return "class_{nitdoc_id}.html"
282 redef fun mdoc_or_fallback do return intro.mdoc
283
284 # Format: `Foo[E]`
285 redef var html_name is lazy do
286 var tpl = new Template
287 tpl.add name.html_escape
288 if arity > 0 then
289 tpl.add "["
290 var parameter_names = new Array[String]
291 for p in mparameters do
292 parameter_names.add(p.html_name)
293 end
294 tpl.add parameter_names.join(", ")
295 tpl.add "]"
296 end
297 return tpl.write_to_string
298 end
299
300 redef fun html_modifiers do return intro.html_modifiers
301 redef fun html_declaration do return intro.html_declaration
302
303 # Returns `mproject::self`.
304 redef fun html_namespace do
305 var tpl = new Template
306 tpl.add intro_mmodule.mgroup.mproject.html_namespace
307 tpl.add "::<span>"
308 tpl.add html_link
309 tpl.add "</span>"
310 return tpl
311 end
312
313 # Returns `intro.html_short_signature`.
314 fun html_short_signature: Template do return intro.html_short_signature
315
316 # Returns `intro.html_signature`.
317 fun html_signature: Template do return intro.html_signature
318
319 redef fun tpl_definition do return intro.tpl_definition
320
321 redef fun tpl_title do
322 var title = new Template
323 title.add tpl_icon
324 title.add html_link
325 return title
326 end
327
328 redef fun tpl_icon do return intro.tpl_icon
329 redef fun tpl_css_classes do return intro.tpl_css_classes
330 end
331
332 redef class MClassDef
333 redef var nitdoc_id = "{mmodule.nitdoc_id}__{name.to_cmangle}" is lazy
334 redef fun nitdoc_url do return "{mclass.nitdoc_url}#{nitdoc_id}"
335 redef fun mdoc_or_fallback do return mdoc or else mclass.mdoc_or_fallback
336
337 # Depends if `self` is an intro or not.
338 #
339 # * If intro contains the visibility and kind.
340 # * If redef contains the `redef` keyword and kind.
341 redef fun html_modifiers do
342 var res = new Array[String]
343 if not is_intro then
344 res.add "redef"
345 else
346 if mclass.visibility != public_visibility then
347 res.add mclass.visibility.to_s
348 end
349 end
350 res.add mclass.kind.to_s
351 return res
352 end
353
354 # Depends if `self` is an intro or not.
355 #
356 # For intro: `private abstract class Foo[E: Object]`
357 # For redef: `redef class Foo[E]`
358 # TODO change the implementation to correspond to the comment.
359 redef fun html_declaration do
360 var tpl = new Template
361 tpl.add "<span>"
362 tpl.add html_modifiers.join(" ")
363 tpl.add " "
364 tpl.add html_link
365 tpl.add html_signature
366 tpl.add "</span>"
367 return tpl
368 end
369
370 # Returns `mmodule::self`
371 redef fun html_namespace do
372 var tpl = new Template
373 tpl.add mmodule.html_namespace
374 tpl.add "::<span>"
375 tpl.add mclass.html_link
376 tpl.add "</span>"
377 return tpl
378 end
379
380 # Returns the MClassDef generic signature without static bounds.
381 fun html_short_signature: Template do
382 var tpl = new Template
383 var mparameters = mclass.mparameters
384 if not mparameters.is_empty then
385 tpl.add "["
386 for i in [0..mparameters.length[ do
387 tpl.add mparameters[i].html_name
388 if i < mparameters.length - 1 then tpl.add ", "
389 end
390 tpl.add "]"
391 end
392 return tpl
393 end
394
395 # Returns the MClassDef generic signature with static bounds.
396 fun html_signature: Template do
397 var tpl = new Template
398 var mparameters = mclass.mparameters
399 if not mparameters.is_empty then
400 tpl.add "["
401 for i in [0..mparameters.length[ do
402 tpl.add "{mparameters[i].html_name}: "
403 tpl.add bound_mtype.arguments[i].html_signature
404 if i < mparameters.length - 1 then tpl.add ", "
405 end
406 tpl.add "]"
407 end
408 return tpl
409 end
410
411 redef fun tpl_article do
412 var tpl = new TplArticle(nitdoc_id)
413 tpl.summary_title = "in {mmodule.html_name}"
414 tpl.title = html_declaration
415 tpl.title_classes.add "signature"
416 var title = new Template
417 title.add "in "
418 title.add mmodule.html_namespace
419 tpl.subtitle = title
420 var mdoc = mdoc_or_fallback
421 if mdoc != null then
422 tpl.content = mdoc.tpl_comment
423 end
424 return tpl
425 end
426
427 redef fun tpl_title do
428 var title = new Template
429 title.add tpl_icon
430 title.add html_link
431 return title
432 end
433
434 redef fun tpl_definition do
435 var tpl = new TplClassDefinition
436 var mdoc = mdoc_or_fallback
437 if mdoc != null then
438 tpl.comment = mdoc.tpl_comment
439 end
440 return tpl
441 end
442
443 redef fun tpl_css_classes do
444 var set = new HashSet[String]
445 if is_intro then set.add "intro"
446 for m in mclass.intro.modifiers do set.add m.to_cmangle
447 for m in modifiers do set.add m.to_cmangle
448 return set.to_a
449 end
450
451 fun tpl_modifiers: Template do
452 var tpl = new Template
453 for modifier in modifiers do
454 if modifier == "public" then continue
455 tpl.add "{modifier.html_escape} "
456 end
457 return tpl
458 end
459 end
460
461 redef class MProperty
462 redef var nitdoc_id = "{intro_mclassdef.mclass.nitdoc_id}__{name.to_cmangle}" is lazy
463 redef fun nitdoc_url do return "property_{nitdoc_id}.html"
464 redef fun mdoc_or_fallback do return intro.mdoc
465 redef fun html_modifiers do return intro.html_modifiers
466 redef fun html_declaration do return intro.html_declaration
467
468 # Returns `mclass::self`.
469 redef fun html_namespace do
470 var tpl = new Template
471 tpl.add intro_mclassdef.mclass.html_namespace
472 tpl.add "::<span>"
473 tpl.add intro.html_link
474 tpl.add "</span>"
475 return tpl
476 end
477
478 # Returns `intro.html_short_signature`.
479 fun html_short_signature: Template do return intro.html_short_signature
480
481 # Returns `intro.html_signature`.
482 fun html_signature: Template do return intro.html_signature
483
484 redef fun tpl_title do return intro.tpl_title
485
486 redef fun tpl_icon do return intro.tpl_icon
487
488 redef fun tpl_css_classes do return intro.tpl_css_classes
489 end
490
491 redef class MPropDef
492 redef var nitdoc_id = "{mclassdef.nitdoc_id}__{name.to_cmangle}" is lazy
493 redef fun nitdoc_url do return "{mproperty.nitdoc_url}#{nitdoc_id}"
494 redef fun mdoc_or_fallback do return mdoc or else mproperty.mdoc_or_fallback
495
496 # Depends if `self` is an intro or not.
497 #
498 # * If intro contains the visibility and kind.
499 # * If redef contains the `redef` keyword and kind.
500 redef fun html_modifiers do
501 var res = new Array[String]
502 if not is_intro then
503 res.add "redef"
504 else
505 if mproperty.visibility != public_visibility then
506 res.add mproperty.visibility.to_s
507 end
508 end
509 return res
510 end
511
512 # Depends if `self` is an intro or not.
513 #
514 # For intro: `private fun foo(e: Object): Bar is abstract`
515 # For redef: `redef fun foo(e) is cached`
516 # TODO change the implementation to correspond to the comment.
517 redef fun html_declaration do
518 var tpl = new Template
519 tpl.add "<span>"
520 tpl.add html_modifiers.join(" ")
521 tpl.add " "
522 tpl.add html_link
523 tpl.add html_signature
524 tpl.add "</span>"
525 return tpl
526 end
527
528 # Returns `mclassdef::self`
529 redef fun html_namespace do
530 var tpl = new Template
531 tpl.add mclassdef.html_namespace
532 tpl.add "::"
533 tpl.add html_link
534 return tpl
535 end
536
537 # Returns the MPropdDef signature without static types.
538 fun html_short_signature: Template is abstract
539
540 # Returns the MPropDef signature with static types.
541 fun html_signature: Template is abstract
542
543 redef fun tpl_article do
544 var tpl = new TplArticle(nitdoc_id)
545 tpl.summary_title = "in {mclassdef.html_name}"
546 var title = new Template
547 title.add "in "
548 title.add mclassdef.html_link
549 tpl.title = title
550 tpl.subtitle = html_declaration
551 var mdoc = mdoc_or_fallback
552 if mdoc != null then
553 tpl.content = mdoc.tpl_comment
554 end
555 return tpl
556 end
557
558 redef fun tpl_definition do
559 var tpl = new TplDefinition
560 var mdoc = mdoc_or_fallback
561 if mdoc != null then
562 tpl.comment = mdoc.tpl_comment
563 end
564 return tpl
565 end
566
567 redef fun tpl_css_classes do
568 var set = new HashSet[String]
569 if is_intro then set.add "intro"
570 for m in mproperty.intro.modifiers do set.add m.to_cmangle
571 for m in modifiers do set.add m.to_cmangle
572 return set.to_a
573 end
574
575 fun tpl_modifiers: Template do
576 var tpl = new Template
577 for modifier in modifiers do
578 if modifier == "public" then continue
579 tpl.add "{modifier.html_escape} "
580 end
581 return tpl
582 end
583
584 redef fun tpl_list_item do
585 var lnk = new Template
586 lnk.add new TplLabel.with_classes(tpl_css_classes.to_a)
587 var atext = html_link.text
588 var ahref = "{mclassdef.mclass.nitdoc_url}#{mproperty.nitdoc_id}"
589 var atitle = html_link.title
590 var anchor = new Link.with_title(ahref, atext, atitle)
591 lnk.add anchor
592 var mdoc = mdoc_or_fallback
593 if mdoc != null then
594 lnk.add ": "
595 lnk.add mdoc.tpl_short_comment
596 end
597 return new TplListItem.with_content(lnk)
598 end
599
600 fun tpl_inheritance_item: TplListItem do
601 var lnk = new Template
602 lnk.add new TplLabel.with_classes(tpl_css_classes.to_a)
603 lnk.add mclassdef.mmodule.html_namespace
604 lnk.add "::"
605 var atext = mclassdef.html_link.text
606 var ahref = "{mclassdef.mclass.nitdoc_url}#{mproperty.nitdoc_id}"
607 var atitle = mclassdef.html_link.title
608 var anchor = new Link.with_title(ahref, atext, atitle)
609 lnk.add anchor
610 var mdoc = mdoc_or_fallback
611 if mdoc != null then
612 lnk.add ": "
613 lnk.add mdoc.tpl_short_comment
614 end
615 var li = new TplListItem.with_content(lnk)
616 li.css_classes.add "signature"
617 return li
618 end
619 end
620
621 redef class MAttributeDef
622
623 redef fun html_modifiers do
624 var res = super
625 res.add "var"
626 return res
627 end
628
629 redef fun html_short_signature do return new Template
630
631 redef fun html_signature do
632 var tpl = new Template
633 if static_mtype != null then
634 tpl.add ": "
635 tpl.add static_mtype.html_signature
636 end
637 return tpl
638 end
639 end
640
641 redef class MMethodDef
642
643 # FIXME annotation should be handled in their own way
644 redef fun html_modifiers do
645 var res = super
646 if is_abstract then
647 res.add "abstract"
648 else if is_intern then
649 res.add "intern"
650 end
651 if mproperty.is_init then
652 res.add "init"
653 else
654 res.add "fun"
655 end
656 return res
657 end
658
659 redef fun html_short_signature do return msignature.html_short_signature
660 redef fun html_signature do return msignature.html_signature
661 end
662
663 redef class MVirtualTypeProp
664 redef fun html_link do return mvirtualtype.html_link
665 end
666
667 redef class MVirtualTypeDef
668
669 redef fun html_modifiers do
670 var res = super
671 res.add "type"
672 return res
673 end
674
675 redef fun html_short_signature do return new Template
676
677 redef fun html_signature do
678 var tpl = new Template
679 if bound == null then return tpl
680 tpl.add ": "
681 tpl.add bound.html_signature
682 return tpl
683 end
684 end
685
686 redef class MType
687 # Returns the signature of this type whithout bounds.
688 fun html_short_signature: Template is abstract
689
690 # Returns the signature of this type.
691 fun html_signature: Template is abstract
692 end
693
694 redef class MClassType
695 redef fun html_link do return mclass.html_link
696 redef fun html_short_signature do return html_link
697 redef fun html_signature do return html_link
698 end
699
700 redef class MNullableType
701
702 redef fun html_short_signature do
703 var tpl = new Template
704 tpl.add "nullable "
705 tpl.add mtype.html_short_signature
706 return tpl
707 end
708
709 redef fun html_signature do
710 var tpl = new Template
711 tpl.add "nullable "
712 tpl.add mtype.html_signature
713 return tpl
714 end
715 end
716
717 redef class MGenericType
718 redef fun html_short_signature do
719 var lnk = html_link
720 var tpl = new Template
721 tpl.add new Link.with_title(lnk.href, mclass.name.html_escape, lnk.title)
722 tpl.add "["
723 for i in [0..arguments.length[ do
724 tpl.add arguments[i].html_short_signature
725 if i < arguments.length - 1 then tpl.add ", "
726 end
727 tpl.add "]"
728 return tpl
729 end
730
731 redef fun html_signature do
732 var lnk = html_link
733 var tpl = new Template
734 tpl.add new Link.with_title(lnk.href, mclass.name.html_escape, lnk.title)
735 tpl.add "["
736 for i in [0..arguments.length[ do
737 tpl.add arguments[i].html_signature
738 if i < arguments.length - 1 then tpl.add ", "
739 end
740 tpl.add "]"
741 return tpl
742 end
743 end
744
745 redef class MParameterType
746 redef fun html_link do
747 return new Link.with_title("{mclass.nitdoc_url}#FT_{name.to_cmangle}", name, "formal type")
748 end
749
750 redef fun html_short_signature do return html_link
751 redef fun html_signature do return html_link
752 end
753
754 redef class MVirtualType
755 redef fun html_link do return mproperty.intro.html_link
756 redef fun html_signature do return html_link
757 end
758
759 redef class MSignature
760
761 redef fun html_short_signature do
762 var tpl = new Template
763 if not mparameters.is_empty then
764 tpl.add "("
765 for i in [0..mparameters.length[ do
766 tpl.add mparameters[i].html_short_signature
767 if i < mparameters.length - 1 then tpl.add ", "
768 end
769 tpl.add ")"
770 end
771 return tpl
772 end
773
774 redef fun html_signature do
775 var tpl = new Template
776 if not mparameters.is_empty then
777 tpl.add "("
778 for i in [0..mparameters.length[ do
779 tpl.add mparameters[i].html_signature
780 if i < mparameters.length - 1 then tpl.add ", "
781 end
782 tpl.add ")"
783 end
784 if return_mtype != null then
785 tpl.add ": "
786 tpl.add return_mtype.html_signature
787 end
788 return tpl
789 end
790 end
791
792 redef class MParameter
793
794 # Returns `self` name and ellipsys if any.
795 fun html_short_signature: Template do
796 var tpl = new Template
797 tpl.add name
798 if is_vararg then tpl.add "..."
799 return tpl
800 end
801
802 # Returns `self` name with it's static type and ellipsys if any.
803 fun html_signature: Template do
804 var tpl = new Template
805 tpl.add "{name}: "
806 tpl.add mtype.html_signature
807 if is_vararg then tpl.add "..."
808 return tpl
809 end
810 end
811
812 redef class ConcernsTree
813
814 private var seen = new HashSet[MConcern]
815
816 redef fun add(p, e) do
817 if seen.has(e) then return
818 seen.add e
819 super(p, e)
820 end
821
822 fun to_tpl: TplList do
823 var lst = new TplList.with_classes(["list-unstyled", "list-definition"])
824 for r in roots do
825 var li = r.tpl_concern_item
826 lst.add_li li
827 build_list(r, li)
828 end
829 return lst
830 end
831
832 private fun build_list(e: MConcern, li: TplListItem) do
833 if not sub.has_key(e) then return
834 var subs = sub[e]
835 var lst = new TplList.with_classes(["list-unstyled", "list-definition"])
836 for e2 in subs do
837 if e2 isa MGroup and e2.is_root then
838 build_list(e2, li)
839 else
840 var sli = e2.tpl_concern_item
841 lst.add_li sli
842 build_list(e2, sli)
843 end
844 end
845 li.append lst
846 end
847 end
848
849
850 ################################################################################
851 # Additions to `model_ext`.
852
853 redef class MRawType
854 redef fun html_signature do
855 var tpl = new Template
856
857 for part in parts do
858 if part.target != null then
859 tpl.add part.target.as(not null).html_link
860 else
861 tpl.add part.text.html_escape
862 end
863 end
864 return tpl
865 end
866 end
867
868 redef class MInnerClass
869 redef fun nitdoc_url do return inner.nitdoc_url
870 redef fun html_signature do return inner.html_signature
871 end
872
873 redef class MInnerClassDef
874 redef fun nitdoc_url do return inner.nitdoc_url
875
876 redef fun html_link_to_anchor do return inner.html_link_to_anchor
877 redef fun html_link do return inner.html_link
878 redef fun html_signature do return inner.html_signature
879
880 redef fun tpl_definition do
881 var tpl = new TplClassDefinition
882 var mdoc = mdoc_or_fallback
883 if mdoc != null then
884 tpl.comment = mdoc.tpl_comment
885 end
886 return tpl
887 end
888 end