ni_nitdoc: added fast copy past utility to signatures.
[nit.git] / src / nitdoc.nit
index 3943e2d..bdaa346 100644 (file)
@@ -27,7 +27,8 @@ class DocContext
        super AbstractCompiler
        # Destination directory
        readable writable var _dir: String = "doc"
-
+       # GitHub Repo name
+       var github_repo: nullable String = null
        # Content of a generated file
        var _stage_context: StageContext = new StageContext(null)
 
@@ -86,8 +87,12 @@ class DocContext
        readable var _opt_private: OptionBool = new OptionBool("Generate the private API", "--private")
        readable var _opt_nodot: OptionBool = new OptionBool("Do not generate graphes with graphviz", "--no-dot")
        readable var _opt_sharedir: OptionString = new OptionString("Directory containing the nitdoc files", "--sharedir")
-       readable var _opt_overview_text: OptionString = new OptionString("Text displayed as introduction of Overview page", "--overview-text")
-       readable var _opt_footer_text: OptionString = new OptionString("Text displayed as footer of all pages", "--footer-text")
+       
+       readable var _opt_custom_menu_items: OptionString = new OptionString("Items displayed in menu before the 'Overview' item (Each item must be enclosed in 'li' tags)", "--custom-menu-items")
+       readable var _opt_custom_title: OptionString = new OptionString("Title displayed in the top of the Overview page and as suffix of all page names", "--custom-title")
+       readable var _opt_custom_overview_text: OptionString = new OptionString("Text displayed as introduction of Overview page before the modules list", "--custom-overview-text")
+       readable var _opt_custom_footer_text: OptionString = new OptionString("Text displayed as footer of all pages", "--custom-footer-text")
+       readable var _opt_github_repo_name: OptionString = new OptionString("GitHub repo name, example: --github MyRepoName", "--github")
        var sharedir: nullable String
 
        fun public_only: Bool
@@ -157,27 +162,33 @@ class DocContext
                end
 
                var head = "<meta charset=\"utf-8\">" +
-                       "<script type=\"text/javascript\" src=\"scripts/jquery-1.7.1.min.js\"></script>\n" + 
+                       "<script type=\"text/javascript\" src=\"scripts/jquery-1.7.1.min.js\"></script>\n" +
+                       "<script type=\"text/javascript\" src=\"quicksearch-list.js\"></script>\n" +
                        "<script type=\"text/javascript\" src=\"scripts/js-facilities.js\"></script>\n" +
                        "<link rel=\"stylesheet\" href=\"styles/main.css\" type=\"text/css\"  media=\"screen\" />"
 
-               var action_bar = "<header><nav class='main'><ul><li class=\"current\">Overview</li><li><a href='full-index.html'>Full Index</a></li><li><a href=\"help.html\">Help</a></li></ul></nav></header>\n"
+               var custom_items = ""
+               if self._opt_custom_menu_items.value != null then custom_items = self._opt_custom_menu_items.value.as(not null)
 
+               var action_bar = "<header><nav class='main'><ul>{custom_items}<li class=\"current\">Overview</li><li><a href='full-index.html'>Full Index</a></li><li><a href=\"help.html\">Help</a></li><li id=\"liGitHub\" class=\"\"><a id=\"logGitHub\" class=\"btn\" ><img id=\"imgGitHub\" src=\"resources/icons/github-icon.png\" /></a><div class=\"popover bottom\"><div class=\"arrow\"></div><div class=\"githubTitle\"><h3>Github Sign In</h3></div><div><label id=\"lbloginGit\" for=\"login\">Username</label><input id=\"loginGit\" type=\"text\" name=\"login\"><label id=\"logginMessage\" >Hello <a id=\"githubAccount\" ><strong id=\"nickName\"></strong></a></label></div><div><label id=\"lbpasswordGit\" for=\"password\">Password</label><input id=\"passwordGit\" type=\"password\" name=\"password\"><div id=\"divGitHubRepoDisplay\"><label id=\"lbRepoDisplay\">Repository: </label><strong><label id=\"githubRepoDisplay\"></label></strong></div></div><div><label id=\"lbrepositoryGit\" for=\"repository\">Repository</label><input id=\"repositoryGit\" type=\"text\" name=\"repository\"><div id=\"listBranches\"><label id=\"lbBranches\">Branch </label><select id=\"dropBranches\" name=\"dropBranches\" tabindex=\"1\" class=\"dropdown\"></select></div></div><div><label id=\"lbbranchGit\" for=\"branch\">Branch</label><input id=\"branchGit\" type=\"text\" name=\"branch\"></div><div id=\"divlogIn\"><a id=\"signIn\" >Sign In</a></div></div></li></ul></nav></header>\n"
+               var custom_title = "Nitdoc"
+               if self._opt_custom_title.value != null then custom_title = self._opt_custom_title.value.as(not null)
+               
                var overview_text = ""
