# (HTML links, HTML anchors, vim links, etc.).
var id: String is writable
+ # Item title if any.
+ var title: nullable String
+
# Does `self` have a `parent`?
fun is_root: Bool do return parent == null
super DocComposite
redef var id = "<root>"
+ redef var title = "<root>"
+
# No op for `RootSection`.
redef fun parent=(p) do end
end
# Pretty prints the results for the console.
fun make_results(nitx: Nitx, results: Array[NitxMatch]): DocPage do
var page = new DocPage("results", "Results")
- page.root.add_child(new QueryResultArticle("results.article", self, results))
+ page.root.add_child(new QueryResultArticle("results.article", "Results", self, results))
return page
end
var res = results.first.as(MEntityMatch)
var mentity = res.mentity
var page = new DocPage("results", "Results")
- var article = new DefinitionArticle("results.article", mentity)
+ var article = new DefinitionArticle("results.article", "Results", mentity)
article.cs_title = mentity.name
article.cs_subtitle = mentity.cs_declaration
page.root.add_child article
redef fun make_results(nitx, results) do
var page = new DocPage("results", "Code Results")
for res in results do
- page.add new CodeQueryArticle("results.article", self, res.as(CodeMatch))
+ page.add new CodeQueryArticle("results.article", "Results", self, res.as(CodeMatch))
end
return page
end
end
end
op.append("\}\n")
- return new GraphArticle("{mentity.nitdoc_id}.graph", mentity, name, "Importation Graph", op)
+ return new GraphArticle("{mentity.nitdoc_id}.graph", "Importation Graph", name, op)
end
end
end
end
op.append("\}\n")
- return new GraphArticle("{mentity.nitdoc_id}.graph", mentity, name, "Inheritance Graph", op)
+ return new GraphArticle("{mentity.nitdoc_id}.graph", "Inheritance Graph", name, op)
end
end
# The graph is stored in dot format.
# The final output is delayed untill rendering.
class GraphArticle
- super MEntityComposite
+ super DocArticle
# Graph ID (used for outputing file with names).
var graph_id: String
- # Graph title to display.
- var graph_title: String
-
# Dot script of the graph.
var dot: Text
var group = new PanelGroup("list.group", "List")
var imports = self.imports.to_a
v.name_sorter.sort(imports)
- group.add_child new HierarchyListArticle("{id}.imports", mentity, "Imports", imports)
+ group.add_child new HierarchyListArticle("{id}.imports", "Imports", imports)
var clients = self.clients.to_a
v.name_sorter.sort(clients)
- group.add_child new HierarchyListArticle("{id}.clients", mentity, "Clients", clients)
+ group.add_child new HierarchyListArticle("{id}.clients", "Clients", clients)
section.add_child group
section.parent = root.children.first
root.children.first.children.insert(section, 1)
var group = new PanelGroup("list.group", "List")
var parents = self.parents.to_a
v.name_sorter.sort(parents)
- group.add_child new HierarchyListArticle("{id}.parents", mentity, "Parents", parents)
+ group.add_child new HierarchyListArticle("{id}.parents", "Parents", parents)
var ancestors = self.ancestors.to_a
v.name_sorter.sort(ancestors)
- group.add_child new HierarchyListArticle("{id}.ancestors", mentity, "Ancestors", ancestors)
+ group.add_child new HierarchyListArticle("{id}.ancestors", "Ancestors", ancestors)
var children = self.children.to_a
v.name_sorter.sort(children)
- group.add_child new HierarchyListArticle("{id}.children", mentity, "Children", children)
+ group.add_child new HierarchyListArticle("{id}.children", "Children", children)
var descendants = self.descendants.to_a
v.name_sorter.sort(descendants)
- group.add_child new HierarchyListArticle("{id}.descendants", mentity, "Descendants", descendants)
+ group.add_child new HierarchyListArticle("{id}.descendants", "Descendants", descendants)
section.add_child group
section.parent = root.children.first
root.children.first.children.insert(section, 1)
# Dislay a hierarchical list of mentities.
class HierarchyListArticle
- super MEntityArticle
-
- # Title displayed in the top of this list.
- var list_title: String
+ super DocArticle
# MEntities to display in this list.
var mentities: Array[MEntity]
var group = new PanelGroup("list.group", "List")
var intros = mmodule.collect_intro_mclassdefs(v.ctx.min_visibility).to_a
doc.mainmodule.linearize_mclassdefs(intros)
- group.add_child new IntrosRedefsListArticle("{mentity.nitdoc_id}.intros", mentity, "Introduces", intros)
+ group.add_child new IntrosRedefsListArticle("{mentity.nitdoc_id}.intros", "Introduces", intros)
var redefs = mmodule.collect_redef_mclassdefs(v.ctx.min_visibility).to_a
doc.mainmodule.linearize_mclassdefs(redefs)
- group.add_child new IntrosRedefsListArticle("{mentity.nitdoc_id}.redefs", mentity, "Redefines", redefs)
+ group.add_child new IntrosRedefsListArticle("{mentity.nitdoc_id}.redefs", "Redefines", redefs)
section.add_child group
add_child(section)
end
var intros = mclassdef.collect_intro_mpropdefs(v.ctx.min_visibility).to_a
# FIXME avoid diff changes
# v.ctx.mainmodule.linearize_mpropdefs(intros)
- group.add_child new IntrosRedefsListArticle("{mentity.nitdoc_id}.intros", mentity, "Introduces", intros)
+ group.add_child new IntrosRedefsListArticle("{mentity.nitdoc_id}.intros", "Introduces", intros)
var redefs = mclassdef.collect_redef_mpropdefs(v.ctx.min_visibility).to_a
# FIXME avoid diff changes
# v.ctx.mainmodule.linearize_mpropdefs(redefs)
- group.add_child new IntrosRedefsListArticle("{mentity.nitdoc_id}.redefs", mentity, "Redefines", redefs)
+ group.add_child new IntrosRedefsListArticle("{mentity.nitdoc_id}.redefs", "Redefines", redefs)
section.add_child group
add_child(section)
end
# FIXME diff hack
# This can merged with InheritanceListArticle in a more generic class.
class IntrosRedefsListArticle
- super MEntityArticle
-
- # Title displayed as header of the list.
- var list_title: String
+ super DocArticle
# Intro mentities to list.
var mentities: Array[MEntity]
redef class OverviewPage
redef fun apply_structure(v, doc) do
- var article = new HomeArticle("home.article")
+ var article = new HomeArticle("home.article", "Home")
root.add_child article
# Projects list
var mprojects = doc.model.mprojects.to_a
var sorter = new MConcernRankSorter
sorter.sort mprojects
- var section = new ProjectsSection("projects.section")
+ var section = new ProjectsSection("projects.section", "Projects")
for mproject in mprojects do
section.add_child new DefinitionArticle("{mproject.nitdoc_id}.definition", mproject)
end
# A group of sections that can be displayed together in a tab panel.
class PanelGroup
super DocSection
-
- # The title of this group.
- var group_title: String
end
# A DocComposite element about a MEntity.
class MEntityComposite
super DocComposite
+ redef fun title do return mentity.nitdoc_name
+
# MEntity documented by this page element.
var mentity: MEntity
end
# Title to display if any.
#
# This title can be decorated with HTML.
- var html_title: nullable Writable is noinit, writable
+ var html_title: nullable Writable is writable, lazy do return title
# Subtitle to display if any.
var html_subtitle: nullable Writable is noinit, writable
end
end
+redef class DocRoot
+ redef fun rendering do
+ for child in children do addn child.write_to_string
+ end
+end
+
redef class DocSection
super BSComponent
redef class PanelGroup
redef var html_title = null
- redef var toc_title is lazy do return group_title
+ redef var toc_title is lazy do return title or else ""
redef var is_toc_hidden = true
end
end
redef class HierarchyListArticle
- redef var html_title is lazy do return list_title
redef fun is_empty do return mentities.is_empty
redef var is_toc_hidden = true
end
redef class IntrosRedefsListArticle
- redef var html_title is lazy do return list_title
redef fun is_hidden do return mentities.is_empty
redef var is_toc_hidden = true
redef fun render_body do
addn "<div class=\"text-center\">"
addn " <img src='{graph_id}.png' usemap='#{graph_id}' style='margin:auto'"
- addn " alt='{graph_title}'/>"
+ addn " alt='{title or else ""}'/>"
add map
addn "</div>"
end