nitdoc: Inform if a comment was already modify
[nit.git] / src / nitdoc.nit
index e676f22..50bd192 100644 (file)
@@ -170,8 +170,7 @@ class DocContext
                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></ul></nav></header>\n"
-                                                       
+               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)
                
@@ -185,6 +184,7 @@ class DocContext
                self.filename = "index.html"
                clear
                addGithubInformation
+               addCommitForm
                add("<!DOCTYPE html>")
                add("<html><head>{head}<title>Overview | {custom_title}</title></head><body>\n")
                add(action_bar)
@@ -227,9 +227,10 @@ 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>{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></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
                        addGithubInformation
+                       addCommitForm
                        add("<!DOCTYPE html>")
                        add("<html><head>{head}<title>{mod.name} module | {custom_title}</title></head><body>\n")
                        add(action_bar)
@@ -245,9 +246,10 @@ 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>{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></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
                        addGithubInformation
+                       addCommitForm
                        add("<!DOCTYPE html>")
                        add("<html><head>{head}<title>{c.name} class | {custom_title}</title></head><body>\n")
                        add(action_bar)
@@ -260,9 +262,10 @@ class DocContext
                end
 
                self.filename = "fullindex"
-               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></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
                addGithubInformation
+               addCommitForm
                add("<!DOCTYPE html>")
                add("<html><head>{head}<title>Full Index | {custom_title}</title></head><body>\n")
                add(action_bar)
@@ -286,6 +289,11 @@ class DocContext
                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
@@ -304,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 {...)
@@ -608,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
 
@@ -837,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
@@ -1042,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 ")
@@ -1068,7 +1096,7 @@ redef class MMLocalProperty
                        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
@@ -1084,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]
@@ -1115,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)} ")
@@ -1128,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)
@@ -1150,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>")
@@ -1405,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]