Fix nitdoc
authorJean Privat <jean@pryen.org>
Wed, 26 Nov 2008 22:39:18 +0000 (17:39 -0500)
committerJean Privat <jean@pryen.org>
Wed, 26 Nov 2008 22:39:18 +0000 (17:39 -0500)
src/nitc.nit
src/nitdoc.nit
src/syntax/syntax.nit

index eb0e0e0..a3c9fa6 100644 (file)
@@ -41,41 +41,40 @@ special AbstractCompiler
        redef meth process_options
        do
                super
-               tc = new ToolContext
-               tc.output_file = opt_output.value
-               tc.boost = opt_boost.value
-               tc.no_cc = opt_no_cc.value
-               tc.ext_prefix = opt_extension_prefix.value
-               if tc.ext_prefix == null then tc.ext_prefix = ""
-               tc.attr_sim = opt_attr_sim.value
-               tc.global = opt_global.value
-               tc.base_dir = ".nit_compile"
-               tc.clibdir = opt_clibdir.value
-               if tc.clibdir == null then
+               output_file = opt_output.value
+               boost = opt_boost.value
+               no_cc = opt_no_cc.value
+               ext_prefix = opt_extension_prefix.value
+               if ext_prefix == null then ext_prefix = ""
+               attr_sim = opt_attr_sim.value
+               global = opt_global.value
+               base_dir = ".nit_compile"
+               clibdir = opt_clibdir.value
+               if clibdir == null then
                        var dir = once ("NIT_DIR".to_symbol).environ
                        if dir.is_empty then 
                                var dir = "{sys.program_name.dirname}/../lib"
-                               if dir.file_exists then tc.clibdir = dir
+                               if dir.file_exists then clibdir = dir
                        else
                                dir = "{dir}/lib"
-                               if dir.file_exists then tc.clibdir = dir
+                               if dir.file_exists then clibdir = dir
                        end
-                       if tc.clibdir == null then
+                       if clibdir == null then
                                error("Error: Cannot locate NIT C library directory. Uses --clibdir or envvar NIT_DIR.")
                                exit(1)
                        end
                end
-               tc.bindir = opt_bindir.value
-               if tc.bindir == null then
+               bindir = opt_bindir.value
+               if bindir == null then
                        var dir = once ("NIT_DIR".to_symbol).environ
                        if dir.is_empty then 
                                var dir = "{sys.program_name.dirname}/../bin"
-                               if dir.file_exists then tc.bindir = dir
+                               if dir.file_exists then bindir = dir
                        else
                                dir = "{dir}/bin"
-                               if dir.file_exists then tc.bindir = dir
+                               if dir.file_exists then bindir = dir
                        end
-                       if tc.bindir == null then
+                       if bindir == null then
                                error("Error: Cannot locate NIT tools directory. Uses --bindir or envvar NIT_DIR.")
                                exit(1)
                        end
@@ -86,7 +85,7 @@ special AbstractCompiler
        do
                for mod in mods do
                        assert mod isa MMSrcModule
-                       mod.compile_prog_to_c(tc)
+                       mod.compile_prog_to_c(self)
                end
 
        end
index fbd2c85..2bfb3ad 100644 (file)
@@ -24,7 +24,7 @@ import abstracttool
 
 # Store knowledge and facilities to generate files
 class DocContext
-special ToolContext
+special AbstractCompiler
        # Destination directory
        readable writable attr _dir: String
 
@@ -92,8 +92,6 @@ special ToolContext
                _stage_context = new StageContext(null)
        end
 
-       redef init do end
-
        # Generate common files (frames, index, overview)
        meth extract_other_doc
        do
@@ -231,6 +229,32 @@ special ToolContext
                        return res
                end
        end
+
+       readable attr _opt_dir: OptionString = new OptionString("Directory where doc is generated", "-d", "--dir")
+
+       redef meth perform_work(mods)
+       do
+               dir.mkdir
+
+               for mod in modules do
+                       assert mod isa MMSrcModule
+                       mod.extract_module_doc(self)
+               end
+               self.extract_other_doc
+       end
+
+       redef init
+       do
+               super
+               option_context.add_option(opt_dir)
+       end
+
+       redef meth process_options
+       do
+               super
+               dir = opt_dir.value
+               if dir == null then dir = "."
+       end
 end
 
 # Conditionnal part of the text content of a DocContext
@@ -433,7 +457,7 @@ special MMEntity
        do
                var res = signature.to_html(dctx)
                var s = self
-               if s isa MMSrcLocalProperty then
+               if s isa MMConcreteProperty then
                        if s.node isa ADeferredMethPropdef then
                                res.append(" is abstract")
                        else if s.node isa AInternMethPropdef then
@@ -454,20 +478,9 @@ redef class MMTypeProperty
 end
 
 redef class MMSrcModule
-       # Extract doc for the module and its supermodules 
-       meth extract_all_modules_doc(dctx: DocContext)
-       do
-               for m in mhe.greaters_and_self do
-                       assert m isa MMSrcModule
-                       m.extract_module_doc(dctx)
-               end
-       end     
-
-       # Extract and generate html file fhe the module
+       # Extract and generate html file for the module
        meth extract_module_doc(dctx: DocContext)
        do
-               if dctx.modules.has(self) then return
-
                dctx.register(self)
 
                dctx.clear
@@ -1051,7 +1064,7 @@ redef class MMSrcLocalClass
        end
 end
 
-redef class MMSrcLocalProperty
+redef class MMConcreteProperty
        redef meth need_doc(dctx)
        do
                if global.visibility_level >= 3 or self isa MMAttribute then
@@ -1142,42 +1155,5 @@ redef class MMTypeGeneric
        end
 end
 
-
-# The main class of the nitdoc program
-class NitDoc
-special AbstractCompiler
-       readable attr _opt_dir: OptionString = new OptionString("Directory where doc is generated", "-d", "--dir")
-
-       redef meth perform_work(mods)
-       do
-               var dctx = tc
-               assert dctx isa DocContext
-
-               dctx.dir.mkdir
-
-               for mod in mods do
-                       assert mod isa MMSrcModule
-                       mod.extract_all_modules_doc(dctx)
-               end
-               dctx.extract_other_doc
-       end
-
-       redef init
-       do
-               super
-               option_context.add_option(opt_dir)
-       end
-
-       redef meth process_options
-       do
-               super
-               var dctx = new DocContext
-               dctx.dir = opt_dir.value
-               if dctx.dir == null then dctx.dir = "."
-
-               tc = dctx
-       end
-end
-
-var c = new NitDoc
+var c = new DocContext
 c.exec_cmd_line
index 1bc71de..6536478 100644 (file)
@@ -58,11 +58,6 @@ special ModuleLoader
        init do end
 end
 
-redef class MMContext
-       # The current configuration/status of the tool
-        readable writable attr _tc: ToolContext 
-end
-
 redef class MMSrcModule
        # Loading and syntax analysis of super modules
        private meth process_supermodules(tc: ToolContext)