-               if self._opt_overview_text.value != null then overview_text = self._opt_overview_text.value.as(not null)
+               if self._opt_custom_overview_text.value != null then overview_text = self._opt_custom_overview_text.value.as(not null)
 
                var footer_text = ""
-               if self._opt_footer_text.value != null then footer_text = self._opt_footer_text.value.as(not null)
-
+               if self._opt_custom_footer_text.value != null then footer_text = self._opt_custom_footer_text.value.as(not null)
+               
                # generate the index
                self.filename = "index.html"
                clear
                add("<!DOCTYPE html>")
-               add("<html><head>{head}<title>Index</title></head><body>\n")
+               add("<html><head>{head}<title>Overview | {custom_title}</title></head><body>\n")
                add(action_bar)
                add("<div class=\"page\">")
                add("<div class=\"content fullpage\">")
-               add("<h1>Modules</h1>\n<article class='overview'>{overview_text}<ul>")
+               add("<h1>{custom_title}</h1>\n<article class='overview'>{overview_text}</article><article class='overview'><h2>Modules</h2><ul>")
                var modss = mainmod.mhe.greaters_and_self.to_a
                sort(modss)
                for mod in modss do
@@ -203,9 +214,10 @@ class DocContext
                op.append("\}\n")
                self.gen_dot(op.to_s, "dep", "Modules hierarchy")
                add("</article></div>")
-               add("<div class='clear'></div>")
                add("</div>")
                add("<footer>{footer_text}</footer>")
+               addGithubInformation
+               addCommitForm
                add("</body></html>\n")
                write_to("{dir}/index.html")
 
@@ -215,15 +227,17 @@ class DocContext
                        assert mod isa MMSrcModule
                        if not mod.require_doc(self) then continue
                        self.filename = mod.html_name
-                       action_bar = "<header><nav class='main'><ul><li><a href='./index.html'>Overview</a></li><li class=\"current\">{mod.name}</li><li><a href='full-index.html'>Full Index</a></li><li><a href=\"help.html\">Help</a></li></ul></nav></header>\n"
+                       action_bar = "<header><nav class='main'><ul>{custom_items}<li><a href='./index.html'>Overview</a></li><li class=\"current\">{mod.name}</li><li><a href='full-index.html'>Full Index</a></li><li><a href=\"help.html\">Help</a></li><li id=\"liGitHub\" class=\"\"><a id=\"logGitHub\" class=\"btn\" ><img id=\"imgGitHub\" src=\"resources/icons/github-icon.png\" /></a><div class=\"popover bottom\"><div class=\"arrow\"></div><div class=\"githubTitle\"><h3>Github Sign In</h3></div><div><label id=\"lbloginGit\" for=\"login\">Username</label><input id=\"loginGit\" type=\"text\" name=\"login\"><label id=\"logginMessage\" >Hello <a id=\"githubAccount\" ><strong id=\"nickName\"></strong></a></label></div><div><label id=\"lbpasswordGit\" for=\"password\">Password</label><input id=\"passwordGit\" type=\"password\" name=\"password\"><div id=\"divGitHubRepoDisplay\"><label id=\"lbRepoDisplay\">Repository: </label><strong><label id=\"githubRepoDisplay\"></label></strong></div></div><div><label id=\"lbrepositoryGit\" for=\"repository\">Repository</label><input id=\"repositoryGit\" type=\"text\" name=\"repository\"><div id=\"listBranches\"><label id=\"lbBranches\">Branch </label><select id=\"dropBranches\" name=\"dropBranches\" tabindex=\"1\" class=\"dropdown\"></select></div></div><div><label id=\"lbbranchGit\" for=\"branch\">Branch</label><input id=\"branchGit\" type=\"text\" name=\"branch\"></div><div id=\"divlogIn\"><a id=\"signIn\" >Sign In</a></div></div></li></ul></nav></header>\n"
                        clear
                        add("<!DOCTYPE html>")
-                       add("<html><head>{head}<title>Module {mod.name}</title></head><body>\n")
+                       add("<html><head>{head}<title>{mod.name} module | {custom_title}</title></head><body>\n")
                        add(action_bar)
                        add("<div class=\"page\">")
                        mod.file_page_doc(self)
                        add("</div>")
                        add("<footer>{footer_text}</footer>")
+                       addGithubInformation
+                       addCommitForm
                        add("</body></html>\n")
                        write_to("{dir}/{mod.html_name}.html")
                end
@@ -232,24 +246,26 @@ class DocContext
                for c in mainmod.local_classes do
                        if not c.require_doc(self) then continue
                        self.filename = c.html_name
