nitdoc: introduce MakePagePhase
[nit.git] / src / doc / doc_pages.nit
index 38e6cdf..604b415 100644 (file)
@@ -24,10 +24,7 @@ redef class ToolContext
        private var opt_source = new OptionString("link for source (%f for filename, %l for first line, %L for last line)", "--source")
        private var opt_sharedir = new OptionString("directory containing nitdoc assets", "--sharedir")
        private var opt_shareurl = new OptionString("use shareurl instead of copy shared files", "--shareurl")
-       private var opt_no_attributes = new OptionBool("ignore the attributes",
-                       "--no-attributes")
        private var opt_nodot = new OptionBool("do not generate graphes with graphviz", "--no-dot")
-       private var opt_private = new OptionBool("also generate private API", "--private")
 
        private var opt_custom_title = new OptionString("custom title for homepage", "--custom-title")
        private var opt_custom_brand = new OptionString("custom link to external site", "--custom-brand")
@@ -49,15 +46,10 @@ redef class ToolContext
 
                var opts = option_context
                opts.add_option(opt_dir, opt_source, opt_sharedir, opt_shareurl,
-                               opt_no_attributes, opt_nodot, opt_private)
+                               opt_nodot)
                opts.add_option(opt_custom_title, opt_custom_footer, opt_custom_intro, opt_custom_brand)
                opts.add_option(opt_github_upstream, opt_github_base_sha1, opt_github_gitdir)
                opts.add_option(opt_piwik_tracker, opt_piwik_site_id)
-
-               var tpl = new Template
-               tpl.add "Usage: nitdoc [OPTION]... <file.nit>...\n"
-               tpl.add "Generates HTML pages of API documentation from Nit source files."
-               tooldescription = tpl.write_to_string
        end
 
        redef fun process_options(args) do
@@ -69,12 +61,6 @@ redef class ToolContext
                        output_dir = "doc"
                end
                self.output_dir = output_dir
-               # min visibility
-               if opt_private.value then
-                       min_visibility = none_visibility
-               else
-                       min_visibility = protected_visibility
-               end
                # github urls
                var gh_upstream = opt_github_upstream.value
                var gh_base_sha = opt_github_base_sha1.value
@@ -86,23 +72,6 @@ redef class ToolContext
                        end
                end
        end
-
-       # Filter the entity based on the options specified by the user.
-       #
-       # Return `true` if the specified entity has to be included in the generated
-       # documentation
-       private fun filter_mclass(mclass: MClass): Bool do
-               return mclass.visibility >= min_visibility
-       end
-
-       # Filter the entity based on the options specified by the user.
-       #
-       # Return `true` if the specified entity has to be included in the generated
-       # documentation
-       private fun filter_mproperty(mproperty: MProperty): Bool do
-               return mproperty.visibility >= min_visibility and
-                       not (opt_no_attributes.value and mproperty isa MAttribute)
-       end
 end
 
 # The Nitdoc class explores the model and generate pages for each mentities found
@@ -111,17 +80,6 @@ class Nitdoc
        var model: Model
        var mainmodule: MModule
 
-       fun generate do
-               init_output_dir
-               overview
-               search
-               groups
-               modules
-               classes
-               properties
-               quicksearch_list
-       end
-
        private fun init_output_dir do
                # create destination dir if it's necessary
                var output_dir = ctx.output_dir
@@ -144,55 +102,6 @@ class Nitdoc
                end
 
        end
-
-       private fun overview do
-               var page = new NitdocOverview(ctx, model, mainmodule)
-               page.render.write_to_file("{ctx.output_dir.to_s}/{page.page_url}")
-       end
-
-       private fun search do
-               var page = new NitdocSearch(ctx, model, mainmodule)
-               page.render.write_to_file("{ctx.output_dir.to_s}/{page.page_url}")
-       end
-
-       private fun groups do
-               for mproject in model.mprojects do
-                       for mgroup in mproject.mgroups.to_a do
-                               var page = new NitdocGroup(ctx, model, mainmodule, mgroup)
-                               page.render.write_to_file("{ctx.output_dir.to_s}/{page.page_url}")
-                       end
-               end
-       end
-
-       private fun modules do
-               for mmodule in model.mmodules do
-                       if mmodule.is_fictive or mmodule.is_test_suite then continue
-                       var page = new NitdocModule(ctx, model, mainmodule, mmodule)
-                       page.render.write_to_file("{ctx.output_dir.to_s}/{page.page_url}")
-               end
-       end
-
-       private fun classes do
-               for mclass in model.mclasses do
-                       if not ctx.filter_mclass(mclass) then continue
-                       var page = new NitdocClass(ctx, model, mainmodule, mclass)
-                       page.render.write_to_file("{ctx.output_dir.to_s}/{page.page_url}")
-               end
-       end
-
-       private fun properties do
-               for mproperty in model.mproperties do
-                       if not ctx.filter_mproperty(mproperty) then continue
-                       if mproperty isa MInnerClass then continue
-                       var page = new NitdocProperty(ctx, model, mainmodule, mproperty)
-                       page.render.write_to_file("{ctx.output_dir.to_s}/{page.page_url}")
-               end
-       end
-
-       private fun quicksearch_list do
-               var quicksearch = new QuickSearch(ctx, model)
-               quicksearch.render.write_to_file("{ctx.output_dir.to_s}/quicksearch-list.js")
-       end
 end
 
 # Nitdoc QuickSearch list generator
@@ -1418,74 +1327,6 @@ class NitdocClass
        end
 end
 
-# Groups properties by kind.
-private class PropertiesByKind
-       # The virtual types.
-       var virtual_types = new PropertyGroup[MVirtualTypeProp]("Virtual types")
-
-       # The constructors.
-       var constructors = new PropertyGroup[MMethod]("Contructors")
-
-       # The attributes.
-       var attributes = new PropertyGroup[MAttribute]("Attributes")
-
-       # The methods.
-       var methods = new PropertyGroup[MMethod]("Methods")
-
-       # The inner classes.
-       var inner_classes = new PropertyGroup[MInnerClass]("Inner classes")
-
-       # All the groups.
-       #
-       # Sorted in the order they are displayed to the user.
-       var groups: SequenceRead[PropertyGroup[MProperty]] = [
-                       virtual_types,
-                       constructors,
-                       attributes,
-                       methods,
-                       inner_classes: PropertyGroup[MProperty]]
-
-       # Add each the specified property to the appropriate list.
-       init with_elements(properties: Collection[MProperty]) do add_all(properties)
-
-       # Add the specified property to the appropriate list.
-       fun add(property: MProperty) do
-               if property isa MMethod then
-                       if property.is_init then
-                               constructors.add property
-                       else
-                               methods.add property
-                       end
-               else if property isa MVirtualTypeProp then
-                       virtual_types.add property
-               else if property isa MAttribute then
-                       attributes.add property
-               else if property isa MInnerClass then
-                       inner_classes.add property
-               else
-                       abort
-               end
-       end
-
-       # Add each the specified property to the appropriate list.
-       fun add_all(properties: Collection[MProperty]) do
-               for p in properties do add(p)
-       end
-
-       # Sort each group with the specified comparator.
-       fun sort_groups(comparator: Comparator) do
-               for g in groups do comparator.sort(g)
-       end
-end
-
-# A Group of properties of the same kind.
-private class PropertyGroup[E: MProperty]
-       super Array[E]
-
-       # The title of the group, as displayed to the user.
-       var title: String
-end
-
 # A MProperty page
 class NitdocProperty
        super NitdocPage