# TODO this should move to MEntity?
private fun build_mmodule_list(v: IntroRedefListPhase, doc: DocModel, mmodule: MModule) do
- var section = new IntrosRedefsSection(mentity)
- var group = new PanelGroup("List")
+ var section = new TabbedGroup("{mentity.nitdoc_id}.intros_redefs")
+ section.toc_title = "Intros / Redefs"
+ var group = new PanelGroup("list.group", "List")
- var intros = mmodule.intro_mclassdefs(v.ctx.min_visibility).to_a
+ var intros = mmodule.collect_intro_mclassdefs(v.ctx.min_visibility).to_a
doc.mainmodule.linearize_mclassdefs(intros)
- group.add_child new IntrosRedefsListArticle(mentity, "Introduces", intros)
+ group.add_child new MEntitiesListArticle("{mentity.nitdoc_id}.intros", "Introduces", intros)
- var redefs = mmodule.redef_mclassdefs(v.ctx.min_visibility).to_a
+ var redefs = mmodule.collect_redef_mclassdefs(v.ctx.min_visibility).to_a
doc.mainmodule.linearize_mclassdefs(redefs)
- group.add_child new IntrosRedefsListArticle(mentity, "Redefines", redefs)
+ group.add_child new MEntitiesListArticle("{mentity.nitdoc_id}.redefs", "Redefines", redefs)
section.add_child group
add_child(section)
end
# List of mproperties to display.
var mprops: Array[MProperty]
+
+ redef fun is_hidden do
+ return mmodules.is_empty and mclasses.is_empty and mprops.is_empty
+ end
end
+
+ # Concerns ranking
+
+ # Sort MConcerns based on the module importation hierarchy ranking
+ # see also: `MConcern::concern_rank` and `MConcern::booster_rank`
+ #
+ # Comparison is made with the formula:
+ #
+ # ~~~nitish
+ # a.concern_rank + a.booster_rank <=> b.concern_rank + b.booster_ran
+ # ~~~
+ #
+ # If both `a` and `b` have the same ranking,
+ # ordering is based on lexicographic comparison of `a.name` and `b.name`
+ class MConcernRankSorter
+ super Comparator
+ redef type COMPARED: MConcern
+
+ redef fun compare(a, b) do
+ if a.concern_rank == b.concern_rank then
+ return a.name <=> b.name
+ end
+ return a.concern_rank + a.booster_rank <=> b.concern_rank + b.booster_rank
+ end
+ end
+
+ redef class MConcern
+
+ # Boost a MConcern rank
+ # see: `MConcernRankSorter`
+ # Use a positive booster to push down a result in the list
+ # A negative booster can be used to push up the result
+ var booster_rank: Int = 0 is writable
+
+ # Concern ranking used for ordering
+ # see: `MConcernRankSorter`
+ # Rank can be positive or negative
+ fun concern_rank: Int is abstract
+ end
+
+ redef class MProject
+ redef var concern_rank is lazy do
+ var max = 0
+ for mgroup in mgroups do
+ var mmax = mgroup.concern_rank
+ if mmax > max then max = mmax
+ end
+ return max + 1
+ end
+ end
+
+ redef class MGroup
+ redef var concern_rank is lazy do
+ var max = 0
+ for mmodule in mmodules do
+ var mmax = mmodule.concern_rank
+ if mmax > max then max = mmax
+ end
+ return max + 1
+ end
+ end
+
+ redef class MModule
+ redef var concern_rank is lazy do
+ var max = 0
+ for p in in_importation.direct_greaters do
+ var pmax = p.concern_rank
+ if pmax > max then max = pmax
+ end
+ return max + 1
+ end
+ end