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
do
for mod in mods do
assert mod isa MMSrcModule
- mod.compile_prog_to_c(tc)
+ mod.compile_prog_to_c(self)
end
end
# Store knowledge and facilities to generate files
class DocContext
-special ToolContext
+special AbstractCompiler
# Destination directory
readable writable attr _dir: String
_stage_context = new StageContext(null)
end
- redef init do end
-
# Generate common files (frames, index, overview)
meth extract_other_doc
do
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
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
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
end
end
-redef class MMSrcLocalProperty
+redef class MMConcreteProperty
redef meth need_doc(dctx)
do
if global.visibility_level >= 3 or self isa MMAttribute then
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
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)