nitdoc: Adding a command line option
authorStefan Lage <lagestfan@gmail.com>
Fri, 3 May 2013 22:45:01 +0000 (18:45 -0400)
committerStefan Lage <lagestfan@gmail.com>
Thu, 23 May 2013 21:26:51 +0000 (17:26 -0400)
This option allow to inform about the github repository.
If this option is used it's added in each HTML file built

signed-off by: Stefan Lage <lagestfan@gmail.com>

src/nitdoc.nit

index 9196911..e676f22 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)
 
@@ -91,6 +92,7 @@ class DocContext
        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
@@ -182,6 +184,7 @@ class DocContext
                # generate the index
                self.filename = "index.html"
                clear
+               addGithubInformation
                add("<!DOCTYPE html>")
                add("<html><head>{head}<title>Overview | {custom_title}</title></head><body>\n")
                add(action_bar)
@@ -226,6 +229,7 @@ class DocContext
                        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"
                        clear
+                       addGithubInformation
                        add("<!DOCTYPE html>")
                        add("<html><head>{head}<title>{mod.name} module | {custom_title}</title></head><body>\n")
                        add(action_bar)
@@ -243,6 +247,7 @@ class DocContext
                        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"
                        clear
+                       addGithubInformation
                        add("<!DOCTYPE html>")
                        add("<html><head>{head}<title>{c.name} class | {custom_title}</title></head><body>\n")
                        add(action_bar)
@@ -257,6 +262,7 @@ class DocContext
                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"
                clear
+               addGithubInformation
                add("<!DOCTYPE html>")
                add("<html><head>{head}<title>Full Index | {custom_title}</title></head><body>\n")
                add(action_bar)
@@ -274,7 +280,11 @@ class DocContext
                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 a (source) link fo a given location
        fun show_source(l: Location)
@@ -325,6 +335,7 @@ class DocContext
                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
@@ -361,6 +372,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)