-                       action_bar = "<header><nav class='main'><ul><li><a href='./index.html'>Overview</a></li><li>{c.global.intro.mmmodule.toplevel_owner.html_link(self)}</li><li class=\"current\">{c.name}</li><li><a href='full-index.html'>Full Index</a></li><li><a href=\"help.html\">Help</a></li></ul></nav></header>\n"
+                       action_bar = "<header><nav class='main'><ul>{custom_items}<li><a href='./index.html'>Overview</a></li><li>{c.global.intro.mmmodule.toplevel_owner.html_link(self)}</li><li class=\"current\">{c.name}</li><li><a href='full-index.html'>Full Index</a></li><li><a href=\"help.html\">Help</a></li><li id=\"liGitHub\" class=\"\"><a id=\"logGitHub\" class=\"btn\" ><img id=\"imgGitHub\" src=\"resources/icons/github-icon.png\" /></a><div class=\"popover bottom\"><div class=\"arrow\"></div><div class=\"githubTitle\"><h3>Github Sign In</h3></div><div><label id=\"lbloginGit\" for=\"login\">Username</label><input id=\"loginGit\" type=\"text\" name=\"login\"><label id=\"logginMessage\" >Hello <a id=\"githubAccount\" ><strong id=\"nickName\"></strong></a></label></div><div><label id=\"lbpasswordGit\" for=\"password\">Password</label><input id=\"passwordGit\" type=\"password\" name=\"password\"><div id=\"divGitHubRepoDisplay\"><label id=\"lbRepoDisplay\">Repository: </label><strong><label id=\"githubRepoDisplay\"></label></strong></div></div><div><label id=\"lbrepositoryGit\" for=\"repository\">Repository</label><input id=\"repositoryGit\" type=\"text\" name=\"repository\"><div id=\"listBranches\"><label id=\"lbBranches\">Branch </label><select id=\"dropBranches\" name=\"dropBranches\" tabindex=\"1\" class=\"dropdown\"></select></div></div><div><label id=\"lbbranchGit\" for=\"branch\">Branch</label><input id=\"branchGit\" type=\"text\" name=\"branch\"></div><div id=\"divlogIn\"><a id=\"signIn\" >Sign In</a></div></div></li></ul></nav></header>\n"
                        clear
                        add("<!DOCTYPE html>")
-                       add("<html><head>{head}<title>Class {c.name}</title></head><body>\n")
+                       add("<html><head>{head}<title>{c.name} class | {custom_title}</title></head><body>\n")
                        add(action_bar)
                        add("<div class=\"page\">")
                        c.file_page_doc(self)
                        add("</div>")
                        add("<footer>{footer_text}</footer>")
+                       addGithubInformation
+                       addCommitForm
                        add("</body></html>\n")
                        write_to("{dir}/{c.html_name}.html")
                end
 
                self.filename = "fullindex"
-               action_bar = "<header><nav class='main'><ul><li><a href='./index.html'>Overview</a></li><li class=\"current\">Full Index</li><li><a href=\"help.html\">Help</a></li></ul></nav></header>\n"
+               action_bar = "<header><nav class='main'><ul>{custom_items}<li><a href='./index.html'>Overview</a></li><li class=\"current\">Full Index</li><li><a href=\"help.html\">Help</a></li><li id=\"liGitHub\" class=\"\"><a id=\"logGitHub\" class=\"btn\" ><img id=\"imgGitHub\" src=\"resources/icons/github-icon.png\" /></a><div class=\"popover bottom\"><div class=\"arrow\"></div><div class=\"githubTitle\"><h3>Github Sign In</h3></div><div><label id=\"lbloginGit\" for=\"login\">Username</label><input id=\"loginGit\" type=\"text\" name=\"login\"><label id=\"logginMessage\" >Hello <a id=\"githubAccount\" ><strong id=\"nickName\"></strong></a></label></div><div><label id=\"lbpasswordGit\" for=\"password\">Password</label><input id=\"passwordGit\" type=\"password\" name=\"password\"><div id=\"divGitHubRepoDisplay\"><label id=\"lbRepoDisplay\">Repository: </label><strong><label id=\"githubRepoDisplay\"></label></strong></div></div><div><label id=\"lbrepositoryGit\" for=\"repository\">Repository</label><input id=\"repositoryGit\" type=\"text\" name=\"repository\"><div id=\"listBranches\"><label id=\"lbBranches\">Branch </label><select id=\"dropBranches\" name=\"dropBranches\" tabindex=\"1\" class=\"dropdown\"></select></div></div><div><label id=\"lbbranchGit\" for=\"branch\">Branch</label><input id=\"branchGit\" type=\"text\" name=\"branch\"></div></div> <div id=\"divlogIn\"><a id=\"signIn\" >Sign In</a></div></div></li></ul></nav></header>\n"
                clear
                add("<!DOCTYPE html>")
