From: Alexandre Terrasa Date: Thu, 18 Jul 2013 23:34:56 +0000 (-0400) Subject: ni_nitdoc: factorized html lnk to modules X-Git-Tag: v0.6.1~73^2~5^2~64 X-Git-Url: http://nitlanguage.org ni_nitdoc: factorized html lnk to modules Signed-off-by: Alexandre Terrasa --- diff --git a/src/ni_nitdoc.nit b/src/ni_nitdoc.nit index 28a9167..f928914 100644 --- a/src/ni_nitdoc.nit +++ b/src/ni_nitdoc.nit @@ -332,7 +332,8 @@ class NitdocOverview for mmodule in sorted do var amodule = mbuilder.mmodule2nmodule[mmodule] open("li") - add("a").attr("href", "{mmodule.name}.html").text("{mmodule.to_s} ") + add_html(mmodule.link(amodule)) + add_html(" ") add_html(amodule.short_comment) close("li") end @@ -561,8 +562,9 @@ class NitdocModule sorter.sort(sorted) for m in sorted do if m == mmodule or m.public_owner != null then continue + var am = mbuilder.mmodule2nmodule[m] open("li") - add("a").attr("href", "{m.name}.html").text(m.name) + add_html(m.link(am)) close("li") end add_html("") @@ -574,8 +576,9 @@ class NitdocModule sorter.sort(sorted) for m in sorted do if m == mmodule or m.public_owner != null then continue + var am = mbuilder.mmodule2nmodule[m] open("li") - add("a").attr("href", "{m.name}.html").text(m.name) + add_html(m.link(am)) close("li") end add_html("") @@ -589,12 +592,12 @@ class NitdocModule add("h3").text("Nested Modules").attr("style","cursor: pointer;") open("ul") for m in sorted do + var am = mbuilder.mmodule2nmodule[m] open("li") - add("a").attr("href", "{m.name}.html").text(m.name) + add_html(m.link(am)) close("li") end close("ul") - close("nav") end close("div") @@ -700,9 +703,11 @@ class NitdocClass open("li") var public_owner = mclass.public_owner if public_owner is null then - add_html("{mclass.intro_mmodule.name}") + var am = mbuilder.mmodule2nmodule[mclass.intro_mmodule] + add_html(mclass.intro_mmodule.link(am)) else - add_html("{public_owner.name}") + var am = mbuilder.mmodule2nmodule[public_owner] + add_html(public_owner.link(am)) end close("li") add("li").add_class("current").text(mclass.name) @@ -831,7 +836,8 @@ class NitdocClass add("h1").text(mclass.name) open("div").add_class("subtitle") if mclass.visibility is none_visibility then subtitle += "private " - subtitle += "{mclass.kind} {mclass.public_owner.name}::{mclass.name}" + var nowner = mbuilder.mmodule2nmodule[mclass.public_owner] + subtitle += "{mclass.kind} {mclass.public_owner.link(nowner)}::{mclass.name}" add_html(subtitle) close("div") add_html("
") @@ -897,7 +903,7 @@ class NitdocClass if mclass.has_mmodule(mmodule) then add_html("

{mmodule.name}: {nmodule.short_comment}

") else - add_html("

Methods refined in {mmodule.name}

{mmodule.name}: {nmodule.short_comment}

") + add_html("

Methods refined in {mmodule.link(nmodule)}

{mmodule.name}: {nmodule.short_comment}

") end end var sortedc = mmethods.to_a @@ -941,12 +947,20 @@ class NitdocClass end add_html("CancelCommit
")
 		open("p")
-		if prop.local_class != mclass then add_html("inherited from {prop.local_class.intro_mmodule.name} ")
+		if prop.local_class != mclass then
+			var mredef = prop.local_class.intro_mmodule
+			var nredef = mbuilder.mmodule2nmodule[mredef]
+			add_html("inherited from {mredef.link(nredef)} ")
+		end
 		#TODO display show code if doc github
-		add_html("defined by the module {prop.intro_mclassdef.mmodule.name} {if prop.apropdef is null then "" else show_source(prop.apropdef.location)}.")
+		var mintro = prop.intro_mclassdef.mmodule
+		var nintro = mbuilder.mmodule2nmodule[mintro]
+		add_html("defined by the module {mintro.link(nintro)}{if prop.apropdef is null then "" else show_source(prop.apropdef.location)}.")
 
 		for parent in mclass.parents do
-			if prop isa MMethod then if parent.constructors.has(prop) then add_html(" Previously defined by: {parent.intro_mmodule.name} for {parent.name}.")
+			var mparent = parent.intro_mmodule
+			var nparent = mbuilder.mmodule2nmodule[mparent]
+			if prop isa MMethod then if parent.constructors.has(prop) then add_html(" Previously defined by: {mparent.link(nparent)} for {parent.name}.")
 		end
 		close("p")
 		close("div")
@@ -987,8 +1001,6 @@ redef class MModule
 	redef type OTHER: MModule
 	redef fun <(other: OTHER): Bool do return self.name < other.name
 
-	var amodule: nullable AModule
-
 	# Get the list of all methods in a module
 	fun imported_methods: Set[MMethod] do
 		var methods = new HashSet[MMethod]
@@ -1010,6 +1022,11 @@ redef class MModule
 		end
 		return methods
 	end
+
+	# Return a link (html a tag) to the nitdoc module page
+	fun link(amodule: AModule): String do
+		return "{name}"
+	end
 end
 redef class MPropDef
 	super Comparable
@@ -1102,14 +1119,6 @@ redef class MClass
 			return owner.public_owner.as(not null)
 		end
 	end
-	
-	# Associate Amodule to all MModule concern by 'self'
-	fun amodule(amodules: HashMap[MModule, AModule]) do
-		for owner, childs in concerns do
-			if childs != null then for child in childs do child.amodule = amodules[child]
-			owner.amodule = amodules[owner]
-		end
-	end
 
 	# Associate MClass to all MMethod include in 'inherited_methods'
 	fun inherited: HashMap[MClass, Set[MMethod]] do