X-Git-Url: http://nitlanguage.org diff --git a/src/nitdoc.nit b/src/nitdoc.nit index 18e1d0c..104bfef 100644 --- a/src/nitdoc.nit +++ b/src/nitdoc.nit @@ -24,27 +24,27 @@ import abstracttool # Store knowledge and facilities to generate files class DocContext -special AbstractCompiler + super AbstractCompiler # Destination directory - readable writable attr _dir: String = "." + readable writable var _dir: String = "doc" # Content of a generated file - attr _stage_context: StageContext = new StageContext(null) + var _stage_context: StageContext = new StageContext(null) # Add a string in the content - meth add(s: String) do + fun add(s: String) do _stage_context.content.add(s) _stage_context.validate = true end # Add a string in the content iff some other string are added - meth stage(s: String) do _stage_context.content.add(s) + fun stage(s: String) do _stage_context.content.add(s) # Create a new stage in the content - meth open_stage do _stage_context = new StageContext(_stage_context) + fun open_stage do _stage_context = new StageContext(_stage_context) # Close the current stage in the content - meth close_stage + fun close_stage do var s = _stage_context.parent if _stage_context.validate then @@ -56,9 +56,8 @@ special AbstractCompiler end # Write the content to a new file - meth write_to(filename: String) + fun write_to(filename: String) do - print "Generate {filename}" var f = new OFStream.open(filename) for s in _stage_context.content do f.write(s) @@ -66,209 +65,274 @@ special AbstractCompiler f.close end - # Currently computed module - readable attr _module: nullable MMSrcModule - - # Is the current directory module computed as a simple modude ? - readable writable attr _inside_mode: Bool = false - - # Is the current module computed as a intruded one ? - readable writable attr _intrude_mode: Bool = false + # Start a new file + fun clear + do + _stage_context = new StageContext(null) + end - # Compued introducing entities (for the index) - attr _entities: Array[MMEntity] = new Array[MMEntity] + # Sorter of entities in alphabetical order + var _sorter: AlphaSorter[MMEntity] = new AlphaSorter[MMEntity] - # Register an entity (for the index) - meth register(e: MMEntity) + # Sort entities in the alphabetical order + fun sort(array: Array[MMEntity]) do - _entities.add(e) - if e isa MMSrcModule then - _module = e - end + _sorter.sort(array) end - # Start a new file - meth clear + readable var _opt_dir: OptionString = new OptionString("Directory where doc is generated", "-d", "--dir") + readable var _opt_source: OptionString = new OptionString("What link for source (%f for filename, %l for first line, %L for last line)", "--source") + readable var _opt_public: OptionBool = new OptionBool("Generate only the public API", "--public") + + fun public_only: Bool do - _stage_context = new StageContext(null) + if self._opt_public.value == true then return true + return false end - # Generate common files (frames, index, overview) - meth extract_other_doc + # The current processed filename + var filename: String + + # The main virtual module + var mainmod: nullable MMVirtualModule + + redef fun perform_work(mods) do - _module = null - inside_mode = false - intrude_mode = false - clear - add("
\n") - add("Overview