-               add("<html><head>{head}<title>Full Index</title></head><body>\n")
+               add("<html><head>{head}<title>Full Index | {custom_title}</title></head><body>\n")
                add(action_bar)
                add("<div class=\"page\">")
                add("<div class=\"content fullpage\">")
@@ -257,17 +273,33 @@ class DocContext
                add("</div>")
                add("</div>")
                add("<footer>{footer_text}</footer>")
+               addGithubInformation
+               addCommitForm
                add("</body></html>\n")
                write_to("{dir}/full-index.html")
+
+               self.filename = "quicksearch-list"
+               clear
+               mainmod.file_quicksearch_list_doc(self)
+               write_to("{dir}/quicksearch-list.js")
+       end
+       
+       # Add or not a tag for the github repository
+       fun addGithubInformation do
+               if not github_repo == null then add("<div id=\"repoName\" name=\"{github_repo.to_s}\"></div>")
        end
 
+       # Add all tags for the commit form
+       fun addCommitForm do    
+               add("<div id=\"modal\"><form class=\"clearfix\"><div><label for=\"commitMessage\">Commit message</label><textarea id=\"commitMessage\" rows=\"1\" cols=\"76\" name=\"commitMessage\" ></textarea><input id=\"chkSignedOff\" type=\"checkbox\" name=\"chkSignedOff\">Signed-Off </div><div class=\"social-signup login\"><form ></form></div><form id=\"github-connect-form\" class=\"connect-button\" name=\"login\"><a id=\"loginAction\" title=\"Commit on GitHub\"><img src=\"resources/icons/github-icon.png\"><span id=\"btnGitHub\"><strong>Commit</strong></span></a></form></form></div><div id=\"modalQuestion\"><label id=\"txtQuestion\"></label><br><a id=\"btnCreateBranch\">Yes</a><a id=\"btnCancelBranch\">No</a></div><div id=\"waitCommit\"></div>\n\n")
+       end
 
        # Add a (source) link fo a given location
        fun show_source(l: Location)
        do
                var s = opt_source.value
                if s == null then
-                       add("in #{l.file.filename.simplify_path}")
+                       add("({l.file.filename.simplify_path})")
                else
                        # THIS IS JUST UGLY ! (but there is no replace yet)
                        var x = s.split_with("%f")
@@ -280,6 +312,24 @@ class DocContext
                end
        end
 
+       # Return source link for a given location
+       fun get_source(l: Location): String
+       do
+               var s = opt_source.value
+               if s == null then
+                       return l.file.filename.simplify_path
+               else
+                       # THIS IS JUST UGLY ! (but there is no replace yet)
+                       var x = s.split_with("%f")
+                       s = x.join(l.file.filename.simplify_path)
+                       x = s.split_with("%l")
+                       s = x.join(l.line_start.to_s)
+                       x = s.split_with("%L")
+                       s = x.join(l.line_end.to_s)
+                       return s
+               end
+       end
+
        # Generate a clicable graphiz image using a dot content.
        # `name' refer to the filename (without extension) and the id name of the map.
        # `name' must also match the name of the graph in the dot content (eg. digraph NAME {...)
@@ -307,8 +357,11 @@ class DocContext
                option_context.add_option(opt_source)
                option_context.add_option(opt_nodot)
                option_context.add_option(opt_sharedir)
-               option_context.add_option(opt_overview_text)
-               option_context.add_option(opt_footer_text)
+               option_context.add_option(opt_custom_title)
+               option_context.add_option(opt_custom_menu_items)
+               option_context.add_option(opt_custom_overview_text)
+               option_context.add_option(opt_custom_footer_text)
+               option_context.add_option(opt_github_repo_name)
        end
 
        redef fun process_options
@@ -328,7 +381,7 @@ class DocContext
                
                sharedir = opt_sharedir.value
                if sharedir == null then
-                       var dir = once ("NIT_DIR".to_symbol).environ
+                       var dir = "NIT_DIR".environ
                        if dir.is_empty then
                                dir = "{sys.program_name.dirname}/../share/nitdoc"
                                if dir.file_exists then sharedir = dir
@@ -345,6 +398,8 @@ class DocContext
                        end
 
                end
+               var git = opt_github_repo_name.value
+               if not git == null then github_repo = git
        end
 
        redef fun handle_property_conflict(lc, impls)
@@ -427,7 +482,7 @@ class AlphaSorter[E: Object]
 end
 
 # Generalization of metamodel entities
-class MMEntity
+interface MMEntity
        # Return a link to
        fun html_link(dctx: DocContext): String is abstract
 
@@ -437,12 +492,44 @@ class MMEntity
        # The doc node from the AST
        # Return null is none
        fun doc: nullable ADoc do return null
