X-Git-Url: http://nitlanguage.org diff --git a/src/ni_nitdoc.nit b/src/ni_nitdoc.nit index 7fa887c..339a77f 100644 --- a/src/ni_nitdoc.nit +++ b/src/ni_nitdoc.nit @@ -166,13 +166,13 @@ class NitdocContext file.write("var entries = \{ ") for mmodule in model.mmodules do file.write("\"{mmodule.name}\": [") - file.write("\{txt: \"{mmodule.name}\", url:\"{mmodule.url}\" \},") + file.write("\{txt: \"{mmodule.full_name}\", url:\"{mmodule.url}\" \},") file.write("],") end for mclass in model.mclasses do if mclass.visibility < min_visibility then continue file.write("\"{mclass.name}\": [") - file.write("\{txt: \"{mclass.name}\", url:\"{mclass.url}\" \},") + file.write("\{txt: \"{mclass.full_name}\", url:\"{mclass.url}\" \},") file.write("],") end var name2mprops = new HashMap[String, Set[MPropDef]] @@ -538,16 +538,16 @@ class NitdocModule redef fun title do if mbuilder.mmodule2nmodule.has_key(mmodule) and not mbuilder.mmodule2nmodule[mmodule].short_comment.is_empty then var nmodule = mbuilder.mmodule2nmodule[mmodule] - return "{mmodule.name} module | {nmodule.short_comment}" + return "{mmodule.html_name} module | {nmodule.short_comment}" else - return "{mmodule.name} module" + return "{mmodule.html_name} module" end end redef fun menu do super append("
  • Overview
  • ") - append("
  • {mmodule.name}
  • ") + append("
  • {mmodule.html_name}
  • ") append("
  • Search
  • ") end @@ -622,7 +622,7 @@ class NitdocModule private fun module_doc do # title - append("

    {mmodule.name}

    ") + append("

    {mmodule.html_name}

    ") append("
    ") mmodule.html_signature(self) append("
    ") @@ -775,9 +775,9 @@ class NitdocClass redef fun title do var nclass = ctx.mbuilder.mclassdef2nclassdef[mclass.intro] if nclass isa AStdClassdef then - return "{mclass.name} class | {nclass.short_comment}" + return "{mclass.html_name} class | {nclass.short_comment}" else - return "{mclass.name} class" + return "{mclass.html_name} class" end end @@ -794,7 +794,7 @@ class NitdocClass public_owner.html_link(self) append("") end - append("
  • {mclass.name}
  • ") + append("
  • {mclass.html_name}
  • ") append("
  • Search
  • ") end @@ -907,7 +907,7 @@ class NitdocClass private fun class_doc do # title - append("

    {mclass.name}{mclass.html_short_signature}

    ") + append("

    {mclass.html_name}{mclass.html_short_signature}

    ") append("
    ") if mclass.visibility < public_visibility then append("{mclass.visibility.to_s} ") append("{mclass.kind.to_s} ") @@ -916,7 +916,6 @@ class NitdocClass # comment mclass.html_comment(self) process_generate_dot - append("") # concerns var concern2meths = new ArrayMap[MModule, Array[MMethodDef]] var sorted_meths = new Array[MMethodDef] @@ -946,18 +945,18 @@ class NitdocClass var nowner = ctx.mbuilder.mmodule2nmodule[owner] append("
  • ") if nowner.short_comment.is_empty then - append("{owner.name}") + append("{owner.html_name}") else - append("{owner.name}: {nowner.short_comment}") + append("{owner.html_name}: {nowner.short_comment}") end if not mmodules.is_empty then append("") @@ -1124,8 +1123,12 @@ end # redef class MModule + # Return the HTML escaped name of the module + private fun html_name: String do return name.html_escape + # URL to nitdoc page - fun url: String do + # module_owner_name.html + private fun url: String do if url_cache == null then var res = new Buffer res.append("module_") @@ -1140,8 +1143,9 @@ redef class MModule end private var url_cache: nullable String - # html anchor id to the module in a nitdoc page - fun anchor: String do + # html anchor id for the module in a nitdoc page + # MOD_owner_name + private fun anchor: String do if anchor_cache == null then var res = new Buffer res.append("MOD_") @@ -1157,13 +1161,14 @@ redef class MModule private var anchor_cache: nullable String # Return a link (html a tag) to the nitdoc module page - fun html_link(page: NitdocPage) do + # html_name + private fun html_link(page: NitdocPage) do if html_link_cache == null then var res = new Buffer if page.ctx.mbuilder.mmodule2nmodule.has_key(self) then - res.append("{name}") + res.append("{html_name}") else - res.append("{name}") + res.append("{html_name}") end html_link_cache = res.to_s end @@ -1172,14 +1177,16 @@ redef class MModule private var html_link_cache: nullable String # Return the module signature decorated with html - fun html_signature(page: NitdocPage) do + # module html_full_namespace + private fun html_signature(page: NitdocPage) do page.append("module ") html_full_namespace(page) page.append("") end # Return the module full namespace decorated with html - fun html_full_namespace(page: NitdocPage) do + # public_owner.html_namespace::html_link + private fun html_full_namespace(page: NitdocPage) do page.append("") var mowner = public_owner if mowner != null then @@ -1191,7 +1198,8 @@ redef class MModule end # Return the module full namespace decorated with html - fun html_namespace(page: NitdocPage) do + # public_owner.html_namespace + private fun html_namespace(page: NitdocPage) do page.append("") var mowner = public_owner if mowner != null then @@ -1242,41 +1250,29 @@ redef class MModule end redef class MClass - # return the generic signature of the class - # [E, F] - private fun html_short_signature: String do - if arity > 0 then - return "[{intro.parameter_names.join(", ")}]" - else - return "" - end - end + # Return the HTML escaped name of the module + private fun html_name: String do return name.html_escape - # return the generic signature of the class with bounds - # [E: MType, F: MType] - private fun html_signature(page: NitdocPage) do - if arity > 0 then - page.append("[") - for i in [0..intro.parameter_names.length[ do - page.append("{intro.parameter_names[i]}: ") - intro.bound_mtype.arguments[i].html_link(page) - if i < intro.parameter_names.length - 1 then page.append(", ") - end - page.append("]") - end + # URL to nitdoc page + # class_owner_name.html + private fun url: String do + return "class_{public_owner}_{name}.html" end - # Return the class namespace decorated with html - private fun html_namespace(page: NitdocPage) do - intro_mmodule.html_namespace(page) - page.append("::") - html_short_link(page) - page.append("") + # html anchor id for the class in a nitdoc page + # MOD_owner_name + private fun anchor: String do + if anchor_cache == null then + anchor_cache = "CLASS_{public_owner.name}_{name}" + end + return anchor_cache.as(not null) end + private var anchor_cache: nullable String - # Return a link (html a tag) to the nitdoc class page - fun html_short_link(page: NitdocPage) do - if html_short_link_cache == null then + # Return a link (with signature) to the nitdoc class page + # html_name(signature) + private fun html_link(page: NitdocPage) do + if html_link_cache == null then var res = new Buffer res.append("{name}") - html_short_link_cache = res.to_s + res.append(">{html_name}{html_short_signature}") + html_link_cache = res.to_s end - page.append(html_short_link_cache.as(not null)) + page.append(html_link_cache.as(not null)) end - private var html_short_link_cache: nullable String + private var html_link_cache: nullable String - # Return a link (html a tag) to the nitdoc class page - fun html_link(page: NitdocPage) do - if html_link_cache == null then + # Return a short link (without signature) to the nitdoc class page + # html_name + private fun html_short_link(page: NitdocPage) do + if html_short_link_cache == null then var res = new Buffer res.append("{name}{html_short_signature}") - html_link_cache = res.to_s + res.append(">{html_name}") + html_short_link_cache = res.to_s end - page.append(html_link_cache.as(not null)) + page.append(html_short_link_cache.as(not null)) end - private var html_link_cache: nullable String + private var html_short_link_cache: nullable String - fun html_anchor(page: NitdocPage) do - if html_anchor_cache == null then + # Return a link (with signature) to the class anchor + # html_name + private fun html_link_anchor(page: NitdocPage) do + if html_link_anchor_cache == null then var res = new Buffer res.append("{name}{html_short_signature}") - html_anchor_cache = res.to_s + res.append(">{html_name}{html_short_signature}") + html_link_anchor_cache = res.to_s end - page.append(html_anchor_cache.as(not null)) + page.append(html_link_anchor_cache.as(not null)) end - private var html_anchor_cache: nullable String + private var html_link_anchor_cache: nullable String - fun anchor: String do - if anchor_cache == null then - anchor_cache = "CLASS_{public_owner.name}_{name}" + # Return the generic signature of the class with bounds + # [E: MType, F: MType] + private fun html_signature(page: NitdocPage) do + if arity > 0 then + page.append("[") + for i in [0..intro.parameter_names.length[ do + page.append("{intro.parameter_names[i]}: ") + intro.bound_mtype.arguments[i].html_link(page) + if i < intro.parameter_names.length - 1 then page.append(", ") + end + page.append("]") end - return anchor_cache.as(not null) end - private var anchor_cache: nullable String - fun url: String do - return "class_{public_owner}_{name}.html" + # Return the generic signature of the class without bounds + # [E, F] + private fun html_short_signature: String do + if arity > 0 then + return "[{intro.parameter_names.join(", ")}]" + else + return "" + end end - # Escape name for html output - redef fun name do return super.html_escape + # Return the class namespace decorated with html + # intro_module::html_short_link + private fun html_namespace(page: NitdocPage) do + intro_mmodule.html_namespace(page) + page.append("::") + html_short_link(page) + page.append("") + end # Return a list item for the mclass + #
  • html_link
  • private fun html_sidebar_item(page: NitdocModule) do if page.mmodule.in_nesting.greaters.has(intro.mmodule) then page.append("
  • ") page.append("I") - html_anchor(page) + html_link_anchor(page) else if page.mmodule.has_mclassdef_for(self) then page.append("
  • ") page.append("R") - html_anchor(page) + html_link_anchor(page) else page.append("
  • ") page.append("H") @@ -1366,7 +1384,7 @@ redef class MClass if not page.mmodule.in_nesting.greaters.has(intro.mmodule) then classes.add("redef") classes.add(visibility.to_s) page.append("
    ") - page.append("

    ") + page.append("

    ") page.append("") html_short_link(page) html_signature(page) @@ -1453,21 +1471,23 @@ redef class MClass end redef class MProperty + # Escape name for html output + private fun html_name: String do return name.html_escape + # Return the property namespace decorated with html - fun html_namespace(page: NitdocPage) do + # intro_module::intro_class::html_link + private fun html_namespace(page: NitdocPage) do intro_mclassdef.mclass.html_namespace(page) page.append(intro_mclassdef.mclass.html_short_signature) page.append("::") intro.html_link(page) page.append("") end - - # Escape name for html output - redef fun name do return super.html_escape end redef class MType - fun html_link(page: NitdocPage) is abstract + # Link to the type definition in the nitdoc page + private fun html_link(page: NitdocPage) is abstract end redef class MClassType @@ -1483,7 +1503,7 @@ end redef class MGenericType redef fun html_link(page) do - page.append("{mclass.name}[") + page.append("{mclass.html_name}[") for i in [0..arguments.length[ do arguments[i].html_link(page) if i < arguments.length - 1 then page.append(", ") @@ -1505,7 +1525,7 @@ end redef class MClassDef # Return the classdef namespace decorated with html - fun html_namespace(page: NitdocPage) do + private fun html_namespace(page: NitdocPage) do mmodule.html_full_namespace(page) page.append("::") mclass.html_link(page) @@ -1514,7 +1534,15 @@ redef class MClassDef end redef class MPropDef - fun url: String do + # Return the full qualified name of the mpropdef + # module::classdef::name + private fun full_name: String do + return "{mclassdef.mclass.public_owner.name}::{mclassdef.mclass.name}::{mproperty.name}" + end + + # URL into the nitdoc page + # class_owner_name.html#anchor + private fun url: String do if url_cache == null then url_cache = "{mclassdef.mclass.url}#{anchor}" end @@ -1522,23 +1550,26 @@ redef class MPropDef end private var url_cache: nullable String - fun anchor: String do + # html anchor id for the property in a nitdoc class page + # PROP_mclass_propertyname + private fun anchor: String do if anchor_cache == null then - anchor_cache = "PROP_{mclassdef.mclass.public_owner.name}_{mproperty.name}" + anchor_cache = "PROP_{mclassdef.mclass.public_owner.name}_{mproperty.name.replace(" ", "_")}" end return anchor_cache.as(not null) end private var anchor_cache: nullable String - # Return a link (html a tag) to the nitdoc class page - fun html_link(page: NitdocPage) do + # Return a link to property into the nitdoc class page + # html_name + private fun html_link(page: NitdocPage) do if html_link_cache == null then var res = new Buffer if page.ctx.mbuilder.mpropdef2npropdef.has_key(self) then var nprop = page.ctx.mbuilder.mpropdef2npropdef[self] - res.append("{mproperty.name}") + res.append("{mproperty.html_name}") else - res.append("{mproperty.name}") + res.append("{mproperty.html_name}") end html_link_cache = res.to_s end @@ -1547,6 +1578,7 @@ redef class MPropDef private var html_link_cache: nullable String # Return a list item for the mpropdef + #
  • html_link
  • private fun html_sidebar_item(page: NitdocClass) do if is_intro and mclassdef.mclass == page.mclass then page.append("
  • ") @@ -1565,10 +1597,6 @@ redef class MPropDef private fun html_full_desc(page: NitdocPage, ctx: MClass) is abstract private fun html_info(page: NitdocPage, ctx: MClass) is abstract - fun full_name: String do - return "{mclassdef.mclass.public_owner.name}::{mclassdef.mclass.name}::{mproperty.name}" - end - private fun html_comment(page: NitdocPage) do page.append("
    ") if not is_intro then @@ -1623,7 +1651,7 @@ redef class MMethodDef page.append("
    ") if page.ctx.mbuilder.mpropdef2npropdef.has_key(self) then page.append("

    ") - page.append("{mproperty.name}") + page.append("{mproperty.html_name}") msignature.html_signature(page) page.append("

    ") else @@ -1659,7 +1687,7 @@ redef class MVirtualTypeDef if is_redef then classes.add("redef") classes.add(mproperty.visibility.to_s) page.append("
    ") - page.append("

    {mproperty.name}: ") + page.append("

    {mproperty.html_name}: ") bound.html_link(page) page.append("

    ") html_info(page, ctx)