1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # Nitdoc page generation
20 # The NitdocContext contains all the knowledge used for doc generation
22 private var opt_dir
= new OptionString("output directory", "-d", "--dir")
23 private var opt_source
= new OptionString("link for source (%f for filename, %l for first line, %L for last line)", "--source")
24 private var opt_sharedir
= new OptionString("directory containing nitdoc assets", "--sharedir")
25 private var opt_shareurl
= new OptionString("use shareurl instead of copy shared files", "--shareurl")
26 private var opt_nodot
= new OptionBool("do not generate graphes with graphviz", "--no-dot")
27 private var opt_private
= new OptionBool("also generate private API", "--private")
29 private var opt_custom_title
= new OptionString("custom title for homepage", "--custom-title")
30 private var opt_custom_brand
= new OptionString("custom link to external site", "--custom-brand")
31 private var opt_custom_intro
= new OptionString("custom intro text for homepage", "--custom-overview-text")
32 private var opt_custom_footer
= new OptionString("custom footer text", "--custom-footer-text")
34 private var opt_github_upstream
= new OptionString("Git branch where edited commits will be pulled into (ex: user:repo:branch)", "--github-upstream")
35 private var opt_github_base_sha1
= new OptionString("Git sha1 of base commit used to create pull request", "--github-base-sha1")
36 private var opt_github_gitdir
= new OptionString("Git working directory used to resolve path name (ex: /home/me/myproject/)", "--github-gitdir")
38 private var opt_piwik_tracker
= new OptionString("Piwik tracker URL (ex: nitlanguage.org/piwik/)", "--piwik-tracker")
39 private var opt_piwik_site_id
= new OptionString("Piwik site ID", "--piwik-site-id")
41 private var toolcontext
= new ToolContext
42 private var mbuilder
: ModelBuilder
43 private var mainmodule
: MModule
44 private var output_dir
: String
45 private var min_visibility
: MVisibility
48 var opts
= toolcontext
.option_context
49 opts
.add_option
(opt_dir
, opt_source
, opt_sharedir
, opt_shareurl
, opt_nodot
, opt_private
)
50 opts
.add_option
(opt_custom_title
, opt_custom_footer
, opt_custom_intro
, opt_custom_brand
)
51 opts
.add_option
(opt_github_upstream
, opt_github_base_sha1
, opt_github_gitdir
)
52 opts
.add_option
(opt_piwik_tracker
, opt_piwik_site_id
)
54 var tpl
= new Template
55 tpl
.add
"Usage: nitdoc [OPTION]... <file.nit>...\n"
56 tpl
.add
"Generates HTML pages of API documentation from Nit source files."
57 toolcontext
.tooldescription
= tpl
.write_to_string
58 toolcontext
.process_options
(args
)
61 self.parse
(toolcontext
.option_context
.rest
)
64 private fun process_options
do
65 if opt_private
.value
then
66 min_visibility
= none_visibility
68 min_visibility
= protected_visibility
70 var gh_upstream
= opt_github_upstream
.value
71 var gh_base_sha
= opt_github_base_sha1
.value
72 var gh_gitdir
= opt_github_gitdir
.value
73 if not gh_upstream
== null or not gh_base_sha
== null or not gh_gitdir
== null then
74 if gh_upstream
== null or gh_base_sha
== null or gh_gitdir
== null then
75 print
"Error: Options {opt_github_upstream.names.first}, {opt_github_base_sha1.names.first} and {opt_github_gitdir.names.first} are required to enable the GitHub plugin"
81 private fun parse
(arguments
: Array[String]) do
83 mbuilder
= new ModelBuilder(model
, toolcontext
)
84 var mmodules
= mbuilder
.parse
(arguments
)
85 if mmodules
.is_empty
then return
87 if mmodules
.length
== 1 then
88 mainmodule
= mmodules
.first
90 mainmodule
= new MModule(model
, null, "<main>", new Location(null, 0, 0, 0, 0))
91 mainmodule
.is_fictive
= true
92 mainmodule
.set_imported_mmodules
(mmodules
)
96 fun generate_nitdoc
do
107 private fun init_output_dir
do
108 # location output dir
109 var output_dir
= opt_dir
.value
110 if output_dir
== null then
113 self.output_dir
= output_dir
114 # create destination dir if it's necessary
115 if not output_dir
.file_exists
then output_dir
.mkdir
117 var sharedir
= opt_sharedir
.value
118 if sharedir
== null then
119 var dir
= toolcontext
.nit_dir
121 print
"Error: Cannot locate nitdoc share files. Uses --sharedir or envvar NIT_DIR"
124 sharedir
= "{dir}/share/nitdoc"
125 if not sharedir
.file_exists
then
126 print
"Error: Cannot locate nitdoc share files. Uses --sharedir or envvar NIT_DIR"
131 if opt_shareurl
.value
== null then
132 sys
.system
("cp -r {sharedir.to_s}/* {output_dir.to_s}/")
134 sys
.system
("cp -r {sharedir.to_s}/resources/ {output_dir.to_s}/resources/")
139 private fun overview
do
140 var overviewpage
= new NitdocOverview(self)
141 overviewpage
.render
.write_to_file
("{output_dir.to_s}/index.html")
144 private fun search
do
145 var searchpage
= new NitdocSearch(self)
146 searchpage
.render
.write_to_file
("{output_dir.to_s}/search.html")
149 private fun groups
do
150 for mproject
in mbuilder
.model
.mprojects
do
151 for mgroup
in mproject
.mgroups
.to_a
do
152 var page
= new NitdocGroup(mgroup
, self)
153 page
.render
.write_to_file
("{output_dir.to_s}/{mgroup.nitdoc_url}")
158 private fun modules
do
159 for mmodule
in mbuilder
.model
.mmodules
do
160 if mmodule
.name
== "<main>" then continue
161 var modulepage
= new NitdocModule(mmodule
, self)
162 modulepage
.render
.write_to_file
("{output_dir.to_s}/{mmodule.nitdoc_url}")
166 private fun classes
do
167 for mclass
in mbuilder
.model
.mclasses
do
168 var classpage
= new NitdocClass(mclass
, self)
169 classpage
.render
.write_to_file
("{output_dir.to_s}/{mclass.nitdoc_url}")
173 private fun properties
do
174 for mproperty
in mbuilder
.model
.mproperties
do
175 var page
= new NitdocProperty(mproperty
, self)
176 page
.render
.write_to_file
("{output_dir.to_s}/{mproperty.nitdoc_url}")
180 private fun quicksearch_list
do
181 var quicksearch
= new QuickSearch(self)
182 quicksearch
.render
.write_to_file
("{output_dir.to_s}/quicksearch-list.js")
186 # Nitdoc QuickSearch list generator
188 # Create a JSON object containing links to:
192 # All entities are grouped by name to make the research easier.
195 private var mmodules
= new HashSet[MModule]
196 private var mclasses
= new HashSet[MClass]
197 private var mpropdefs
= new HashMap[String, Set[MPropDef]]
199 init(ctx
: NitdocContext) do
200 for mmodule
in ctx
.mbuilder
.model
.mmodules
do
201 if mmodule
.name
== "<main>" then continue
204 for mclass
in ctx
.mbuilder
.model
.mclasses
do
205 if mclass
.visibility
< ctx
.min_visibility
then continue
208 for mproperty
in ctx
.mbuilder
.model
.mproperties
do
209 if mproperty
.visibility
< ctx
.min_visibility
then continue
210 if mproperty
isa MAttribute then continue
211 if not mpropdefs
.has_key
(mproperty
.name
) then
212 mpropdefs
[mproperty
.name
] = new HashSet[MPropDef]
214 mpropdefs
[mproperty
.name
].add_all
(mproperty
.mpropdefs
)
218 fun render
: Template do
219 var tpl
= new Template
220 tpl
.add
"var nitdocQuickSearchRawList=\{ "
221 for mmodule
in mmodules
do
222 tpl
.add
"\"{mmodule.name}\
":["
223 tpl
.add
"\{txt:\"{mmodule.full_name}\",url
:\
"{mmodule.nitdoc_url}\"\
},"
226 for mclass in mclasses do
227 var full_name = mclass.intro.mmodule.full_name
228 tpl.add "\
"{mclass.name}\":["
229 tpl.add "\
{txt:\"{full_name}\
",url:\"{mclass.nitdoc_url}\
"\},"
232 for mproperty
, mprops
in mpropdefs
do
233 tpl
.add
"\"{mproperty}\
":["
234 for mpropdef
in mprops
do
235 var full_name
= mpropdef
.mclassdef
.mclass
.full_name
236 tpl
.add
"\{txt:\"{full_name}\",url
:\
"{mpropdef.nitdoc_url}\"\
},"
246 # Define page structure and properties
247 abstract class NitdocPage
249 private var ctx: NitdocContext
250 private var model: Model
251 private var name_sorter = new MEntityNameSorter
253 init(ctx: NitdocContext) do
255 self.model = ctx.mbuilder.model
258 # Render the page as a html template
259 fun render: Template do
261 if ctx.opt_shareurl.value != null then
262 shareurl = ctx.opt_shareurl.value.as(not null)
267 tpl.title = tpl_title
268 tpl.shareurl = shareurl
269 tpl.topmenu = tpl_topmenu
271 tpl.footer = ctx.opt_custom_footer.value
272 tpl.body_attrs.add(new TagAttribute("data-bootstrap-share
", shareurl))
273 tpl.sidebar = tpl_sidebar
276 var tracker_url = ctx.opt_piwik_tracker.value
277 var site_id = ctx.opt_piwik_site_id.value
278 if tracker_url != null and site_id != null then
279 tpl.scripts.add new TplPiwikScript(tracker_url, site_id)
284 # Build page template
285 fun tpl_page: TplPage is abstract
287 # Build page sidebar if any
288 fun tpl_sidebar: nullable TplSidebar do return null
290 # Build page title string
291 fun tpl_title: String do
292 if ctx.opt_custom_title.value != null then
293 return ctx.opt_custom_title.value.to_s
298 # Build top menu template
299 fun tpl_topmenu: TplTopMenu do
300 var topmenu = new TplTopMenu
301 var brand = ctx.opt_custom_brand.value
302 if brand != null then
303 var tpl = new Template
304 tpl.add "<span
class='navbar-brand'>"
312 # Build page content template
313 fun tpl_content is abstract
315 # Clickable graphviz image using dot format
316 # return null if no graph for this page
317 fun tpl_graph(dot: FlatBuffer, name: String, title: nullable String): nullable TplArticle do
318 if ctx.opt_nodot.value then return null
319 var output_dir = ctx.output_dir
320 var file = new OFStream.open("{output_dir}/{name}.dot
")
323 sys.system("\
{ test -f {output_dir}/{name}.png
&& test
-f
{output_dir}/{name}.s
.dot
&& diff
{output_dir}/{name}.dot
{output_dir}/{name}.s
.dot
>/dev
/null 2>&1 ; \
} || \
{ cp {output_dir}/{name}.dot
{output_dir}/{name}.s
.dot
&& dot
-Tpng -o
{output_dir}/{name}.png
-Tcmapx -o
{output_dir}/{name}.map
{output_dir}/{name}.s
.dot
; \
}")
324 var fmap = new IFStream.open("{output_dir}/{name}.map
")
325 var map = fmap.read_all
328 var article = new TplArticle("graph
")
330 if title != null then
331 article.title = title
332 alt = "alt
='{title}'"
334 article.css_classes.add "text-center
"
335 var content = new Template
336 content.add "<img src
='{name}.png' usemap
='#{name}' style
='margin:auto' {alt}/>"
338 article.content = content
342 # A (source) link template for a given location
343 fun tpl_showsource(location: nullable Location): nullable String
345 if location == null then return null
346 var source = ctx.opt_source.value
347 if source == null then return "{location.file.filename.simplify_path}"
348 # THIS IS JUST UGLY ! (but there is no replace yet)
349 var x = source.split_with("%f
")
350 source = x.join(location.file.filename.simplify_path)
351 x = source.split_with("%l
")
352 source = x.join(location.line_start.to_s)
353 x = source.split_with("%L
")
354 source = x.join(location.line_end.to_s)
355 source = source.simplify_path
356 return "<a target
='_blank' title
='Show source' href
=\
"{source.to_s}\">View Source</a
>"
359 # MProject description template
360 fun tpl_mproject_article(mproject: MProject): TplArticle do
361 var article = mproject.tpl_article
362 article.subtitle = mproject.tpl_declaration
363 article.content = mproject.tpl_definition
364 if mproject.mdoc != null then
365 article.content = mproject.mdoc.tpl_short_comment
370 # MGroup description template
371 fun tpl_mgroup_article(mgroup: MGroup): TplArticle do
372 var article = mgroup.tpl_article
373 article.subtitle = mgroup.tpl_declaration
374 article.content = mgroup.tpl_definition
378 # MModule description template
379 fun tpl_mmodule_article(mmodule: MModule): TplArticle do
380 var article = mmodule.tpl_article
381 article.subtitle = mmodule.tpl_declaration
382 article.content = mmodule.tpl_definition
384 var intros = mmodule.intro_mclassdefs(ctx.min_visibility).to_a
385 ctx.mainmodule.linearize_mclassdefs(intros)
386 var intros_art = new TplArticle.with_title("{mmodule.nitdoc_id}_intros
", "Introduces")
387 var intros_lst = new TplList.with_classes(["list-unstyled
", "list-labeled
"])
388 for mclassdef in intros do
389 intros_lst.add_li new TplListItem.with_content(mclassdef.tpl_list_item)
391 if not intros_lst.is_empty then
392 intros_art.content = intros_lst
393 article.add_child intros_art
395 var redefs = mmodule.redef_mclassdefs(ctx.min_visibility).to_a
396 ctx.mainmodule.linearize_mclassdefs(redefs)
397 var redefs_art = new TplArticle.with_title("{mmodule.nitdoc_id}_redefs
", "Redefines")
398 var redefs_lst = new TplList.with_classes(["list-unstyled
", "list-labeled
"])
399 for mclassdef in redefs do
400 redefs_lst.add_li new TplListItem.with_content(mclassdef.tpl_list_item)
402 if not redefs_lst.is_empty then
403 redefs_art.content = redefs_lst
404 article.add_child redefs_art
409 # MClassDef description template
410 fun tpl_mclass_article(mclass: MClass, mclassdefs: Array[MClassDef]): TplArticle do
411 var article = mclass.tpl_article
412 if not mclassdefs.has(mclass.intro) then
414 var intro_article = mclass.intro.tpl_short_article
415 intro_article.source_link = tpl_showsource(mclass.intro.location)
416 article.add_child intro_article
418 ctx.mainmodule.linearize_mclassdefs(mclassdefs)
419 for mclassdef in mclassdefs do
420 # add mclassdef full description
421 var redef_article = mclassdef.tpl_article
422 redef_article.source_link = tpl_showsource(mclassdef.location)
423 article.add_child redef_article
425 var intros = new TplArticle.with_title("{mclassdef.nitdoc_id}_intros
", "Introduces")
426 var intros_lst = new TplList.with_classes(["list-unstyled
", "list-labeled
"])
427 for mpropdef in mclassdef.collect_intro_mpropdefs(ctx.min_visibility) do
428 intros_lst.add_li new TplListItem.with_content(mpropdef.tpl_list_item)
430 if not intros_lst.is_empty then
431 intros.content = intros_lst
432 redef_article.add_child intros
434 var redefs = new TplArticle.with_title("{mclassdef.nitdoc_id}_redefs
", "Redefines")
435 var redefs_lst = new TplList.with_classes(["list-unstyled
", "list-labeled
"])
436 for mpropdef in mclassdef.collect_redef_mpropdefs(ctx.min_visibility) do
437 redefs_lst.add_li new TplListItem.with_content(mpropdef.tpl_list_item)
439 if not redefs_lst.is_empty then
440 redefs.content = redefs_lst
441 redef_article.add_child redefs
447 # MClassDef description template
448 fun tpl_mclassdef_article(mclassdef: MClassDef): TplArticle do
449 var article = mclassdef.tpl_article
450 if mclassdef.is_intro then article.content = null
451 article.source_link = tpl_showsource(mclassdef.location)
455 # MProp description template
456 fun tpl_mprop_article(mproperty: MProperty, mpropdefs: Array[MPropDef]): TplArticle do
457 var article = mproperty.tpl_article
458 if not mpropdefs.has(mproperty.intro) then
460 var intro_article = mproperty.intro.tpl_short_article
461 intro_article.source_link = tpl_showsource(mproperty.intro.location)
462 article.add_child intro_article
464 ctx.mainmodule.linearize_mpropdefs(mpropdefs)
465 for mpropdef in mpropdefs do
466 # add mpropdef description
467 var redef_article = mpropdef.tpl_article
468 redef_article.source_link = tpl_showsource(mpropdef.location)
469 article.add_child redef_article
474 # MProperty description template
475 fun tpl_mpropdef_article(mpropdef: MPropDef): TplArticle do
476 var article = mpropdef.tpl_article
477 if mpropdef.is_intro then article.content = null
478 article.source_link = tpl_showsource(mpropdef.location)
484 # Display a list of modules contained in program
488 init(ctx: NitdocContext) do super(ctx)
490 private var page = new TplPage
491 redef fun tpl_page do return page
493 private var sidebar = new TplSidebar
494 redef fun tpl_sidebar do return sidebar
496 redef fun tpl_title do
497 if ctx.opt_custom_title.value != null then
498 return ctx.opt_custom_title.value.to_s
504 redef fun tpl_topmenu do
506 topmenu.add_item(new TplLink("#", "Overview"), true)
507 topmenu
.add_item
(new TplLink("search.html", "Index"), false)
512 private fun tpl_intro
: TplSection do
513 var section
= new TplSection.with_title
("overview", tpl_title
)
514 var article
= new TplArticle("intro")
515 if ctx
.opt_custom_intro
.value
!= null then
516 article
.content
= ctx
.opt_custom_intro
.value
.to_s
518 section
.add_child article
523 private fun tpl_projects
(section
: TplSection) do
525 var mprojects
= model
.mprojects
.to_a
526 var sorter
= new MConcernRankSorter
527 sorter
.sort mprojects
528 var ssection
= new TplSection.with_title
("projects", "Projects")
529 for mproject
in mprojects
do
530 ssection
.add_child tpl_mproject_article
(mproject
)
532 section
.add_child ssection
535 redef fun tpl_content
do
538 tpl_page
.add_section top
543 # Display a list of modules, classes and properties
547 init(ctx
: NitdocContext) do super(ctx
)
549 private var page
= new TplPage
550 redef fun tpl_page
do return page
552 redef fun tpl_title
do return "Index"
554 redef fun tpl_topmenu
do
556 topmenu
.add_item
(new TplLink("index.html", "Overview"), false)
557 topmenu
.add_item
(new TplLink("#", "Index"), true)
561 redef fun tpl_content
do
562 var tpl
= new TplSearchPage("search_all")
563 var section
= new TplSection("search")
567 for mmodule
in modules_list
do
568 tpl
.modules
.add mmodule
.tpl_link
571 for mclass
in classes_list
do
572 tpl
.classes
.add mclass
.tpl_link
575 for mproperty
in mprops_list
do
577 m
.add mproperty
.intro
.tpl_link
579 m
.add mproperty
.intro
.mclassdef
.mclass
.tpl_link
583 section
.add_child tpl
584 tpl_page
.add_section section
587 # Extract mmodule list to display (sorted by name)
588 private fun modules_list
: Array[MModule] do
589 var sorted
= new Array[MModule]
590 for mmodule
in ctx
.mbuilder
.model
.mmodule_importation_hierarchy
do
591 if mmodule
.name
== "<main>" then continue
594 name_sorter
.sort
(sorted
)
598 # Extract mclass list to display (sorted by name)
599 private fun classes_list
: Array[MClass] do
600 var sorted
= new Array[MClass]
601 for mclass
in ctx
.mbuilder
.model
.mclasses
do
602 if mclass
.visibility
< ctx
.min_visibility
then continue
605 name_sorter
.sort
(sorted
)
609 # Extract mproperty list to display (sorted by name)
610 private fun mprops_list
: Array[MProperty] do
611 var sorted
= new Array[MProperty]
612 for mproperty
in ctx
.mbuilder
.model
.mproperties
do
613 if mproperty
.visibility
< ctx
.min_visibility
then continue
614 if mproperty
isa MAttribute then continue
617 name_sorter
.sort
(sorted
)
623 # Display a flattened view of the group
627 private var mgroup
: MGroup
629 private var concerns
: ConcernsTree
630 private var intros
: Set[MClass]
631 private var redefs
: Set[MClass]
633 init(mgroup
: MGroup, ctx
: NitdocContext) do
637 self.concerns
= model
.concerns_tree
(mgroup
.collect_mmodules
)
638 self.concerns
.sort_with
(new MConcernRankSorter)
639 self.intros
= mgroup
.in_nesting_intro_mclasses
(ctx
.min_visibility
)
640 var redefs
= new HashSet[MClass]
641 for rdef
in mgroup
.in_nesting_redef_mclasses
(ctx
.min_visibility
) do
642 if intros
.has
(rdef
) then continue
648 private var page
= new TplPage
649 redef fun tpl_page
do return page
651 private var sidebar
= new TplSidebar
652 redef fun tpl_sidebar
do return sidebar
654 redef fun tpl_title
do return "{mgroup.nitdoc_name}"
656 redef fun tpl_topmenu
do
658 var mproject
= mgroup
.mproject
659 topmenu
.add_item
(new TplLink("index.html", "Overview"), false)
660 if mgroup
.is_root
then
661 topmenu
.add_item
(new TplLink("#", "{mproject.nitdoc_name}"), true)
663 topmenu
.add_item
(new TplLink(mproject
.nitdoc_url
, "{mproject.nitdoc_name}"), false)
664 topmenu
.add_item
(new TplLink("#", "{mgroup.nitdoc_name}"), true)
666 topmenu
.add_item
(new TplLink("search.html", "Index"), false)
670 # Class list to display in sidebar
671 fun tpl_sidebar_mclasses
do
672 var mclasses
= new HashSet[MClass]
673 mclasses
.add_all intros
674 mclasses
.add_all redefs
675 if mclasses
.is_empty
then return
676 var list
= new TplList.with_classes
(["list-unstyled", "list-labeled"])
678 var sorted
= mclasses
.to_a
679 name_sorter
.sort
(sorted
)
680 for mclass
in sorted
do
681 list
.add_li tpl_sidebar_item
(mclass
)
683 tpl_sidebar
.boxes
.add
new TplSideBox.with_content
("All classes", list
)
686 private fun tpl_sidebar_item
(def
: MClass): Template do
687 var classes
= def
.intro
.tpl_css_classes
.to_a
688 if intros
.has
(def
) then
693 var lnk
= new Template
694 lnk
.add
new TplLabel.with_classes
(classes
)
700 private fun tpl_intro
: TplSection do
701 var section
= new TplSection.with_title
("top", tpl_title
)
702 var article
= new TplArticle("intro")
704 if mgroup
.is_root
then
705 section
.subtitle
= mgroup
.mproject
.tpl_declaration
706 article
.content
= mgroup
.mproject
.tpl_definition
708 section
.subtitle
= mgroup
.tpl_declaration
709 article
.content
= mgroup
.tpl_definition
711 section
.add_child article
715 private fun tpl_concerns
(section
: TplSection) do
716 if concerns
.is_empty
then return
717 section
.add_child
new TplArticle.with_content
("concerns", "Concerns", concerns
.to_tpl
)
720 private fun tpl_groups
(parent
: TplSection) do
721 var lst
= concerns
.to_a
723 for mentity
in lst
do
724 if mentity
isa MProject then
725 section
.add_child
new TplSection(mentity
.nitdoc_id
)
726 else if mentity
isa MGroup then
727 section
.add_child
new TplSection(mentity
.nitdoc_id
)
728 else if mentity
isa MModule then
729 section
.add_child tpl_mmodule_article
(mentity
)
734 redef fun tpl_content
do
739 tpl_page
.add_section top
742 private fun sort_by_mclass
(mclassdefs
: Collection[MClassDef]): Map[MClass, Set[MClassDef]] do
743 var map
= new HashMap[MClass, Set[MClassDef]]
744 for mclassdef
in mclassdefs
do
745 var mclass
= mclassdef
.mclass
746 if not map
.has_key
(mclass
) then map
[mclass
] = new HashSet[MClassDef]
747 map
[mclass
].add mclassdef
754 # Display the list of introduced and redefined classes in module
758 private var mmodule
: MModule
759 private var concerns
: ConcernsTree
760 private var mclasses2mdefs
: Map[MClass, Set[MClassDef]]
761 private var mmodules2mclasses
: Map[MModule, Set[MClass]]
763 init(mmodule
: MModule, ctx
: NitdocContext) do
764 self.mmodule
= mmodule
767 var mclassdefs
= new HashSet[MClassDef]
768 mclassdefs
.add_all mmodule
.intro_mclassdefs
(ctx
.min_visibility
)
769 mclassdefs
.add_all mmodule
.redef_mclassdefs
(ctx
.min_visibility
)
770 self.mclasses2mdefs
= sort_by_mclass
(mclassdefs
)
771 self.mmodules2mclasses
= group_by_mmodule
(mclasses2mdefs
.keys
)
772 self.concerns
= model
.concerns_tree
(mmodules2mclasses
.keys
)
774 mmodule
.mgroup
.mproject
.booster_rank
= -1000
775 mmodule
.mgroup
.booster_rank
= -1000
776 mmodule
.booster_rank
= -1000
777 self.concerns
.sort_with
(new MConcernRankSorter)
778 mmodule
.mgroup
.mproject
.booster_rank
= 0
779 mmodule
.mgroup
.booster_rank
= 0
780 mmodule
.booster_rank
= 0
783 private var page
= new TplPage
784 redef fun tpl_page
do return page
786 private var sidebar
= new TplSidebar
787 redef fun tpl_sidebar
do return sidebar
789 redef fun tpl_title
do return "{mmodule.nitdoc_name}"
791 redef fun tpl_topmenu
do
793 var mproject
= mmodule
.mgroup
.mproject
794 topmenu
.add_item
(new TplLink("index.html", "Overview"), false)
795 topmenu
.add_item
(new TplLink("{mproject.nitdoc_url}", "{mproject.nitdoc_name}"), false)
796 topmenu
.add_item
(new TplLink("#", "{mmodule.nitdoc_name}"), true)
797 topmenu
.add_item
(new TplLink("search.html", "Index"), false)
801 # Class list to display in sidebar
802 fun tpl_sidebar_mclasses
do
803 var mclasses
= new HashSet[MClass]
804 mclasses
.add_all mmodule
.filter_intro_mclasses
(ctx
.min_visibility
)
805 mclasses
.add_all mmodule
.filter_redef_mclasses
(ctx
.min_visibility
)
806 if mclasses
.is_empty
then return
807 var list
= new TplList.with_classes
(["list-unstyled", "list-labeled"])
809 var sorted
= mclasses
.to_a
810 name_sorter
.sort
(sorted
)
811 for mclass
in sorted
do
812 list
.add_li tpl_sidebar_item
(mclass
)
814 tpl_sidebar
.boxes
.add
new TplSideBox.with_content
("All classes", list
)
817 private fun tpl_sidebar_item
(def
: MClass): Template do
818 var classes
= def
.intro
.tpl_css_classes
.to_a
819 if def
.intro_mmodule
== mmodule
then
824 var lnk
= new Template
825 lnk
.add
new TplLabel.with_classes
(classes
)
831 private fun tpl_intro
: TplSection do
832 var section
= new TplSection.with_title
("top", tpl_title
)
833 section
.subtitle
= mmodule
.tpl_declaration
835 var article
= new TplArticle("intro")
836 var def
= mmodule
.tpl_definition
837 var location
= mmodule
.location
838 article
.source_link
= tpl_showsource
(location
)
839 article
.content
= def
840 section
.add_child article
844 # inheritance section
845 private fun tpl_inheritance
(parent
: TplSection) do
846 # Extract relevent modules
847 var imports
= mmodule
.in_importation
.greaters
848 if imports
.length
> 10 then imports
= mmodule
.in_importation
.direct_greaters
849 var clients
= mmodule
.in_importation
.smallers
850 if clients
.length
> 10 then clients
= mmodule
.in_importation
.direct_smallers
853 var section
= new TplSection.with_title
("dependencies", "Dependencies")
856 var mmodules
= new HashSet[MModule]
857 mmodules
.add_all mmodule
.in_nesting
.direct_greaters
858 mmodules
.add_all imports
859 if clients
.length
< 10 then mmodules
.add_all clients
861 var graph
= tpl_dot
(mmodules
)
862 if graph
!= null then section
.add_child graph
865 var lst
= new Array[MModule]
866 for dep
in imports
do
867 if dep
.is_fictive
then continue
868 if dep
== mmodule
then continue
871 if not lst
.is_empty
then
873 section
.add_child tpl_list
("imports", "Imports", lst
)
877 lst
= new Array[MModule]
878 for dep
in clients
do
879 if dep
.is_fictive
then continue
880 if dep
== mmodule
then continue
883 if not lst
.is_empty
then
885 section
.add_child tpl_list
("clients", "Clients", lst
)
888 parent
.add_child section
891 private fun tpl_list
(id
: String, title
: String, mmodules
: Array[MModule]): TplArticle do
892 var article
= new TplArticle.with_title
(id
, title
)
893 var list
= new TplList.with_classes
(["list-unstyled", "list-definition"])
894 for mmodule
in mmodules
do list
.elts
.add mmodule
.tpl_list_item
895 article
.content
= list
899 private fun tpl_concerns
(parent
: TplSection) do
900 if concerns
.is_empty
then return
901 parent
.add_child
new TplArticle.with_content
("concerns", "Concerns", concerns
.to_tpl
)
904 private fun tpl_mclasses
(parent
: TplSection) do
905 for mentity
in concerns
do
906 if mentity
isa MProject then
907 parent
.add_child
new TplSection(mentity
.nitdoc_id
)
908 else if mentity
isa MGroup then
909 parent
.add_child
new TplSection(mentity
.nitdoc_id
)
910 else if mentity
isa MModule then
911 var section
= new TplSection(mentity
.nitdoc_id
)
912 var title
= new Template
913 if mentity
== mmodule
then
915 section
.summary_title
= "in {mentity.nitdoc_name}"
918 section
.summary_title
= "from {mentity.nitdoc_name}"
920 title
.add mentity
.tpl_namespace
921 section
.title
= title
923 var mclasses
= mmodules2mclasses
[mentity
].to_a
924 name_sorter
.sort
(mclasses
)
925 for mclass
in mclasses
do
926 section
.add_child tpl_mclass_article
(mclass
, mclasses2mdefs
[mclass
].to_a
)
928 parent
.add_child section
933 private fun group_by_mmodule
(mclasses
: Collection[MClass]): Map[MModule, Set[MClass]] do
934 var res
= new HashMap[MModule, Set[MClass]]
935 for mclass
in mclasses
do
936 var mmodule
= mclass
.intro_mmodule
937 if not res
.has_key
(mmodule
) then
938 res
[mmodule
] = new HashSet[MClass]
940 res
[mmodule
].add
(mclass
)
945 redef fun tpl_content
do
951 tpl_page
.add_section top
954 # Genrate dot hierarchy for class inheritance
955 fun tpl_dot
(mmodules
: Collection[MModule]): nullable TplArticle do
956 var poset
= new POSet[MModule]
957 for mmodule
in mmodules
do
958 if mmodule
.is_fictive
then continue
959 poset
.add_node mmodule
960 for omodule
in mmodules
do
961 if mmodule
.is_fictive
then continue
962 poset
.add_node mmodule
963 if mmodule
.in_importation
< omodule
then
964 poset
.add_edge
(mmodule
, omodule
)
969 var op
= new FlatBuffer
970 var name
= "dep_{mmodule.name}"
971 op
.append
("digraph {name} \{ rankdir=BT; node[shape=none,margin=0,width=0,height=0,fontsize=10]; edge[dir=none,color=gray]; ranksep=0.2; nodesep=0.1;\n")
972 for mmodule
in poset
do
973 if mmodule
== self.mmodule
then
974 op
.append
("\"{mmodule.name}\
"[shape=box,margin=0.03];\n")
976 op
.append
("\"{mmodule.name}\
"[URL=\"{mmodule.nitdoc_url}\
"];\n")
978 for omodule
in poset
[mmodule
].direct_greaters
do
979 op
.append
("\"{mmodule.name}\
"->\"{omodule.name}\
";\n")
983 return tpl_graph
(op
, name
, null)
986 private fun sort_by_mclass
(mclassdefs
: Collection[MClassDef]): Map[MClass, Set[MClassDef]] do
987 var map
= new HashMap[MClass, Set[MClassDef]]
988 for mclassdef
in mclassdefs
do
989 var mclass
= mclassdef
.mclass
990 if not map
.has_key
(mclass
) then map
[mclass
] = new HashSet[MClassDef]
991 map
[mclass
].add mclassdef
998 # Display a list properties defined or redefined for this class
1002 private var mclass
: MClass
1003 private var concerns
: ConcernsTree
1004 private var mprops2mdefs
: Map[MProperty, Set[MPropDef]]
1005 private var mmodules2mprops
: Map[MModule, Set[MProperty]]
1007 init(mclass
: MClass, ctx
: NitdocContext) do
1008 self.mclass
= mclass
1010 var mpropdefs
= new HashSet[MPropDef]
1011 mpropdefs
.add_all mclass
.intro_mpropdefs
(ctx
.min_visibility
)
1012 mpropdefs
.add_all mclass
.redef_mpropdefs
(ctx
.min_visibility
)
1013 self.mprops2mdefs
= sort_by_mproperty
(mpropdefs
)
1014 self.mmodules2mprops
= sort_by_mmodule
(mprops2mdefs
.keys
)
1015 self.concerns
= model
.concerns_tree
(mmodules2mprops
.keys
)
1016 self.concerns
.sort_with
(new MConcernRankSorter)
1019 private var page
= new TplPage
1020 redef fun tpl_page
do return page
1022 private var sidebar
= new TplSidebar
1023 redef fun tpl_sidebar
do return sidebar
1025 redef fun tpl_title
do return "{mclass.nitdoc_name}{mclass.tpl_signature.write_to_string}"
1027 redef fun tpl_topmenu
do
1029 var mproject
= mclass
.intro_mmodule
.mgroup
.mproject
1030 topmenu
.add_item
(new TplLink("index.html", "Overview"), false)
1031 topmenu
.add_item
(new TplLink("{mproject.nitdoc_url}", "{mproject.nitdoc_name}"), false)
1032 topmenu
.add_item
(new TplLink("#", "{mclass.nitdoc_name}"), true)
1033 topmenu
.add_item
(new TplLink("search.html", "Index"), false)
1037 # Property list to display in sidebar
1038 fun tpl_sidebar_properties
do
1039 var kind_map
= sort_by_kind
(mclass_inherited_mprops
)
1040 var summary
= new TplList.with_classes
(["list-unstyled"])
1042 tpl_sidebar_list
("Virtual types", kind_map
["type"].to_a
, summary
)
1043 tpl_sidebar_list
("Constructors", kind_map
["init"].to_a
, summary
)
1044 tpl_sidebar_list
("Methods", kind_map
["fun"].to_a
, summary
)
1045 tpl_sidebar
.boxes
.add
new TplSideBox.with_content
("All properties", summary
)
1048 private fun tpl_sidebar_list
(name
: String, mprops
: Array[MProperty], summary
: TplList) do
1049 if mprops
.is_empty
then return
1050 name_sorter
.sort
(mprops
)
1051 var entry
= new TplListItem.with_content
(name
)
1052 var list
= new TplList.with_classes
(["list-unstyled", "list-labeled"])
1053 for mprop
in mprops
do
1054 list
.add_li tpl_sidebar_item
(mprop
)
1057 summary
.elts
.add entry
1060 private fun tpl_sidebar_item
(mprop
: MProperty): Template do
1061 var classes
= mprop
.intro
.tpl_css_classes
.to_a
1062 if not mprops2mdefs
.has_key
(mprop
) then
1063 classes
.add
"inherit"
1064 var lnk
= new Template
1065 lnk
.add
new TplLabel.with_classes
(classes
)
1066 lnk
.add mprop
.intro
.tpl_link
1069 var defs
= mprops2mdefs
[mprop
]
1070 if defs
.has
(mprop
.intro
) then
1075 var lnk
= new Template
1076 lnk
.add
new TplLabel.with_classes
(classes
)
1077 lnk
.add mprop
.intro
.tpl_anchor
1081 private fun tpl_intro
: TplSection do
1082 var section
= new TplSection.with_title
("top", tpl_title
)
1083 section
.subtitle
= mclass
.intro
.tpl_declaration
1084 var article
= new TplArticle("comment")
1085 if mclass
.mdoc
!= null then
1086 article
.content
= mclass
.mdoc
.tpl_comment
1088 section
.add_child article
1092 private fun tpl_concerns
(parent
: TplSection) do
1094 var section
= new TplSection.with_title
("intro", "Introduction")
1095 section
.summary_title
= "Introduction"
1096 section
.add_child tpl_mclassdef_article
(mclass
.intro
)
1097 parent
.add_child section
1099 if concerns
.is_empty
then return
1100 parent
.add_child
new TplArticle.with_content
("concerns", "Concerns", concerns
.to_tpl
)
1103 private fun tpl_inheritance
(parent
: TplSection) do
1105 var hparents
= new HashSet[MClass]
1106 for c
in mclass
.in_hierarchy
(ctx
.mainmodule
).direct_greaters
do
1107 if c
.visibility
< ctx
.min_visibility
then continue
1112 var hancestors
= new HashSet[MClass]
1113 for c
in mclass
.in_hierarchy
(ctx
.mainmodule
).greaters
do
1114 if c
== mclass
then continue
1115 if c
.visibility
< ctx
.min_visibility
then continue
1116 if hparents
.has
(c
) then continue
1121 var hchildren
= new HashSet[MClass]
1122 for c
in mclass
.in_hierarchy
(ctx
.mainmodule
).direct_smallers
do
1123 if c
.visibility
< ctx
.min_visibility
then continue
1128 var hdescendants
= new HashSet[MClass]
1129 for c
in mclass
.in_hierarchy
(ctx
.mainmodule
).smallers
do
1130 if c
== mclass
then continue
1131 if c
.visibility
< ctx
.min_visibility
then continue
1132 if hchildren
.has
(c
) then continue
1137 var section
= new TplSection.with_title
("inheritance", "Inheritance")
1140 var mclasses
= new HashSet[MClass]
1141 mclasses
.add_all hancestors
1142 mclasses
.add_all hparents
1143 if hchildren
.length
< 10 then mclasses
.add_all hchildren
1144 if hdescendants
.length
< 10 then mclasses
.add_all hdescendants
1146 var graph
= tpl_dot
(mclasses
)
1147 if graph
!= null then section
.add_child graph
1150 if not hparents
.is_empty
then
1151 var lst
= hparents
.to_a
1152 name_sorter
.sort lst
1153 section
.add_child tpl_list
("parents", "Parents", lst
)
1157 if not hancestors
.is_empty
then
1158 var lst
= hancestors
.to_a
1159 name_sorter
.sort lst
1160 section
.add_child tpl_list
("ancestors", "Ancestors", lst
)
1164 if not hchildren
.is_empty
and hchildren
.length
< 15 then
1165 var lst
= hchildren
.to_a
1166 name_sorter
.sort lst
1167 section
.add_child tpl_list
("children", "Children", lst
)
1171 if not hdescendants
.is_empty
and hchildren
.length
< 15 then
1172 var lst
= hdescendants
.to_a
1173 name_sorter
.sort lst
1174 section
.add_child tpl_list
("descendants", "Descendants", lst
)
1177 parent
.add_child section
1180 private fun tpl_list
(id
: String, title
: String, elts
: Array[MClass]): TplArticle do
1181 var article
= new TplArticle.with_title
(id
, title
)
1182 var list
= new TplList.with_classes
(["list-unstyled", "list-definition"])
1183 for elt
in elts
do list
.elts
.add elt
.tpl_list_item
1184 article
.content
= list
1188 private fun tpl_properties
(parent
: TplSection) do
1189 var lst
= concerns
.to_a
1190 for mentity
in lst
do
1191 if mentity
isa MProject then
1192 parent
.add_child
new TplSection(mentity
.nitdoc_id
)
1193 else if mentity
isa MGroup then
1194 parent
.add_child
new TplSection(mentity
.nitdoc_id
)
1195 else if mentity
isa MModule then
1196 var section
= new TplSection(mentity
.nitdoc_id
)
1197 var title
= new Template
1199 title
.add mentity
.tpl_namespace
1200 section
.title
= title
1201 section
.summary_title
= "in {mentity.nitdoc_name}"
1204 var mprops
= mmodules2mprops
[mentity
]
1205 var kind_map
= sort_by_kind
(mprops
)
1208 var elts
= kind_map
["type"].to_a
1209 name_sorter
.sort
(elts
)
1211 var defs
= mprops2mdefs
[elt
].to_a
1212 section
.add_child tpl_mprop_article
(elt
, defs
)
1216 elts
= kind_map
["init"].to_a
1217 name_sorter
.sort
(elts
)
1219 var defs
= mprops2mdefs
[elt
].to_a
1220 section
.add_child tpl_mprop_article
(elt
, defs
)
1224 elts
= kind_map
["fun"].to_a
1225 name_sorter
.sort
(elts
)
1227 var defs
= mprops2mdefs
[elt
].to_a
1228 section
.add_child tpl_mprop_article
(elt
, defs
)
1230 parent
.add_child section
1235 redef fun tpl_content
do
1236 tpl_sidebar_properties
1238 tpl_inheritance
(top
)
1241 tpl_page
.add_section top
1244 private fun sort_by_mproperty
(mpropdefs
: Collection[MPropDef]): Map[MProperty, Set[MPropDef]] do
1245 var map
= new HashMap[MProperty, Set[MPropDef]]
1246 for mpropdef
in mpropdefs
do
1247 var mproperty
= mpropdef
.mproperty
1248 if not map
.has_key
(mproperty
) then map
[mproperty
] = new HashSet[MPropDef]
1249 map
[mproperty
].add mpropdef
1254 private fun sort_by_mmodule
(mprops
: Collection[MProperty]): Map[MModule, Set[MProperty]] do
1255 var map
= new HashMap[MModule, Set[MProperty]]
1256 for mprop
in mprops
do
1257 var mpropdefs
= mprops2mdefs
[mprop
].to_a
1258 ctx
.mainmodule
.linearize_mpropdefs
(mpropdefs
)
1259 var mmodule
= mpropdefs
.first
.mclassdef
.mmodule
1260 if not map
.has_key
(mmodule
) then map
[mmodule
] = new HashSet[MProperty]
1261 map
[mmodule
].add mprop
1266 private fun sort_by_kind
(mprops
: Collection[MProperty]): Map[String, Set[MProperty]] do
1267 var map
= new HashMap[String, Set[MProperty]]
1268 map
["type"] = new HashSet[MProperty]
1269 map
["init"] = new HashSet[MProperty]
1270 map
["fun"] = new HashSet[MProperty]
1271 for mprop
in mprops
do
1272 if mprop
isa MVirtualTypeProp then
1273 map
["type"].add mprop
1274 else if mprop
isa MMethod then
1275 if mprop
.is_init
then
1276 map
["init"].add mprop
1278 map
["fun"].add mprop
1285 private fun mclass_inherited_mprops
: Set[MProperty] do
1286 var res
= new HashSet[MProperty]
1287 var local
= mclass
.local_mproperties
(ctx
.min_visibility
)
1288 for mprop
in mclass
.inherited_mproperties
(ctx
.mainmodule
, ctx
.min_visibility
) do
1289 if local
.has
(mprop
) then continue
1290 #if mprop isa MMethod and mprop.is_init then continue
1291 if mprop
.intro
.mclassdef
.mclass
.name
== "Object" and
1292 (mprop
.visibility
== protected_visibility
or
1293 mprop
.intro
.mclassdef
.mmodule
.name
!= "kernel") then continue
1300 private fun collect_mmodules
(mprops
: Collection[MProperty]): Set[MModule] do
1301 var res
= new HashSet[MModule]
1302 for mprop
in mprops
do
1303 if mprops2mdefs
.has_key
(mprop
) then
1304 for mpropdef
in mprops2mdefs
[mprop
] do res
.add mpropdef
.mclassdef
.mmodule
1310 private fun sort_by_public_owner
(mmodules
: Collection[MModule]): Map[MModule, Set[MModule]] do
1311 var map
= new HashMap[MModule, Set[MModule]]
1312 for mmodule
in mmodules
do
1314 if mmodule
.public_owner
!= null then owner
= mmodule
.public_owner
.as(not null)
1315 if not map
.has_key
(owner
) then map
[owner
] = new HashSet[MModule]
1316 map
[owner
].add mmodule
1321 # Generate dot hierarchy for classes
1322 fun tpl_dot
(mclasses
: Collection[MClass]): nullable TplArticle do
1323 var poset
= new POSet[MClass]
1325 for mclass
in mclasses
do
1326 poset
.add_node mclass
1327 for oclass
in mclasses
do
1328 poset
.add_node oclass
1329 if mclass
.in_hierarchy
(ctx
.mainmodule
) < oclass
then
1330 poset
.add_edge
(mclass
, oclass
)
1335 var op
= new FlatBuffer
1336 var name
= "dep_{mclass.name}"
1337 op
.append
("digraph {name} \{ rankdir=BT; node[shape=none,margin=0,width=0,height=0,fontsize=10]; edge[dir=none,color=gray]; ranksep=0.2; nodesep=0.1;\n")
1340 op
.append
("\"{c.name}\
"[shape=box,margin=0.03];\n")
1342 op
.append
("\"{c.name}\
"[URL=\"{c.nitdoc_url}\
"];\n")
1344 for c2
in poset
[c
].direct_greaters
do
1345 op
.append
("\"{c.name}\
"->\"{c2.name}\
";\n")
1349 return tpl_graph
(op
, name
, null)
1354 class NitdocProperty
1357 private var mproperty
: MProperty
1358 private var concerns
: ConcernsTree
1359 private var mmodules2mdefs
: Map[MModule, Set[MPropDef]]
1361 init(mproperty
: MProperty, ctx
: NitdocContext) do
1362 self.mproperty
= mproperty
1364 self.mmodules2mdefs
= sort_by_mmodule
(collect_mpropdefs
)
1365 self.concerns
= model
.concerns_tree
(mmodules2mdefs
.keys
)
1366 self.concerns
.sort_with
(new MConcernRankSorter)
1369 private fun collect_mpropdefs
: Set[MPropDef] do
1370 var res
= new HashSet[MPropDef]
1371 for mpropdef
in mproperty
.mpropdefs
do
1372 if not mpropdef
.is_intro
then res
.add mpropdef
1377 private var page
= new TplPage
1378 redef fun tpl_page
do return page
1380 private var sidebar
= new TplSidebar
1381 redef fun tpl_sidebar
do return sidebar
1383 redef fun tpl_title
do
1384 return "{mproperty.nitdoc_name}{mproperty.tpl_signature.write_to_string}"
1387 redef fun tpl_topmenu
do
1389 var mmodule
= mproperty
.intro_mclassdef
.mmodule
1390 var mproject
= mmodule
.mgroup
.mproject
1391 var mclass
= mproperty
.intro_mclassdef
.mclass
1392 topmenu
.add_item
(new TplLink("index.html", "Overview"), false)
1393 topmenu
.add_item
(new TplLink("{mproject.nitdoc_url}", "{mproject.nitdoc_name}"), false)
1394 topmenu
.add_item
(new TplLink("{mclass.nitdoc_url}", "{mclass.nitdoc_name}"), false)
1395 topmenu
.add_item
(new TplLink("#", "{mproperty.nitdoc_name}"), true)
1396 topmenu
.add_item
(new TplLink("search.html", "Index"), false)
1400 private fun tpl_intro
: TplSection do
1401 var section
= new TplSection.with_title
("top", tpl_title
)
1402 section
.subtitle
= mproperty
.tpl_declaration
1403 var article
= new TplArticle("comment")
1404 if mproperty
.intro
.mdoc
!= null then
1405 article
.content
= mproperty
.intro
.mdoc
.tpl_comment
1407 section
.add_child article
1411 private fun tpl_properties
(parent
: TplSection) do
1413 var section
= new TplSection.with_title
("intro", "Introduction")
1414 section
.summary_title
= "Introduction"
1415 section
.add_child tpl_mpropdef_article
(mproperty
.intro
)
1416 parent
.add_child section
1419 if concerns
.is_empty
then return
1420 parent
.add_child
new TplArticle.with_content
("Concerns", "Concerns", concerns
.to_tpl
)
1423 var lst
= concerns
.to_a
1424 for mentity
in lst
do
1425 if mentity
isa MProject then
1426 parent
.add_child
new TplSection(mentity
.nitdoc_id
)
1427 else if mentity
isa MGroup then
1428 parent
.add_child
new TplSection(mentity
.nitdoc_id
)
1429 else if mentity
isa MModule then
1430 var ssection
= new TplSection(mentity
.nitdoc_id
)
1431 var title
= new Template
1433 title
.add mentity
.tpl_namespace
1434 ssection
.title
= title
1435 ssection
.summary_title
= "in {mentity.nitdoc_name}"
1438 var mpropdefs
= mmodules2mdefs
[mentity
].to_a
1439 name_sorter
.sort
(mpropdefs
)
1440 for mpropdef
in mpropdefs
do
1441 ssection
.add_child tpl_mpropdef_article
(mpropdef
)
1443 parent
.add_child ssection
1448 redef fun tpl_content
do
1451 tpl_page
.add_section top
1454 private fun sort_by_mmodule
(mpropdefs
: Collection[MPropDef]): Map[MModule, Set[MPropDef]] do
1455 var map
= new HashMap[MModule, Set[MPropDef]]
1456 for mpropdef
in mpropdefs
do
1457 var mmodule
= mpropdef
.mclassdef
.mmodule
1458 if not map
.has_key
(mmodule
) then map
[mmodule
] = new HashSet[MPropDef]
1459 map
[mmodule
].add mpropdef