+
+ # Does `self` display only it's title and no body?
+ #
+ # FIXME diff hack
+ var is_no_body: Bool = false is writable
+
+ # Does `self` display only the short content as definition?
+ #
+ # FIXME diff hack
+ var is_short_comment: Bool = false is writable
+
+ # Link to source to display if any.
+ var html_source_link: nullable Writable is noinit, writable
+
+ redef fun render_body do
+ var tabs = new DocTabs("{html_id}.tabs", "")
+ if not is_no_body then
+ var comment
+ if is_short_comment or mentity isa MPackage then
+ comment = mentity.html_synopsis
+ else
+ comment = mentity.html_documentation
+ end
+ if comment != null then
+ tabs.add_panel new DocTabPanel("{html_tab_id}-comment", "Comment", comment)
+ end
+ end
+ for child in children do
+ if child.is_hidden then continue
+ var title = child.html_toc_title or else child.toc_title or else ""
+ tabs.add_panel new DocTabPanel(child.html_tab_id, title, child)
+ end
+ var lnk = html_source_link
+ if lnk != null then
+ tabs.drop_list.items.add new ListItem(lnk)
+ end
+ addn tabs
+ end
+end
+
+redef class MEntitiesListArticle
+ redef fun render_body do
+ var lst = new UnorderedList
+ lst.css_classes.add "list-unstyled list-definition"
+ for mentity in mentities do
+ lst.add_li mentity.html_list_item
+ end
+ add lst
+ end
+end
+
+redef class DefinitionLinArticle
+ redef fun render_body do
+ var lst = new UnorderedList
+ lst.css_classes.add "list-unstyled list-labeled"
+ for mentity in mentities do
+ if not mentity isa MPropDef then continue # TODO handle all mentities
+ var tpl = new Template
+ tpl.add mentity.mclassdef.html_namespace
+ var comment = mentity.mclassdef.html_synopsis
+ if comment != null then
+ tpl.add ": "
+ tpl.add comment
+ end
+ var li = new ListItem(tpl)
+ li.css_classes.add "signature"
+ lst.add_li li
+ end
+ add lst
+ end
+end
+
+redef class GraphArticle
+ redef var html_title = null
+
+ # Graph in SVG with clickable map.
+ #
+ # This attribute is set by the `doc_render` phase who knows the context.
+ var svg: nullable String = null is writable
+
+ redef fun render_body do
+ addn "<div class=\"text-center\">"
+ var svg = self.svg
+ if svg != null then add svg
+ addn "</div>"
+ end
+end
+
+redef class ReadmeSection
+ redef var html_id is lazy do
+ return markdown_processor.emitter.decorator.strip_id(html_title.as(not null).to_s)
+ end
+
+ redef var html_title is lazy do
+ return markdown_processor.process(title.as(not null))
+ end
+end
+
+redef class ReadmeArticle
+ redef var html_id = ""
+ redef var html_title = null
+ redef var is_toc_hidden = true
+
+ redef fun render_body do
+ add markdown_processor.process(md.trim.write_to_string)
+ end
+end
+
+redef class DocumentationArticle
+ redef var html_title is lazy do
+ var synopsis = mentity.html_synopsis
+ if synopsis == null then return mentity.html_link
+ return "{mentity.html_link.write_to_string} – {synopsis.write_to_string}"
+ end
+
+ redef var html_subtitle is lazy do return null
+ redef var html_toc_title is lazy do return mentity.html_name
+ redef var is_toc_hidden is lazy do return depth > 3