From 6b71ef06dc2c27b65ec9d7b11983402f5e0d90df Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Sat, 20 Jul 2013 23:27:32 -0400 Subject: [PATCH] ni_nitdoc: fixed sinature links Signed-off-by: Alexandre Terrasa --- src/ni_nitdoc.nit | 63 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/ni_nitdoc.nit b/src/ni_nitdoc.nit index 31b9455..ee20484 100644 --- a/src/ni_nitdoc.nit +++ b/src/ni_nitdoc.nit @@ -863,7 +863,7 @@ class NitdocClass # formal types if mclass.arity > 0 and nclass isa AStdClassdef then for ft, bound in mclass.parameter_types do - append("
") + append("
") append("

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

") append("
formal generic type
") append("
") @@ -1182,6 +1182,30 @@ redef class MNullableType redef fun link(mbuilder) do return "nullable {mtype.link(mbuilder)}" end +redef class MGenericType + redef fun link(mbuilder) do + var res = new Buffer + res.append("{mclass.name}[") + for i in [0..arguments.length[ do + res.append(arguments[i].link(mbuilder)) + if i < arguments.length - 1 then res.append(", ") + end + res.append("]") + return res.to_s + end +end + +redef class MParameterType + redef fun link(mbuilder) do + var name = mclass.intro.parameter_names[rank] + return "{name}" + end +end + +redef class MVirtualType + redef fun link(mbuilder) do return mproperty.intro.link(mbuilder) +end + redef class MClassDef # Return the classdef namespace decorated with html fun html_namespace(mbuilder: ModelBuilder): String do @@ -1279,7 +1303,8 @@ redef class MMethodDef res.append("

{mprop.name}(value: {nprop.html_signature(page.mbuilder)})

") end else - res.append("

{mprop.name}{nprop.html_signature(page.mbuilder)}

") + var intro_nprop = page.mbuilder.mpropdef2npropdef[mprop.intro] + res.append("

{mprop.name}{intro_nprop.html_signature(page.mbuilder)}

") end res.append(html_info(page)) res.append("
") @@ -1493,7 +1518,7 @@ redef class AAttrPropdef end redef fun html_signature(mbuilder) do - if n_type != null then return n_type.to_html + if n_type != null then return n_type.mtype.link(mbuilder) return "" end end @@ -1514,7 +1539,7 @@ redef class AMethPropdef end redef fun html_signature(mbuilder) do - if n_signature != null then return n_signature.to_html + if n_signature != null then return n_signature.to_html(mbuilder) return "" end end @@ -1540,39 +1565,33 @@ redef class ATypePropdef end redef class ASignature - fun to_html: String do + fun to_html(mbuilder: ModelBuilder): String do #TODO closures - var ret = "" + var res = new Buffer if not n_params.is_empty then - ret = "{ret}({n_params.join(", ")})" + res.append("(") + for i in [0..n_params.length[ do + res.append(n_params[i].to_html(mbuilder)) + if i < n_params.length - 1 then res.append(", ") + end + res.append(")") end - if n_type != null and n_type.to_html != "" then ret += ": {n_type.to_html}" - return ret + if n_type != null and n_type.mtype.link(mbuilder) != "" then res.append(": {n_type.mtype.link(mbuilder)}") + return res.to_s end end redef class AParam - redef fun to_s do + fun to_html(mbuilder: ModelBuilder): String do var ret = "{n_id.text}" if n_type != null then - ret = "{ret}: {n_type.to_html}" + ret = "{ret}: {n_type.mtype.link(mbuilder)}" if n_dotdotdot != null then ret = "{ret}..." end return ret end end -redef class AType - fun to_html: 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 - # Create a tool context to handle options and paths var toolcontext = new ToolContext -- 1.7.9.5