+
+       # Return a JSON entry for quicksearch list
+       fun json_entry(dctx: DocContext): String is abstract
+
+       # Return the qualified name as string
+       fun qualified_name: String is abstract
+               
 end
 
 redef class MMModule
        super MMEntity
        redef fun html_link(dctx) do 
-               return "<a href=\"{html_name}.html\" title=\"{short_doc}\">{self}</a>"
+               if short_doc == "&nbsp;" then
+                       return "<a href=\"{html_name}.html\"\">{self}</a>"
+               else 
+                       return "<a href=\"{html_name}.html\" title=\"{short_doc}\">{self}</a>"
+               end
+       end
+       
+       fun html_anchor: String do 
+               return "<a id=\"MOD_{html_name}\"></a>"
+       end
+       
+       fun html_link_to_anchor: String do 
+               return "<a href=\"#MOD_{html_name}\" title=\"Jump to definitions from module {html_name}\">{self}</a>"
+       end
+
+       redef fun json_entry(dctx) do
+               return "\{txt:\"{self.qualified_name}\",url:\"{html_name}.html\"\},"
+       end
+
+       redef fun qualified_name do
+               var buffer = new Buffer
+               for m in mnhe.smallers do
+                       buffer.append("{m.html_name}::")
+               end
+               buffer.append("{self.name}")
+               return buffer.to_s
        end
 
        fun require_doc(dctx: DocContext): Bool
@@ -547,13 +634,16 @@ redef class MMModule
                        dctx.add("{m.html_link(dctx)}::")
                end
                dctx.add("{self.name}</div>\n")
