From eddcab42b2ee6ec3371cb8ea88fee03eec6943d2 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 8 Feb 2012 14:53:07 -0500 Subject: [PATCH] nitdoc: Handle correctly method with < or > in names Instead of overriding the Symbol::to_s method, create a html_name method and use it at the right places. Signed-off-by: Jean Privat --- src/nitdoc.nit | 65 +++++++++++++++----------------------------------------- 1 file changed, 17 insertions(+), 48 deletions(-) diff --git a/src/nitdoc.nit b/src/nitdoc.nit index 5543600..691d951 100644 --- a/src/nitdoc.nit +++ b/src/nitdoc.nit @@ -666,16 +666,16 @@ redef class MMModule var lpi = self[gp.intro.local_class.global][gp] if lps.has(lpi) then - dctx.add("
  • I {lpi.html_open_link(dctx)}{lpi} ({lpi.local_class})
  • \n") + dctx.add("
  • I {lpi.html_open_link(dctx)}{lpi.html_name} ({lpi.local_class})
  • \n") lps.remove(lpi) else - dctx.add("
  • I {lpi}") + dctx.add("
  • I {lpi.html_name}") dctx.add(" ({lpi.local_class})
  • \n") end if lps.length >= 1 then dctx.sort(lps) for lp in lps do - dctx.add("
  • R {lp.html_open_link(dctx)}{lp} ({lp.local_class})
  • ") + dctx.add("
  • R {lp.html_open_link(dctx)}{lp.html_name} ({lp.local_class})
  • ") end end end @@ -752,11 +752,11 @@ redef class MMModule var lpi = self[gp.intro.local_class.global][gp] lps.remove(lpi) - dctx.add("
  • I {lpi.html_open_link(dctx)}{lpi} ({lpi.local_class})
  • \n") + dctx.add("
  • I {lpi.html_open_link(dctx)}{lpi.html_name} ({lpi.local_class})
  • \n") if lps.length >= 1 then dctx.sort(lps) for lp in lps do - dctx.add("
  • R {lp.html_open_link(dctx)}{lp} ({lp.local_class})
  • \n") + dctx.add("
  • R {lp.html_open_link(dctx)}{lp.html_name} ({lp.local_class})
  • \n") end end end @@ -776,31 +776,36 @@ redef class MMLocalProperty fun html_open_link(dctx: DocContext): String do if not require_doc(dctx) then print "not required {self}" - var title = "{name}{signature.to_s}" + var title = "{html_name}{signature.to_s}" if short_doc != " " then title += " #{short_doc}" end return "" end + fun html_name: String + do + return self.name.to_s.html_escape + end + redef fun html_link(dctx) do if not require_doc(dctx) then print "not required {self}" - var title = "{name}{signature.to_s}" + var title = "{html_name}{signature.to_s}" if short_doc != " " then title += " #{short_doc}" end - return "{self}" + return "{html_name}" end fun html_link_special(dctx: DocContext, lc: MMLocalClass): String do if not require_doc(dctx) then print "not required {self}" - var title = "{name}{signature_for(lc.get_type)}" + var title = "{html_name}{signature_for(lc.get_type)}" if short_doc != " " then title += " #{short_doc}" end - return "{self}" + return "{html_name}" end # Kind of property (fun, attr, etc.) @@ -883,7 +888,7 @@ redef class MMLocalProperty var is_redef = local_class.global != intro_class.global or local_class.mmmodule.toplevel_owner != intro_class.mmmodule.toplevel_owner dctx.add("
    \n") - dctx.add("

    {name}{signature.to_html(dctx, true)}

    \n") + dctx.add("

    {html_name}{signature.to_html(dctx, true)}

    \n") dctx.add("
    \n") #dctx.add("

    LP: {self.mmmodule.html_link(dctx)}::{self.local_class.html_link(dctx)}::{self.html_link(dctx)}

    ") @@ -908,7 +913,7 @@ redef class MMLocalProperty if is_redef then dctx.add("::{mmmodule[intro_class.global][global].html_link(dctx)}") else - dctx.add("::{name}") + dctx.add("::{html_name}") end dctx.add("
    ") @@ -1016,42 +1021,6 @@ redef class MMTypeProperty redef fun kind do return "type" end -redef class Symbol - # Replace < and > with html entities - redef fun to_s - do - var ret = super.to_s - - if(ret.has('<')) then - var parts = ret.split_with("<") - ret = "" - - for i in [0..parts.length[ do - ret += parts[i] - - if(i < parts.length - 1) then - ret += "<" - end - end - end - - if(ret.has('>')) then - var parts = ret.split_with(">") - ret = "" - - for i in [0..parts.length[ do - ret += parts[i] - - if(i < parts.length - 1) then - ret += ">" - end - end - end - - return ret - end -end - redef class MMSrcModule redef fun short_doc do -- 1.7.9.5