src/doc: introduce option --no-render in HTML phase.
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 19 Oct 2015 22:57:57 +0000 (18:57 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 19 Oct 2015 22:57:57 +0000 (18:57 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/doc_phases/doc_html.nit
src/nitdoc.nit
tests/nitdoc.args

index ebc1193..30a15c2 100644 (file)
@@ -70,6 +70,9 @@ redef class ToolContext
        # FIXME redo the plugin
        var opt_github_gitdir = new OptionString("Git working directory used to resolve path name (ex: /home/me/mypackage/)", "--github-gitdir")
 
+       # Do not produce HTML files
+       var opt_no_render = new OptionBool("do not render HTML files", "--no-render")
+
        redef init do
                super
 
@@ -77,7 +80,8 @@ redef class ToolContext
                        opt_source, opt_sharedir, opt_shareurl, opt_custom_title,
                        opt_custom_footer, opt_custom_intro, opt_custom_brand,
                        opt_github_upstream, opt_github_base_sha1, opt_github_gitdir,
-                       opt_piwik_tracker, opt_piwik_site_id)
+                       opt_piwik_tracker, opt_piwik_site_id,
+                       opt_no_render)
        end
 
        redef fun process_options(args) do
@@ -103,6 +107,7 @@ class RenderHTMLPhase
        var name_sorter = new MEntityNameSorter
 
        redef fun apply do
+               if ctx.opt_no_render.value then return
                init_output_dir
                for page in doc.pages.values do
                        page.render(self, doc).write_to_file("{ctx.output_dir.to_s}/{page.html_url}")
index bda79e7..1e6059b 100644 (file)
@@ -26,7 +26,7 @@ redef class ToolContext
        var docphase: Phase = new Nitdoc(self, null)
 
        # File pattern used to link documentation to source code.
-       var opt_test = new OptionBool("do not render anything, only print test data", "--test")
+       var opt_test = new OptionBool("print test data", "--test")
 
        redef init do
                super
@@ -52,11 +52,8 @@ private class Nitdoc
                        new IntroRedefListPhase(toolcontext, doc),
                        new LinListPhase(toolcontext, doc),
                        new GraphPhase(toolcontext, doc),
-                       new ReadmePhase(toolcontext, doc): DocPhase]
-
-               if not toolcontext.opt_test.value then
-                       phases.add new RenderHTMLPhase(toolcontext, doc)
-               end
+                       new ReadmePhase(toolcontext, doc),
+                       new RenderHTMLPhase(toolcontext, doc): DocPhase]
 
                for phase in phases do
                        toolcontext.info("# {phase.class_name}", 1)
index de4c3e4..ee5fd03 100644 (file)
@@ -1,4 +1,4 @@
 module_1.nit -d $WRITE
 base_attr_nullable.nit -d $WRITE
 --private base_attr_nullable.nit -d $WRITE
---test test_prog -d $WRITE
+--no-render --test test_prog -d $WRITE