-
+               dctx.add("<div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
                dctx.add("<section class='description'>\n")
 
                var doc = doc
                if doc != null then
                        dctx.add("<div id=\"description\">\n")
-                       dctx.add("<pre>{doc.to_html}</pre>\n")
+                       dctx.add("<pre class=\"text_label\">{doc.to_html}</pre>\n")
+                       dctx.add("<textarea rows=\"1\" cols=\"76\" id=\"fileContent\" class=\"edit\"></textarea>\n")
+                       dctx.add("<a id=\"cancelBtn\">Cancel</a><a id=\"commitBtn\">Commit</a>")
+                       dctx.add("<pre id=\"preSave\" type=\"2\" class=\"text_label\" ></pre>")
                        dctx.add("</div>\n")
                end
 
@@ -776,7 +866,7 @@ redef class MMModule
                        var lpi = self[gp.intro.local_class.global][gp]
                        
                        lps.remove(lpi)
-                               dctx.add("<li class='intro'><span title='introduction'>I</span>&nbsp;{lpi.html_open_link(dctx)}{lpi.html_name}&nbsp;({lpi.local_class})</a></li>\n")
+                       dctx.add("<li class='intro'><span title='introduction'>I</span>&nbsp;{lpi.html_open_link(dctx)}{lpi.html_name}&nbsp;({lpi.local_class})</a></li>\n")
                        if lps.length >= 1 then
                                dctx.sort(lps)
                                for lp in lps do
@@ -787,14 +877,81 @@ redef class MMModule
                dctx.stage("</ul></article>\n")
                dctx.close_stage
        end
+
+       # Fill the quicksearch list JSON object
+       fun file_quicksearch_list_doc(dctx: DocContext)
+       do
+               var entities = new HashMap[String, Array[MMEntity]]
+               var props = new HashMap[MMGlobalProperty, Array[MMLocalProperty]]
+               for m in mhe.greaters_and_self do
+                       if not m.require_doc(dctx) then continue
+                       var a = new Array[MMEntity]
+                       a.add(m)
+                       entities[m.html_name] = a
+               end
+               for g in global_classes do
+                       var lc = self[g]
+                       if not lc.require_doc(dctx) then continue
+                       var a = new Array[MMEntity]
+                       a.add(lc)
+                       entities[lc.html_name] = a
+                       for gp in lc.global_properties do
+                               var lp = lc[gp]
+                               if not lp.require_doc(dctx) then continue
+                               if lp.kind == "var" then continue
+                               if props.has_key(lp.global) then
+                                       if not props[lp.global].has(lp) then
+                                               props[lp.global].add(lp)
+                                       end
+                               else
+                                       props[lp.global] = [lp]
+                               end
+                       end
+               end
+
+               for k, v in props do
+                       entities[k.short_name] = v
+               end
+
+               var keys = entities.keys.to_a
+               var sorter = new AlphaSorter[String]
+               sorter.sort(keys)
+               
+               dctx.open_stage
+               dctx.stage("var entries = \{")
+               for key in keys do
+                       dctx.add("\"{key}\": [")
+                       for entity in entities[key] do
+                               dctx.add(entity.json_entry(dctx))
+                       end
+                       dctx.add("],")
+               end
+               dctx.stage("\};")
+               dctx.close_stage
+       end
 end
 
+redef class MMGlobalProperty
+       # Return the short name of the property
+       fun short_name: String do
+               return self.intro.html_name
+       end
+end 
+
 redef class MMLocalProperty
        super MMEntity
        # Anchor of the property description in the module html file
        fun html_anchor: String
        do
-               return "PROP_{local_class}_{cmangle(name)}"
+               return "PROP_{self.mmmodule.toplevel_owner}_{local_class}_{cmangle(name)}"
+       end
+
+       redef fun json_entry(dctx) do
+               return "\{txt:\"{qualified_name}\",url:\"{local_class.html_name}.html#{html_anchor}\"\},"
+       end
+
+       redef fun qualified_name do
+               return "{intro_module.qualified_name}::{local_class.html_name}::{html_name}"
        end
 
        fun html_open_link(dctx: DocContext): String
@@ -914,7 +1071,6 @@ redef class MMLocalProperty
                dctx.add("<article id=\"{html_anchor}\" class=\"{kind} {visibility} {if is_redef then "redef" else ""}\">\n")
                dctx.add("<h3 class=\"signature\">{html_name}{signature.to_html(dctx, true)}</h3>\n")
                dctx.add("<div class=\"info\">\n")
-               #dctx.add("<p>LP: {self.mmmodule.html_link(dctx)}::{self.local_class.html_link(dctx)}::{self.html_link(dctx)}</p>")
 
                if is_redef then
                        dctx.add("redef ")
@@ -935,12 +1091,12 @@ redef class MMLocalProperty
                        dctx.add("::{mmmodule[intro_class.global].html_link(dctx)}")
                end
                if is_redef then
-                       dctx.add("::{mmmodule[intro_class.global][global].html_link(dctx)}")
+                       dctx.add("::{mmmodule[intro_class.global][global].global.intro.html_link(dctx)}")
                else
                        dctx.add("::{html_name}")
                end
                dctx.add("</div>")
-
+               dctx.add("<div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
                dctx.add("<div class=\"description\">")
 
                # Collect all refinement of the global property in the same global property
@@ -956,7 +1112,10 @@ redef class MMLocalProperty
                        end
                end
                if introdoc then
-                       dctx.add("<pre>{global.intro.doc.to_html}</pre>")
+                       dctx.add("<pre class=\"text_label\" name=\"{html_name}\" >{global.intro.doc.to_html}</pre>")
+                       dctx.add("<textarea rows=\"1\" cols=\"76\" id=\"fileContent\" class=\"edit\"></textarea>")
+                       dctx.add("<a id=\"cancelBtn\">Cancel</a><a id=\"commitBtn\">Commit</a>")
+                       dctx.add("<pre id=\"preSave\" type=\"2\" class=\"text_label\" ></pre>")
                end
 
                var tlmods = new Array[MMModule]
@@ -972,7 +1131,7 @@ redef class MMLocalProperty
                        var tlp
                        if tm.global_classes.has(lc.global) then
                                tlp = tm[lc.global][self.global]
-                               assert lps.has(tlp)
+                               #assert lps.has(tlp) # FIXME What this line is used for?
                        else if tm.global_classes.has(self.local_class.global) then
                                # Self is the inherited property. Process it
                                tlp = tm[self.local_class.global][self.global]
@@ -987,12 +1146,22 @@ redef class MMLocalProperty
                                dctx.add("<h4>In module {tm.html_link(dctx)} :</h4>")
                        end
 
-                       #dctx.add("<p>TLP: {tm} x {lc} : {tlp.full_name}</p>")
-
                        var doc = tlp.doc
+                       var n = tlp.node
                        if doc != null and (not introdoc or global.intro.doc != doc) then
-                               dctx.add("<pre>{doc.to_html}</pre>")
+                               if n != null then
+                                       var l = n.location
+                                       dctx.add("<pre type=\"1\" class=\"text_label\" tag=\"{l.file.filename}\" name=\"{dctx.get_source(l)}\" title=\"{l.line_start.to_s}\" >{doc.to_html}</pre>")
+                               end
+                       else if not is_redef then
+                               if n != null then
+                                       var l = n.location
+                                       dctx.add("<a class=\"newComment\" tag=\"{l.file.filename}\" title=\"{l.line_start.to_s}\">New comment</a>\n")
+                               end
                        end
+                       dctx.add("<textarea rows=\"1\" cols=\"76\" id=\"fileContent\" class=\"edit\"></textarea>")
+                       dctx.add("<a id=\"cancelBtn\">Cancel</a><a id=\"commitBtn\">Commit</a>")
+                       dctx.add("<pre id=\"preSave\" type=\"2\" class=\"text_label\" ></pre>")
                        dctx.add("<p>")
                        if tlp.local_class.global != lc.global then
                                dctx.add("inherited from {tlp.local_class.html_link(dctx)} ")
@@ -1000,7 +1169,6 @@ redef class MMLocalProperty
                        if tm != tlp.mmmodule then
                                dctx.add("defined by the module {tlp.mmmodule.html_link(dctx)} ")
                        end
-                       var n = tlp.node
                        if n != null then
                                var l = n.location
                                dctx.show_source(l)
@@ -1014,7 +1182,7 @@ redef class MMLocalProperty
                                if lp == tlp then continue
                                dctx.add(" {lp.mmmodule.html_link(dctx)}")
                                if lp.local_class.global != lc.global then
-                                       dctx.add(" for {lp.local_class.html_link(dctx)}")
+                                       dctx.add(" for {lp.local_class.html_link(dctx)} ")
                                end
 
                                n = lp.node
@@ -1022,11 +1190,6 @@ redef class MMLocalProperty
                                        var l = n.location
                                        dctx.show_source(l)
                                end
-
-                               #var doc = lp.doc
-                               #if doc != null and (not introdoc or global.intro.doc != doc) then
-                               #       dctx.add("<pre>{doc.to_html}</pre>")
-                               #end
                        end
                        dctx.close_stage
                        dctx.add("</p>")
@@ -1104,7 +1267,19 @@ redef class MMLocalClass
        redef fun html_link(dctx)
        do
                if not require_doc(dctx) then print "{dctx.filename}: not required {self}"
-               return "<a href=\"{html_name}.html\" title=\"{short_doc}\">{self}</a>"
+               if short_doc == "&nbsp;" then
+                       return "<a href=\"{html_name}.html\"\">{self}</a>"
+               else 
+                       return "<a href=\"{html_name}.html\" title=\"{short_doc}\">{self}</a>"
+               end
+       end
+
+       redef fun json_entry(dctx) do
+               return "\{txt:\"{qualified_name}\",url:\"{html_name}.html\"\},"
+       end
+
+       redef fun qualified_name do
+               return "{intro_module.qualified_name}::{html_name}"
        end
 
        redef fun short_doc do return global.intro.short_doc
@@ -1265,11 +1440,15 @@ redef class MMLocalClass
                        dctx.add("(unexported) ")
                end
                dctx.add("{kind} {global.intro.mmmodule.toplevel_owner.html_link(dctx)}::{name}</div>")
-
+               dctx.add("<div style=\"float: right;\"><a id=\"lblDiffCommit\"></a></div>")
                dctx.add("<section class=\"description\">\n")
                var doc = doc
                if doc != null then
-                       dctx.add("<pre>{doc.to_html}</pre>\n")
+                       var l = doc.location
+                       dctx.add("<pre type=\"2\" class=\"text_label\" tag=\"{l.file.filename}\" name=\"{dctx.get_source(l)}\" title=\"{l.line_start.to_s}\">{doc.to_html}</pre>\n")
+                       dctx.add("<textarea rows=\"1\" cols=\"76\" id=\"fileContent\" class=\"edit\"></textarea>")
+                       dctx.add("<a id=\"cancelBtn\">Cancel</a><a id=\"commitBtn\">Commit</a>")
+                       dctx.add("<pre id=\"preSave\" type=\"2\" class=\"text_label\" ></pre>")
                end
 
                var cla = new HashSet[MMLocalClass]
@@ -1314,7 +1493,12 @@ redef class MMLocalClass
                end
                op.append("\}\n")
                dctx.gen_dot(op.to_s, name.to_s, "Inheritance graph for class {name}")
+               dctx.add("</section>\n")
 
+               # Concerns table
+               dctx.open_stage
+               dctx.stage("<section class=\"concerns\">\n")
+               dctx.stage("<h2 class=\"section-header\">Concerns</h2>\n")
 
                var mods = new Array[MMModule]
                mods.add(global.intro.mmmodule.toplevel_owner)
@@ -1323,28 +1507,28 @@ redef class MMLocalClass
                        var m = lc.mmmodule.toplevel_owner
                        if not mods.has(m) then mods.add(m)
                end
-               dctx.sort(mods)
+               
+               var intro = global.intro.mmmodule
+               var short_doc
+               dctx.add("<ul>\n")
                for m in mods do
-                       if m == global.intro.mmmodule.toplevel_owner then
-                               dctx.add("<p>Introduced by {m.html_link(dctx)}")
-                       else
-                               dctx.add("<p>Refined by {m.html_link(dctx)}")
-                       end
-                       dctx.open_stage
-                       dctx.stage(". Definition in:")
-                       for lc in crhe.greaters do
+                       short_doc = ""
+                       if m.short_doc != "&nbsp;" then short_doc = ": {m.short_doc}"
+                       dctx.add("<li>{m.html_link_to_anchor}{short_doc}")
+                       dctx.add("<ul>\n")
+                       for lc in crhe.linear_extension.reversed do
                                if lc.mmmodule.toplevel_owner != m then continue
-                               dctx.add(" {lc.mmmodule.html_link(dctx)}")
-                               assert lc isa MMSrcLocalClass
-                               var n = lc.node
-                               if n != null then
-                                       dctx.show_source(n.location)
-                               end
+                               if lc.mmmodule == m then continue
+                               short_doc = ""
+                               if lc.mmmodule.short_doc != "&nbsp;" then short_doc = ": {lc.mmmodule.short_doc}"
+                               dctx.add("<li>{lc.mmmodule.html_link_to_anchor}{short_doc}</li>")
                        end
-                       dctx.close_stage
-                       dctx.add("</p>\n")
+                       dctx.add("</ul>\n")
+                       dctx.add("</li>\n")
                end
-               dctx.add("</section>\n")
+               dctx.add("</ul>\n")
+               dctx.stage("</section>\n")
+               dctx.close_stage
 
                dctx.open_stage
                dctx.stage("<section class=\"types\">\n")
@@ -1373,23 +1557,89 @@ redef class MMLocalClass
                dctx.open_stage
                dctx.stage("<section class=\"methods\">\n")
                dctx.stage("<h2 class=\"section-header\">Methods</h2>\n")
+               var redefs = new HashMap[MMModule, HashMap[MMModule, Array[MMMethod]]]
                for p in props do
                        if p.global.is_init then continue
                        if p.local_class.global != self.global then continue
                        if not p isa MMMethod then continue
-                       p.full_documentation(dctx, self)
+                       # Top level module
+                       var toplevel_module = p.mmmodule.toplevel_owner
+                       if not redefs.has_key(toplevel_module) then
+                               redefs[toplevel_module] = new HashMap[MMModule, Array[MMMethod]]
+                       end
+                       # Nested module
+                       var nested_module = p.mmmodule
+                       if not redefs[toplevel_module].has_key(nested_module) then
+                               redefs[toplevel_module][nested_module] = new Array[MMMethod]
+                       end
+                       # Props
+                       redefs[toplevel_module][nested_module].add(p)
+                       
+                       # Redefs
+                       if p.mmmodule.toplevel_owner != p.intro_module then
+                               toplevel_module = p.intro_module
+                               nested_module = p.global.intro.mmmodule
+                               
+                               if not redefs.has_key(toplevel_module) then
+                                       redefs[toplevel_module] = new HashMap[MMModule, Array[MMMethod]]
+                               end
+                               if not redefs[toplevel_module].has_key(nested_module) then
+                                       redefs[toplevel_module][nested_module] = new Array[MMMethod]
+                               end
+                       
+                               redefs[toplevel_module][nested_module].add(p.global.intro.as(MMMethod))
+                       end
+               end
+               
+               # Display toplevel blocks               
+               for m in mods do
+                       if not redefs.has_key(m) then continue
+                       dctx.add(m.html_anchor)
+                       if m != global.intro.mmmodule.toplevel_owner then
+                               dctx.add("<h3 class=\"concern-toplevel\">Methods refined in {m.html_link(dctx)}</h3>")
+                       end
+                       
+                       # Display nested module blocks
+                       for lc in crhe.linear_extension.reversed do
+                               if lc.mmmodule.toplevel_owner != m then continue
+                               var nm =  lc.mmmodule
+                               if not redefs[m].has_key(nm) then continue
+                               dctx.add(nm.html_anchor)
+                               if nm != global.intro.mmmodule then
+                                       short_doc = ""
+                                       if nm.short_doc != "&nbsp;" then short_doc = ": {nm.short_doc}" 
+                                       dctx.add("<p class=\"concern-doc\">{nm.html_name}{short_doc}</p>\n")
+                               end
+                       
+                               var pps = redefs[m][nm]
+                               dctx.sort(pps)
+                               for p in pps do
+                                       p.full_documentation(dctx, self)
+                               end                                     
+                       end
                end
+
                if not inhs.is_empty then
                        dctx.open_stage
                        dctx.stage("<h3>Inherited Methods</h3>\n")
                        for lc in inhs do
                                dctx.open_stage
                                dctx.stage("<p>Defined in {lc.html_link(dctx)}:")
+                               
+                               var ims = new Array[MMMethod] 
                                for p in inh[lc] do
                                        if p.global.is_init then continue
                                        if not p isa MMMethod then continue
+                                       ims.add(p)
+                               end
+                               
+                               var i = 0
+                               for p in ims do 
                                        dctx.add(" {p.html_link(dctx)}")
+                                       if i < ims.length - 1 then dctx.add(",")
+                                       i += 1
                                end
+                               
                                dctx.stage("</p>")
                                dctx.close_stage
                        end