From a8ac388b632f24dbb4a93be2d46b726bd5636e80 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Fri, 19 Jul 2013 18:27:16 -0400 Subject: [PATCH] ni_nitdoc: better formal type display Signed-off-by: Alexandre Terrasa --- src/ni_nitdoc.nit | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/src/ni_nitdoc.nit b/src/ni_nitdoc.nit index 8b6a8e5..d05eab7 100644 --- a/src/ni_nitdoc.nit +++ b/src/ni_nitdoc.nit @@ -590,7 +590,6 @@ class NitdocModule append("

Classes

") append("") @@ -808,7 +807,7 @@ class NitdocClass fun class_doc do # title - append("

{mclass.to_s}

") + append("

{mclass.html_signature}

") append("
") var subtitle = "" if mclass.visibility is none_visibility then subtitle += "private " @@ -859,13 +858,10 @@ class NitdocClass append("
") append("

Formal and Virtual Types

") if mclass.virtual_types.length > 0 then for prop in mclass.virtual_types do description(prop) - #TODO this is incorrect if mclass.arity > 0 and nclass isa AStdClassdef then - for prop in nclass.n_formaldefs do - append("
") - append("

{prop.collect_text}: nullable ") - append("Object") - append("

") + for ft, bound in mclass.parameter_types do + append("
") + append("

{ft}: {bound.link(mbuilder)}

") append("
formal generic type
") append("
") end @@ -905,10 +901,9 @@ class NitdocClass sorterc.sort(sortedc) append("

Inherited Methods

") for imclass in sortedc do - var inclass = mbuilder.mclassdef2nclassdef[imclass.intro].as(AStdClassdef) var sortedp = mclass.inherited[imclass].to_a sorterprop.sort(sortedp) - append("

Defined in {imclass.link(inclass)}: ") + append("

Defined in {imclass.link(mbuilder)}: ") for method in sortedp do #TODO link to inherited propdef append("{method.name}") @@ -1153,8 +1148,17 @@ redef class MClass end # Return a link (html a tag) to the nitdoc class page - fun link(aclass: AStdClassdef): String do - return "{html_signature}" + fun link(mbuilder: ModelBuilder): String do + if mbuilder.mclassdef2nclassdef.has_key(intro) then + var nclass = mbuilder.mclassdef2nclassdef[intro] + if nclass isa AStdClassdef then + return "{html_signature}" + else + return "{html_signature}" + end + else + return "{html_signature}" + end end # Associate all MMethods to each MModule concerns @@ -1292,13 +1296,27 @@ redef class AParam end end +redef class MType + fun link(mbuilder: ModelBuilder): String is abstract +end + +redef class MClassType + redef fun link(mbuilder) do return mclass.link(mbuilder) +end + +redef class MNullableType + redef fun link(mbuilder) do return "nullable {mtype.link(mbuilder)}" +end + redef class AType - redef fun to_s do + fun link: String do var ret = "{n_id.text}" if n_kwnullable != null then ret = "nullable {ret}" if not n_types.is_empty then ret = "{ret}[{n_types.join(", ")}]" return ret end + + fun name: String do return n_id.text.html_escape end redef class APropdef -- 1.7.9.5