var ssection = new TplSection.with_title("projects", "Projects")
for mproject in mprojects do
var sarticle = mproject.tpl_article
- sarticle.subtitle = mproject.tpl_declaration
+ sarticle.subtitle = mproject.html_declaration
sarticle.content = mproject.tpl_definition
var mdoc = mproject.mdoc_or_fallback
if mdoc != null then
var section = new TplSection("top")
var mentity = page.mentity
section.title = mentity.html_name
- section.subtitle = mentity.tpl_declaration
+ section.subtitle = mentity.html_declaration
# FIXME ugly hack to avoid diff
if mentity isa MGroup and mentity.is_root then
section.title = mentity.mproject.html_name
- section.subtitle = mentity.mproject.tpl_declaration
+ section.subtitle = mentity.mproject.html_declaration
else if mentity isa MProperty then
section.title = "{mentity.html_name}{mentity.intro.tpl_signature.write_to_string}"
section.subtitle = mentity.tpl_namespace
else if mentity isa MPropDef then
article.source_link = v.tpl_showsource(mentity.location)
end
- # article.subtitle = mentity.tpl_declaration
+ # article.subtitle = mentity.html_declaration
# FIXME diff hack
if mentity isa MProperty then
# intro title
# FIXME hideous hacks...
if mentity isa MModule then
article = mentity.tpl_article
- article.subtitle = mentity.tpl_declaration
+ article.subtitle = mentity.html_declaration
article.content = mentity.tpl_definition
else if mentity isa MClass then
article = make_mclass_article(v, page)
article = make_mpropdef_article(v, doc, page)
else
article = mentity.tpl_article
- article.subtitle = mentity.tpl_declaration
+ article.subtitle = mentity.html_declaration
if mentity isa MPropDef then
article.source_link = v.tpl_showsource(mentity.location)
end
return tpl
end
+ # Returns the list of keyword used in `self` declaration.
+ fun html_modifiers: Array[String] is abstract
+
+ # Returns the complete MEntity declaration decorated with HTML.
+ #
+ # * MProject: `project foo`
+ # * MGroup: `group foo`
+ # * MModule: `module foo`
+ # * MClass: `private abstract class Foo[E: Object]`
+ # * MClassDef: `redef class Foo[E]`
+ # * MProperty: `private fun foo(e: Object): Int`
+ # * MPropdef: `redef fun foo(e)`
+ fun html_declaration: Template do
+ var tpl = new Template
+ tpl.add "<span>"
+ tpl.add html_modifiers.join(" ")
+ tpl.add " "
+ tpl.add html_link
+ tpl.add "</span>"
+ return tpl
+ end
+
# A template article that briefly describe the entity
fun tpl_short_article: TplArticle do
var tpl = tpl_article
return tpl
end
- # A template signature that contains modifiers and parameters
- fun tpl_declaration: Template is abstract
-
# A template namespace
fun tpl_namespace: Template is abstract
redef class MProject
redef var nitdoc_id = name.to_cmangle is lazy
redef fun nitdoc_url do return root.nitdoc_url
-
- redef fun tpl_declaration do
- var tpl = new Template
- tpl.add "<span>project "
- tpl.add html_link
- tpl.add "</span>"
- return tpl
- end
+ redef var html_modifiers = ["project"]
redef fun tpl_namespace do return html_link
end
redef fun nitdoc_url do return "group_{nitdoc_id}.html"
+ redef var html_modifiers = ["group"]
redef fun tpl_namespace do
var tpl = new Template
return tpl
end
- redef fun tpl_declaration do
- var tpl = new Template
- tpl.add "<span>group "
- tpl.add html_link
- tpl.add "</span>"
- return tpl
- end
-
redef fun tpl_definition do
var tpl = new TplDefinition
var mdoc = mdoc_or_fallback
end
redef fun nitdoc_url do return "module_{nitdoc_id}.html"
-
- redef fun tpl_declaration do
- var tpl = new Template
- tpl.add "<span>module "
- tpl.add tpl_namespace
- tpl.add "</span>"
- return tpl
- end
+ redef var html_modifiers = ["module"]
redef fun tpl_namespace do
var tpl = new Template
return tpl.write_to_string
end
- redef fun tpl_declaration do return intro.tpl_declaration
+ redef fun html_modifiers do return intro.html_modifiers
+ redef fun html_declaration do return intro.html_declaration
+
redef fun tpl_definition do return intro.tpl_definition
redef fun tpl_namespace do
redef class MClassDef
redef var nitdoc_id = "{mmodule.nitdoc_id}__{name.to_cmangle}" is lazy
redef fun nitdoc_url do return "{mclass.nitdoc_url}#{nitdoc_id}"
-
redef fun mdoc_or_fallback do return mdoc or else mclass.mdoc_or_fallback
+ # Depends if `self` is an intro or not.
+ #
+ # * If intro contains the visibility and kind.
+ # * If redef contains the `redef` keyword and kind.
+ redef fun html_modifiers do
+ var res = new Array[String]
+ if not is_intro then
+ res.add "redef"
+ else
+ if mclass.visibility != public_visibility then
+ res.add mclass.visibility.to_s
+ end
+ end
+ res.add mclass.kind.to_s
+ return res
+ end
+
+ # Depends if `self` is an intro or not.
+ #
+ # For intro: `private abstract class Foo[E: Object]`
+ # For redef: `redef class Foo[E]`
+ # TODO change the implementation to correspond to the comment.
+ redef fun html_declaration do
+ var tpl = new Template
+ tpl.add "<span>"
+ tpl.add html_modifiers.join(" ")
+ tpl.add " "
+ tpl.add html_link
+ tpl.add tpl_signature
+ tpl.add "</span>"
+ return tpl
+ end
+
redef fun tpl_namespace do
var tpl = new Template
tpl.add mmodule.tpl_namespace
redef fun tpl_article do
var tpl = new TplArticle(nitdoc_id)
tpl.summary_title = "in {mmodule.html_name}"
- tpl.title = tpl_declaration
+ tpl.title = html_declaration
tpl.title_classes.add "signature"
var title = new Template
title.add "in "
return title
end
- redef fun tpl_declaration do
- var tpl = new Template
- tpl.add tpl_modifiers
- tpl.add html_link
- tpl.add tpl_signature
- return tpl
- end
-
fun tpl_signature: Template do
var tpl = new Template
var mparameters = mclass.mparameters
redef class MProperty
redef var nitdoc_id = "{intro_mclassdef.mclass.nitdoc_id}__{name.to_cmangle}" is lazy
redef fun nitdoc_url do return "property_{nitdoc_id}.html"
-
redef fun mdoc_or_fallback do return intro.mdoc
+ redef fun html_modifiers do return intro.html_modifiers
+ redef fun html_declaration do return intro.html_declaration
redef fun tpl_namespace do
var tpl = new Template
return tpl
end
- redef fun tpl_declaration do return intro.tpl_declaration
-
fun tpl_signature: Template do return new Template
redef fun tpl_title do return intro.tpl_title
redef class MPropDef
redef var nitdoc_id = "{mclassdef.nitdoc_id}__{name.to_cmangle}" is lazy
redef fun nitdoc_url do return "{mproperty.nitdoc_url}#{nitdoc_id}"
-
redef fun mdoc_or_fallback do return mdoc or else mproperty.mdoc_or_fallback
+ # Depends if `self` is an intro or not.
+ #
+ # * If intro contains the visibility and kind.
+ # * If redef contains the `redef` keyword and kind.
+ redef fun html_modifiers do
+ var res = new Array[String]
+ if not is_intro then
+ res.add "redef"
+ else
+ if mproperty.visibility != public_visibility then
+ res.add mproperty.visibility.to_s
+ end
+ end
+ return res
+ end
+
+ # Depends if `self` is an intro or not.
+ #
+ # For intro: `private fun foo(e: Object): Bar is abstract`
+ # For redef: `redef fun foo(e) is cached`
+ # TODO change the implementation to correspond to the comment.
+ redef fun html_declaration do
+ var tpl = new Template
+ tpl.add "<span>"
+ tpl.add html_modifiers.join(" ")
+ tpl.add " "
+ tpl.add html_link
+ tpl.add tpl_signature
+ tpl.add "</span>"
+ return tpl
+ end
+
redef fun tpl_namespace do
var tpl = new Template
tpl.add mclassdef.tpl_namespace
title.add "in "
title.add mclassdef.html_link
tpl.title = title
- tpl.subtitle = tpl_declaration
+ tpl.subtitle = html_declaration
var mdoc = mdoc_or_fallback
if mdoc != null then
tpl.content = mdoc.tpl_comment
return tpl
end
- redef fun tpl_declaration do
- var tpl = new Template
- tpl.add tpl_modifiers
- tpl.add html_link
- tpl.add tpl_signature
- return tpl
- end
-
redef fun tpl_css_classes do
var set = new HashSet[String]
if is_intro then set.add "intro"
end
redef class MAttributeDef
+
+ redef fun html_modifiers do
+ var res = super
+ res.add "var"
+ return res
+ end
+
redef fun tpl_signature do
var tpl = new Template
if static_mtype != null then
end
redef class MMethodDef
+
+ # FIXME annotation should be handled in their own way
+ redef fun html_modifiers do
+ var res = super
+ if is_abstract then
+ res.add "abstract"
+ else if is_intern then
+ res.add "intern"
+ end
+ if mproperty.is_init then
+ res.add "init"
+ else
+ res.add "fun"
+ end
+ return res
+ end
+
redef fun tpl_signature do return msignature.tpl_signature
end
end
redef class MVirtualTypeDef
+
+ redef fun html_modifiers do
+ var res = super
+ res.add "type"
+ return res
+ end
+
redef fun tpl_signature do
var tpl = new Template
if bound == null then return tpl