From: Jean Privat Date: Fri, 28 Aug 2015 03:49:33 +0000 (-0400) Subject: src: mass rename project->package X-Git-Tag: v0.7.8~35^2~4 X-Git-Url: http://nitlanguage.org src: mass rename project->package Signed-off-by: Jean Privat --- diff --git a/src/doc/console_templates/console_model.nit b/src/doc/console_templates/console_model.nit index 5d693b1..96b1a40 100644 --- a/src/doc/console_templates/console_model.nit +++ b/src/doc/console_templates/console_model.nit @@ -39,7 +39,7 @@ redef class MEntity # Returns the mentity name with short signature. # - # * MProject: `foo` + # * MPackage: `foo` # * MGroup: `foo` # * MModule: `foo` # * MClass: `Foo[E]` @@ -53,7 +53,7 @@ redef class MEntity # Returns the complete MEntity declaration (modifiers + name + signature). # - # * MProject: `project foo` + # * MPackage: `package foo` # * MGroup: `group foo` # * MModule: `module foo` # * MClass: `private abstract class Foo[E: Object]` @@ -70,10 +70,10 @@ redef class MEntity # Returns `self` namespace formatted for console. # - # * MProject: `mproject` - # * MGroup: `mproject(::group)` + # * MPackage: `mpackage` + # * MGroup: `mpackage(::group)` # * MModule: `mgroup::mmodule` - # * MClass: `mproject::mclass` + # * MClass: `mpackage::mclass` # * MClassDef: `mmodule::mclassdef` # * MProperty: `mclass::mprop` # * MPropdef: `mclassdef:mpropdef` @@ -158,8 +158,8 @@ redef class MEntity end end -redef class MProject - redef var cs_modifiers = ["project"] +redef class MPackage + redef var cs_modifiers = ["package"] redef fun cs_namespace do return cs_name redef fun cs_icon do return "P" redef fun cs_location do return root.mmodules.first.location.to_s @@ -171,12 +171,12 @@ redef class MGroup # Depends if `self` is root or not. # - # * If root `mproject`. - # * Else `mproject::self`. + # * If root `mpackage`. + # * Else `mpackage::self`. redef fun cs_namespace do var tpl = new FlatBuffer - tpl.append mproject.cs_namespace - if mproject.root != self then + tpl.append mpackage.cs_namespace + if mpackage.root != self then tpl.append "::" tpl.append cs_name end @@ -230,10 +230,10 @@ redef class MClass redef fun cs_modifiers do return intro.cs_modifiers redef fun cs_declaration do return intro.cs_declaration - # Returns `mproject::self`. + # Returns `mpackage::self`. redef fun cs_namespace do var tpl = new FlatBuffer - tpl.append intro_mmodule.mgroup.mproject.cs_namespace + tpl.append intro_mmodule.mgroup.mpackage.cs_namespace tpl.append "::" tpl.append cs_name return tpl.write_to_string diff --git a/src/doc/console_templates/console_templates.nit b/src/doc/console_templates/console_templates.nit index 6e8f03e..fbeea29 100644 --- a/src/doc/console_templates/console_templates.nit +++ b/src/doc/console_templates/console_templates.nit @@ -73,7 +73,7 @@ redef class ConcernSection redef fun rendering do var mentity = self.mentity - if mentity isa MGroup and mentity.mproject.root == mentity then + if mentity isa MGroup and mentity.mpackage.root == mentity then render_body else super diff --git a/src/doc/doc_phases/doc_extract.nit b/src/doc/doc_phases/doc_extract.nit index 456d545..d35abfa 100644 --- a/src/doc/doc_phases/doc_extract.nit +++ b/src/doc/doc_phases/doc_extract.nit @@ -55,7 +55,7 @@ class ExtractionPhase doc.populate(self) end - # Should we exclude this `mproject` from the documentation? + # Should we exclude this `mpackage` from the documentation? fun ignore_mentity(mentity: MEntity): Bool do if mentity isa MModule then return mentity.is_fictive or mentity.is_test_suite @@ -79,8 +79,8 @@ end # TODO Should I rebuild a new Model from filtered data? redef class DocModel - # MProjects that will be documented. - var mprojects = new HashSet[MProject] + # MPackages that will be documented. + var mpackages = new HashSet[MPackage] # MGroups that will be documented. var mgroups = new HashSet[MGroup] @@ -102,17 +102,17 @@ redef class DocModel # Populate `self` from internal `model`. fun populate(v: ExtractionPhase) do - populate_mprojects(v) + populate_mpackages(v) populate_mclasses(v) populate_mproperties(v) end - # Populates the `mprojects` set. - private fun populate_mprojects(v: ExtractionPhase) do - for mproject in model.mprojects do - if v.ignore_mentity(mproject) then continue - self.mprojects.add mproject - for mgroup in mproject.mgroups do + # Populates the `mpackages` set. + private fun populate_mpackages(v: ExtractionPhase) do + for mpackage in model.mpackages do + if v.ignore_mentity(mpackage) then continue + self.mpackages.add mpackage + for mgroup in mpackage.mgroups do if v.ignore_mentity(mgroup) then continue self.mgroups.add mgroup for mmodule in mgroup.mmodules do @@ -152,7 +152,7 @@ redef class DocModel # FIXME invalidate cache if `self` is modified. var mentities: Collection[MEntity] is lazy do var res = new HashSet[MEntity] - res.add_all mprojects + res.add_all mpackages res.add_all mgroups res.add_all mmodules res.add_all mclasses @@ -178,7 +178,7 @@ redef class DocModel # # Path can be the shortest possible to disambiguise like `Class::property`. # In case of larger conflicts, a more complex namespace can be given like - # `project::module::Class::prop`. + # `package::module::Class::prop`. fun mentities_by_namespace(namespace: String): Array[MEntity] do var res = new Array[MEntity] for mentity in mentities do @@ -206,7 +206,7 @@ redef class MEntity end end -redef class MProject +redef class MPackage redef fun mentities_by_namespace(namespace, res) do lookup_in(mgroups, namespace, res) end diff --git a/src/doc/doc_phases/doc_html.nit b/src/doc/doc_phases/doc_html.nit index 722724b..ebc1193 100644 --- a/src/doc/doc_phases/doc_html.nit +++ b/src/doc/doc_phases/doc_html.nit @@ -46,7 +46,7 @@ redef class ToolContext # Display a custom brand or logo in the documentation top menu. var opt_custom_brand = new OptionString("custom link to external site", "--custom-brand") - # Display a custom introduction text before the projects overview. + # Display a custom introduction text before the packages overview. var opt_custom_intro = new OptionString("custom intro text for homepage", "--custom-overview-text") # Display a custom footer on each documentation page. # @@ -68,7 +68,7 @@ redef class ToolContext # FIXME redo the plugin var opt_github_base_sha1 = new OptionString("Git sha1 of base commit used to create pull request", "--github-base-sha1") # FIXME redo the plugin - var opt_github_gitdir = new OptionString("Git working directory used to resolve path name (ex: /home/me/myproject/)", "--github-gitdir") + var opt_github_gitdir = new OptionString("Git working directory used to resolve path name (ex: /home/me/mypackage/)", "--github-gitdir") redef init do super @@ -257,11 +257,11 @@ redef class ReadmePage redef fun init_topmenu(v, doc) do super - var mproject = mentity.mproject + var mpackage = mentity.mpackage if not mentity.is_root then - topmenu.add_li new ListItem(new Link(mproject.nitdoc_url, mproject.html_name)) + topmenu.add_li new ListItem(new Link(mpackage.nitdoc_url, mpackage.html_name)) end - topmenu.add_li new ListItem(new Link(html_url, mproject.html_name)) + topmenu.add_li new ListItem(new Link(html_url, mpackage.html_name)) topmenu.active_item = topmenu.items.last end @@ -275,11 +275,11 @@ end redef class MGroupPage redef fun init_topmenu(v, doc) do super - var mproject = mentity.mproject + var mpackage = mentity.mpackage if not mentity.is_root then - topmenu.add_li new ListItem(new Link(mproject.nitdoc_url, mproject.html_name)) + topmenu.add_li new ListItem(new Link(mpackage.nitdoc_url, mpackage.html_name)) end - topmenu.add_li new ListItem(new Link(html_url, mproject.html_name)) + topmenu.add_li new ListItem(new Link(html_url, mpackage.html_name)) topmenu.active_item = topmenu.items.last end @@ -323,8 +323,8 @@ end redef class MModulePage redef fun init_topmenu(v, doc) do super - var mproject = mentity.mproject - topmenu.add_li new ListItem(new Link(mproject.nitdoc_url, mproject.html_name)) + var mpackage = mentity.mpackage + topmenu.add_li new ListItem(new Link(mpackage.nitdoc_url, mpackage.html_name)) topmenu.add_li new ListItem(new Link(mentity.nitdoc_url, mentity.html_name)) topmenu.active_item = topmenu.items.last end @@ -367,8 +367,8 @@ redef class MClassPage redef fun init_topmenu(v, doc) do super - var mproject = mentity.intro_mmodule.mgroup.mproject - topmenu.add_li new ListItem(new Link(mproject.nitdoc_url, mproject.html_name)) + var mpackage = mentity.intro_mmodule.mgroup.mpackage + topmenu.add_li new ListItem(new Link(mpackage.nitdoc_url, mpackage.html_name)) topmenu.add_li new ListItem(new Link(html_url, mentity.html_name)) topmenu.active_item = topmenu.items.last end @@ -471,9 +471,9 @@ redef class MPropertyPage redef fun init_topmenu(v, doc) do super var mmodule = mentity.intro_mclassdef.mmodule - var mproject = mmodule.mgroup.mproject + var mpackage = mmodule.mgroup.mpackage var mclass = mentity.intro_mclassdef.mclass - topmenu.add_li new ListItem(new Link(mproject.nitdoc_url, mproject.html_name)) + topmenu.add_li new ListItem(new Link(mpackage.nitdoc_url, mpackage.html_name)) topmenu.add_li new ListItem(new Link(mclass.nitdoc_url, mclass.html_name)) topmenu.add_li new ListItem(new Link(html_url, mentity.html_name)) topmenu.active_item = topmenu.items.last @@ -495,8 +495,8 @@ redef class MEntitySection if not page isa MEntityPage then return var mentity = self.mentity if mentity isa MGroup and mentity.is_root then - html_title = mentity.mproject.html_name - html_subtitle = mentity.mproject.html_declaration + html_title = mentity.mpackage.html_name + html_subtitle = mentity.mpackage.html_declaration else if mentity isa MProperty then var title = new Template title.add mentity.html_name @@ -559,7 +559,7 @@ end redef class DefinitionArticle redef fun init_html_render(v, doc, page) do var mentity = self.mentity - if mentity isa MProject or mentity isa MModule then + if mentity isa MPackage or mentity isa MModule then var title = new Template title.add mentity.html_icon title.add mentity.html_namespace diff --git a/src/doc/doc_phases/doc_readme.nit b/src/doc/doc_phases/doc_readme.nit index 4e5e2dc..605ddac 100644 --- a/src/doc/doc_phases/doc_readme.nit +++ b/src/doc/doc_phases/doc_readme.nit @@ -235,7 +235,7 @@ redef class ArticleCommand private fun filter_results(res: Array[MEntity]): Array[MEntity] do var out = new Array[MEntity] for e in res do - if e isa MProject then continue + if e isa MPackage then continue if e isa MGroup then continue out.add e end diff --git a/src/doc/doc_phases/doc_structure.nit b/src/doc/doc_phases/doc_structure.nit index aaf137f..f2686e6 100644 --- a/src/doc/doc_phases/doc_structure.nit +++ b/src/doc/doc_phases/doc_structure.nit @@ -49,13 +49,13 @@ redef class OverviewPage redef fun apply_structure(v, doc) do var article = new HomeArticle("home.article", "Home") root.add_child article - # Projects list - var mprojects = doc.model.mprojects.to_a + # Packages list + var mpackages = doc.model.mpackages.to_a var sorter = new MConcernRankSorter - sorter.sort mprojects - var section = new DocSection("projects.section", "Projects") - for mproject in mprojects do - section.add_child new DefinitionArticle("{mproject.nitdoc_id}.definition", null, mproject) + sorter.sort mpackages + var section = new DocSection("packages.section", "Packages") + for mpackage in mpackages do + section.add_child new DefinitionArticle("{mpackage.nitdoc_id}.definition", null, mpackage) end article.add_child section end @@ -78,17 +78,17 @@ redef class MGroupPage var section = new MEntitySection("{mentity.nitdoc_name}.section", null, mentity) root.add_child section if mentity.is_root then - section.add_child new IntroArticle("{mentity.mproject.nitdoc_id}.intro", null, mentity.mproject) + section.add_child new IntroArticle("{mentity.mpackage.nitdoc_id}.intro", null, mentity.mpackage) else section.add_child new IntroArticle("{mentity.nitdoc_id}.intro", null, mentity) end var concerns = self.concerns if concerns == null or concerns.is_empty then return # FIXME avoid diff - mentity.mproject.booster_rank = -1000 + mentity.mpackage.booster_rank = -1000 mentity.booster_rank = -1000 concerns.sort_with(v.concerns_sorter) - mentity.mproject.booster_rank = 0 + mentity.mpackage.booster_rank = 0 mentity.booster_rank = 0 section.add_child new ConcernsArticle("{mentity.nitdoc_id}.concerns", null, mentity, concerns) for mentity in concerns do @@ -109,11 +109,11 @@ redef class MModulePage var concerns = self.concerns if concerns == null or concerns.is_empty then return # FIXME avoid diff - mentity.mgroup.mproject.booster_rank = -1000 + mentity.mgroup.mpackage.booster_rank = -1000 mentity.mgroup.booster_rank = -1000 mentity.booster_rank = -1000 concerns.sort_with(v.concerns_sorter) - mentity.mgroup.mproject.booster_rank = 0 + mentity.mgroup.mpackage.booster_rank = 0 mentity.mgroup.booster_rank = 0 mentity.booster_rank = 0 section.add_child new ConcernsArticle("{mentity.nitdoc_id}.concerns", null, mentity, concerns) @@ -174,11 +174,11 @@ redef class MClassPage var concerns = self.concerns if concerns == null or concerns.is_empty then return # FIXME diff hack - mentity.intro_mmodule.mgroup.mproject.booster_rank = -1000 + mentity.intro_mmodule.mgroup.mpackage.booster_rank = -1000 mentity.intro_mmodule.mgroup.booster_rank = -1000 mentity.intro_mmodule.booster_rank = -1000 concerns.sort_with(v.concerns_sorter) - mentity.intro_mmodule.mgroup.mproject.booster_rank = 0 + mentity.intro_mmodule.mgroup.mpackage.booster_rank = 0 mentity.intro_mmodule.mgroup.booster_rank = 0 mentity.intro_mmodule.booster_rank = 0 var constructors = new DocSection("{mentity.nitdoc_id}.constructors", "Constructors") @@ -249,11 +249,11 @@ redef class MPropertyPage var concerns = self.concerns if concerns == null or concerns.is_empty then return # FIXME diff hack - mentity.intro.mclassdef.mmodule.mgroup.mproject.booster_rank = -1000 + mentity.intro.mclassdef.mmodule.mgroup.mpackage.booster_rank = -1000 mentity.intro.mclassdef.mmodule.mgroup.booster_rank = -1000 mentity.intro.mclassdef.mmodule.booster_rank = -1000 concerns.sort_with(v.concerns_sorter) - mentity.intro.mclassdef.mmodule.mgroup.mproject.booster_rank = 0 + mentity.intro.mclassdef.mmodule.mgroup.mpackage.booster_rank = 0 mentity.intro.mclassdef.mmodule.mgroup.booster_rank = 0 mentity.intro.mclassdef.mmodule.booster_rank = 0 section.add_child new ConcernsArticle("{mentity.nitdoc_id}.concerns", null, mentity, concerns) @@ -377,7 +377,7 @@ class DefinitionArticle redef var is_hidden = false end -# The main project article. +# The main package article. class HomeArticle super DocArticle end @@ -439,7 +439,7 @@ redef class MConcern fun concern_rank: Int is abstract end -redef class MProject +redef class MPackage redef var concern_rank is lazy do var max = 0 for mgroup in mgroups do diff --git a/src/doc/html_templates/html_model.nit b/src/doc/html_templates/html_model.nit index ed895ee..b8727de 100644 --- a/src/doc/html_templates/html_model.nit +++ b/src/doc/html_templates/html_model.nit @@ -28,7 +28,7 @@ redef class MEntity # Returns the mentity name without short signature. # - # * MProject: `foo` + # * MPackage: `foo` # * MGroup: `foo` # * MModule: `foo` # * MClass: `Foo[E]` @@ -66,7 +66,7 @@ redef class MEntity # Returns the complete MEntity declaration decorated with HTML. # - # * MProject: `project foo` + # * MPackage: `package foo` # * MGroup: `group foo` # * MModule: `module foo` # * MClass: `private abstract class Foo[E: Object]` @@ -85,10 +85,10 @@ redef class MEntity # Returns `self` namespace decorated with HTML links. # - # * MProject: `mproject` - # * MGroup: `mproject(::group)` + # * MPackage: `mpackage` + # * MGroup: `mpackage(::group)` # * MModule: `mgroup::mmodule` - # * MClass: `mproject::mclass` + # * MClass: `mpackage::mclass` # * MClassDef: `mmodule::mclassdef` # * MProperty: `mclass::mprop` # * MPropdef: `mclassdef:mpropdef` @@ -141,10 +141,10 @@ redef class MEntity end end -redef class MProject +redef class MPackage redef var nitdoc_id = name.to_cmangle is lazy redef fun nitdoc_url do return root.nitdoc_url - redef var html_modifiers = ["project"] + redef var html_modifiers = ["package"] redef fun html_namespace do return html_link redef var css_classes = ["public"] end @@ -162,12 +162,12 @@ redef class MGroup # Depends if `self` is root or not. # - # * If root `mproject`. - # * Else `mproject::self`. + # * If root `mpackage`. + # * Else `mpackage::self`. redef fun html_namespace do var tpl = new Template - tpl.add mproject.html_namespace - if mproject.root != self then + tpl.add mpackage.html_namespace + if mpackage.root != self then tpl.add "::" tpl.add html_link end @@ -233,10 +233,10 @@ redef class MClass redef fun html_modifiers do return intro.html_modifiers redef fun html_declaration do return intro.html_declaration - # Returns `mproject::self`. + # Returns `mpackage::self`. redef fun html_namespace do var tpl = new Template - tpl.add intro_mmodule.mgroup.mproject.html_namespace + tpl.add intro_mmodule.mgroup.mpackage.html_namespace tpl.add "::" tpl.add html_link tpl.add "" diff --git a/src/doc/html_templates/html_templates.nit b/src/doc/html_templates/html_templates.nit index a497ad3..290f04b 100644 --- a/src/doc/html_templates/html_templates.nit +++ b/src/doc/html_templates/html_templates.nit @@ -449,7 +449,7 @@ redef class IntroArticle redef fun render_body do var tabs = new DocTabs("{html_id}.tabs", "") var comment = mentity.html_documentation - if mentity isa MProject then + if mentity isa MPackage then comment = mentity.html_synopsis end if comment != null then @@ -506,7 +506,7 @@ redef class DefinitionArticle var tabs = new DocTabs("{html_id}.tabs", "") if not is_no_body then var comment - if is_short_comment or mentity isa MProject then + if is_short_comment or mentity isa MPackage then comment = mentity.html_synopsis else comment = mentity.html_documentation diff --git a/src/ffi/extra_java_files.nit b/src/ffi/extra_java_files.nit index 0e093a0..e6dfca2 100644 --- a/src/ffi/extra_java_files.nit +++ b/src/ffi/extra_java_files.nit @@ -28,7 +28,7 @@ redef class ToolContext end redef class MModule - # Extra Java files to compile with the project + # Extra Java files to compile with the module private var extra_java_files: nullable Array[JavaFile] = null end diff --git a/src/loader.nit b/src/loader.nit index eb3d06d..a59ccf0 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -116,14 +116,14 @@ redef class ModelBuilder # # Each name can be: # - # * a path to a module, a group or a directory of projects. + # * a path to a module, a group or a directory of packages. # * a short name of a module or a group that are looked in the `paths` (-I) # # Then, for each entry, if it is: # # * a module, then is it parser and returned. # * a group then recursively all its modules are parsed. - # * a directory of projects then all the modules of all projects are parsed. + # * a directory of packages then all the modules of all packages are parsed. # * else an error is displayed. # # See `parse` for details. @@ -205,7 +205,7 @@ redef class ModelBuilder # First, look in groups var c = mgroup if c != null then - var r = c.mproject.root + var r = c.mpackage.root assert r != null scan_group(r) var res = r.mmodule_paths_by_name(name) @@ -215,10 +215,10 @@ redef class ModelBuilder # Look at some known directories var lookpaths = self.paths - # Look in the directory of the group project also (even if not explicitly in the path) + # Look in the directory of the group package also (even if not explicitly in the path) if mgroup != null then # path of the root group - var dirname = mgroup.mproject.root.filepath + var dirname = mgroup.mpackage.root.filepath if dirname != null then dirname = dirname.join_path("..").simplify_path if not lookpaths.has(dirname) and dirname.file_exists then @@ -308,7 +308,7 @@ redef class ModelBuilder # See `identify_file`. var identified_files = new Array[ModulePath] - # Identify a source file and load the associated project and groups if required. + # Identify a source file and load the associated package and groups if required. # # This method does what the user expects when giving an argument to a Nit tool. # @@ -317,7 +317,7 @@ redef class ModelBuilder # * If `path` is a directory (with a `/`), # then the ModulePath of its default module is returned (if any) # * If `path` is a simple identifier (eg. `digraph`), - # then the main module of the project `digraph` is searched in `paths` and returned. + # then the main module of the package `digraph` is searched in `paths` and returned. # # Silently return `null` if `path` does not exists or cannot be identified. fun identify_file(path: String): nullable ModulePath @@ -361,18 +361,18 @@ redef class ModelBuilder var mgroup = get_mgroup(mgrouppath) if mgroup == null then - # singleton project - var mproject = new MProject(pn, model) - mgroup = new MGroup(pn, mproject, null) # same name for the root group + # singleton package + var mpackage = new MPackage(pn, model) + mgroup = new MGroup(pn, mpackage, null) # same name for the root group mgroup.filepath = path - mproject.root = mgroup - toolcontext.info("found singleton project `{pn}` at {path}", 2) + mpackage.root = mgroup + toolcontext.info("found singleton package `{pn}` at {path}", 2) - # Attach homonymous `ini` file to the project + # Attach homonymous `ini` file to the package var inipath = path.dirname / "{pn}.ini" if inipath.file_exists then var ini = new ConfigTree(inipath) - mproject.ini = ini + mpackage.ini = ini end end @@ -416,13 +416,13 @@ redef class ModelBuilder return null end - # By default, the name of the project or group is the base_name of the directory + # By default, the name of the package or group is the base_name of the directory var pn = rdp.basename(".nit") - # Check `project.ini` that indicate a project + # Check `package.ini` that indicate a package var ini = null var parent = null - var inipath = dirpath / "project.ini" + var inipath = dirpath / "package.ini" if inipath.file_exists then ini = new ConfigTree(inipath) end @@ -436,16 +436,16 @@ redef class ModelBuilder return null end - # Special stopper `projects.ini` - if (dirpath/"projects.ini").file_exists then - # dirpath cannot be a project since it is a project directory + # Special stopper `packages.ini` + if (dirpath/"packages.ini").file_exists then + # dirpath cannot be a package since it is a package directory mgroups[rdp] = null return null end # check the parent directory (if it does not contain the stopper file) var parentpath = dirpath.join_path("..").simplify_path - var stopper = parentpath / "projects.ini" + var stopper = parentpath / "packages.ini" if not stopper.file_exists then # Recursively get the parent group parent = get_mgroup(parentpath) @@ -459,20 +459,20 @@ redef class ModelBuilder var mgroup if parent == null then - # no parent, thus new project - if ini != null then pn = ini["project.name"] or else pn - var mproject = new MProject(pn, model) - mgroup = new MGroup(pn, mproject, null) # same name for the root group - mproject.root = mgroup - toolcontext.info("found project `{mproject}` at {dirpath}", 2) - mproject.ini = ini + # no parent, thus new package + if ini != null then pn = ini["package.name"] or else pn + var mpackage = new MPackage(pn, model) + mgroup = new MGroup(pn, mpackage, null) # same name for the root group + mpackage.root = mgroup + toolcontext.info("found package `{mpackage}` at {dirpath}", 2) + mpackage.ini = ini else - mgroup = new MGroup(pn, parent.mproject, parent) + mgroup = new MGroup(pn, parent.mpackage, parent) toolcontext.info("found sub group `{mgroup.full_name}` at {dirpath}", 2) end # search documentation - # in src first so the documentation of the project code can be distinct for the documentation of the project usage + # in src first so the documentation of the package code can be distinct for the documentation of the package usage var readme = dirpath.join_path("README.md") if not readme.file_exists then readme = dirpath.join_path("README") if readme.file_exists then @@ -524,8 +524,8 @@ redef class ModelBuilder for f in p.files do var fp = p/f var g = get_mgroup(fp) - # Recursively scan for groups of the same project - if g != null and g.mproject == mgroup.mproject then + # Recursively scan for groups of the same package + if g != null and g.mpackage == mgroup.mpackage then scan_group(g) end identify_file(fp) @@ -668,11 +668,11 @@ redef class ModelBuilder end end - # Check for conflicting module names in the project + # Check for conflicting module names in the package if mgroup != null then var others = model.get_mmodules_by_name(mod_name) if others != null then for other in others do - if other.mgroup!= null and other.mgroup.mproject == mgroup.mproject then + if other.mgroup!= null and other.mgroup.mpackage == mgroup.mpackage then var node: ANode if decl == null then node = nmodule else node = decl.n_name error(node, "Error: a module named `{other.full_name}` already exists at {other.location}.") @@ -728,8 +728,8 @@ redef class ModelBuilder # If qualified and in a group if mgroup != null then - # First search in the project - var r = mgroup.mproject.root + # First search in the package + var r = mgroup.mpackage.root assert r != null scan_group(r) # Get all modules with the final name @@ -1012,7 +1012,7 @@ class ModulePath # The human path of the module var filepath: String - # The group (and the project) of the possible module + # The group (and the package) of the possible module var mgroup: MGroup # The loaded module (if any) @@ -1021,12 +1021,12 @@ class ModulePath redef fun to_s do return filepath end -redef class MProject +redef class MPackage # The associated `.ini` file, if any # # The `ini` file is given as is and might contain invalid or missing information. # - # Some projects, like stand-alone projects or virtual projects have no `ini` file associated. + # Some packages, like stand-alone packages or virtual packages have no `ini` file associated. var ini: nullable ConfigTree = null end @@ -1036,7 +1036,7 @@ redef class MGroup # Is the group interesting for a final user? # - # Groups are mandatory in the model but for simple projects they are not + # Groups are mandatory in the model but for simple packages they are not # always interesting. # # A interesting group has, at least, one of the following true: diff --git a/src/metrics/detect_covariance.nit b/src/metrics/detect_covariance.nit index 746ad9e..25463ad 100644 --- a/src/metrics/detect_covariance.nit +++ b/src/metrics/detect_covariance.nit @@ -204,7 +204,7 @@ private class DetectCovariancePhase ## ONLY covariance remains here - cpt_modules.inc(mmodule.mgroup.mproject.name) + cpt_modules.inc(mmodule.mgroup.mpackage.name) cpt_classes.inc(sub.mclass) # Track if `cpt_explanations` is already decided (used to fallback on unknown) diff --git a/src/metrics/generate_hierarchies.nit b/src/metrics/generate_hierarchies.nit index 6193b9c..ecbba30 100644 --- a/src/metrics/generate_hierarchies.nit +++ b/src/metrics/generate_hierarchies.nit @@ -44,20 +44,20 @@ end fun generate_module_hierarchy(toolcontext: ToolContext, given_mmodules: Collection[MModule]) do var model = given_mmodules.first.model - var dot = new MProjectDot(model) + var dot = new MPackageDot(model) - # Collect requested projects + # Collect requested packages for m in given_mmodules do var g = m.mgroup if g == null then continue - dot.mprojects.add(g.mproject) + dot.mpackages.add(g.mpackage) end - var projectpath = toolcontext.output_dir.join_path("project_hierarchy.dot") - print "generating project_hierarchy.dot" - dot.write_to_file(projectpath) + var packagepath = toolcontext.output_dir.join_path("package_hierarchy.dot") + print "generating package_hierarchy.dot" + dot.write_to_file(packagepath) var modulepath = toolcontext.output_dir.join_path("module_hierarchy.dot") - dot.mprojects.add_all(model.mprojects) + dot.mpackages.add_all(model.mpackages) print "generating module_hierarchy.dot" dot.write_to_file(modulepath) end diff --git a/src/metrics/inheritance_metrics.nit b/src/metrics/inheritance_metrics.nit index d475562..1287c0f 100644 --- a/src/metrics/inheritance_metrics.nit +++ b/src/metrics/inheritance_metrics.nit @@ -59,11 +59,11 @@ private class InheritanceMetricsPhase var model = toolcontext.modelbuilder.model var mmodules = new HashSet[MModule] var mclasses = new HashSet[MClass] - for mproject in model.mprojects do + for mpackage in model.mpackages do - print toolcontext.format_h2("\n ## project {mproject}") + print toolcontext.format_h2("\n ## package {mpackage}") - for mgroup in mproject.mgroups do + for mgroup in mpackage.mgroups do if mgroup.mmodules.is_empty then continue # Scalar metrics diff --git a/src/metrics/mclasses_metrics.nit b/src/metrics/mclasses_metrics.nit index ed41a9f..69b5b40 100644 --- a/src/metrics/mclasses_metrics.nit +++ b/src/metrics/mclasses_metrics.nit @@ -55,11 +55,11 @@ private class MClassesMetricsPhase var model = toolcontext.modelbuilder.model var mclasses = new HashSet[MClass] - for mproject in model.mprojects do + for mpackage in model.mpackages do - print toolcontext.format_h2("\n ## project {mproject}") + print toolcontext.format_h2("\n ## package {mpackage}") - for mgroup in mproject.mgroups do + for mgroup in mpackage.mgroups do if mgroup.mmodules.is_empty then continue metrics.clear diff --git a/src/metrics/mmodules_metrics.nit b/src/metrics/mmodules_metrics.nit index a7ac696..335831c 100644 --- a/src/metrics/mmodules_metrics.nit +++ b/src/metrics/mmodules_metrics.nit @@ -41,10 +41,10 @@ private class MModulesMetricsPhase var model = toolcontext.modelbuilder.model var mmodules = new HashSet[MModule] - for mproject in model.mprojects do + for mpackage in model.mpackages do - print toolcontext.format_h2("\n ## project {mproject}") - for mgroup in mproject.mgroups do + print toolcontext.format_h2("\n ## package {mpackage}") + for mgroup in mpackage.mgroups do if mgroup.mmodules.is_empty then continue # Scalar metrics diff --git a/src/metrics/model_hyperdoc.nit b/src/metrics/model_hyperdoc.nit index 9e66e73..ed91198 100644 --- a/src/metrics/model_hyperdoc.nit +++ b/src/metrics/model_hyperdoc.nit @@ -40,24 +40,24 @@ do buf.append("\n\n") buf.append("

Model

\n") - buf.append("

Projects

\n") - for mproject in model.mprojects do - buf.append("

Project {mproject}

\n") + buf.append("

Packages

\n") + for mpackage in model.mpackages do + buf.append("

Package {mpackage}

\n") buf.append("
\n") buf.append("
groups
\n") - for x in mproject.mgroups do + for x in mpackage.mgroups do buf.append("
{linkto(x)}
\n") end buf.append("
\n") end buf.append("

Groups

\n") - for mproject in model.mprojects do - for mgroup in mproject.mgroups do + for mpackage in model.mpackages do + for mgroup in mpackage.mgroups do buf.append("

Group {mgroup}

\n") buf.append("
\n") - buf.append("
project
\n") - buf.append("
{linkto(mproject)}
\n") + buf.append("
package
\n") + buf.append("
{linkto(mpackage)}
\n") buf.append("
filepath
\n") buf.append("
{mgroup.filepath.to_s}
\n") var p = mgroup.parent @@ -193,8 +193,8 @@ end private fun linkto(o: Object): String do - if o isa MProject then - return "{o}" + if o isa MPackage then + return "{o}" else if o isa MGroup then return "{o}" else if o isa MModule then diff --git a/src/metrics/nullables_metrics.nit b/src/metrics/nullables_metrics.nit index 62c8f71..6e9d7ff 100644 --- a/src/metrics/nullables_metrics.nit +++ b/src/metrics/nullables_metrics.nit @@ -44,11 +44,11 @@ private class NullablesMetricsPhase var model = toolcontext.modelbuilder.model var mclasses = new HashSet[MClass] - for mproject in model.mprojects do + for mpackage in model.mpackages do - print toolcontext.format_h2("\n ## project {mproject}") + print toolcontext.format_h2("\n ## package {mpackage}") - for mgroup in mproject.mgroups do + for mgroup in mpackage.mgroups do if mgroup.mmodules.is_empty then continue metrics.clear diff --git a/src/model/mdoc.nit b/src/model/mdoc.nit index 4e8c565..2035b06 100644 --- a/src/model/mdoc.nit +++ b/src/model/mdoc.nit @@ -39,7 +39,7 @@ redef class MEntity # The documentation associated to the entity or their main nested entity. # - # MProject fall-back to their root MGroup + # MPackage fall-back to their root MGroup # MGroup fall-back to their default_mmodule # Other entities do not fall-back # diff --git a/src/model/mmodule.nit b/src/model/mmodule.nit index 659660b..7e2e9b3 100644 --- a/src/model/mmodule.nit +++ b/src/model/mmodule.nit @@ -18,7 +18,7 @@ module mmodule import location -import mproject +import mpackage private import more_collections # The container class of a Nit object-oriented model. @@ -73,15 +73,15 @@ class MModule # The model considered redef var model: Model - # The group of module in the project if any + # The group of module in the package if any var mgroup: nullable MGroup - # The project of the module if any - # Safe alias for `mgroup.mproject` - fun mproject: nullable MProject + # The package of the module if any + # Safe alias for `mgroup.mpackage` + fun mpackage: nullable MPackage do var g = mgroup - if g == null then return null else return g.mproject + if g == null then return null else return g.mpackage end # The short name of the module @@ -98,24 +98,24 @@ class MModule # The canonical name of the module. # - # It is usually the `name` prefixed by the project's name. - # Example: `"project::name"` + # It is usually the `name` prefixed by the package's name. + # Example: `"package::name"` # - # If both names are the same (of if the module is project-less), then + # If both names are the same (of if the module is package-less), then # the short-name is used alone. redef var full_name is lazy do var mgroup = self.mgroup - if mgroup == null or mgroup.mproject.name == self.name then + if mgroup == null or mgroup.mpackage.name == self.name then return self.name else - return "{mgroup.mproject.name}::{self.name}" + return "{mgroup.mpackage.name}::{self.name}" end end # The namespace used for entities according to their visibility `v`. # - # Public entities use only the project as a namespace. - # Private entities use the `full_name` (i.e. "project::module") + # Public entities use only the package as a namespace. + # Private entities use the `full_name` (i.e. "package::module") # # This method is used by entities to implement their `full_name`. fun namespace_for(v: MVisibility): String do @@ -124,7 +124,7 @@ class MModule if mgroup == null then return full_name else - return mgroup.mproject.full_name + return mgroup.mpackage.full_name end end @@ -133,8 +133,8 @@ class MModule redef var c_name: String is lazy do var g = mgroup var res - if g != null and g.mproject.name != name then - res = g.mproject.name.to_cmangle + "__" + name.to_cmangle + if g != null and g.mpackage.name != name then + res = g.mpackage.name.to_cmangle + "__" + name.to_cmangle else res = name.to_cmangle end @@ -151,7 +151,7 @@ class MModule if mgroup == null then return c_name else - return mgroup.mproject.c_name + return mgroup.mpackage.c_name end end diff --git a/src/model/model.nit b/src/model/model.nit index e0c3280..8d6bf7a 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -614,7 +614,7 @@ class MClassDef # public gives 'p#A' # private gives 'p::m#A' return "{mmodule.namespace_for(mclass.visibility)}#{mclass.name}" - else if mclass.intro_mmodule.mproject != mmodule.mproject then + else if mclass.intro_mmodule.mpackage != mmodule.mpackage then # public gives 'q::n#p::A' # private gives 'q::n#p::m::A' return "{mmodule.full_name}#{mclass.full_name}" @@ -630,7 +630,7 @@ class MClassDef redef var c_name is lazy do if is_intro then return "{mmodule.c_namespace_for(mclass.visibility)}___{mclass.c_name}" - else if mclass.intro_mmodule.mproject == mmodule.mproject and mclass.visibility > private_visibility then + else if mclass.intro_mmodule.mpackage == mmodule.mpackage and mclass.visibility > private_visibility then return "{mmodule.c_name}___{mclass.name.to_cmangle}" else return "{mmodule.c_name}___{mclass.c_name}" @@ -1932,7 +1932,7 @@ abstract class MProperty # The canonical name of the property. # # It is the short-`name` prefixed by the short-name of the class and the full-name of the module. - # Example: "my_project::my_module::MyClass::my_method" + # Example: "my_package::my_module::MyClass::my_method" redef var full_name is lazy do return "{intro_mclassdef.mmodule.namespace_for(visibility)}::{intro_mclassdef.mclass.name}::{name}" end @@ -2250,14 +2250,14 @@ abstract class MPropDef res.append name else # Just try to simplify each part - if mclassdef.mmodule.mproject != mproperty.intro_mclassdef.mmodule.mproject then + if mclassdef.mmodule.mpackage != mproperty.intro_mclassdef.mmodule.mpackage then # precise "p::m" only if "p" != "r" res.append mproperty.intro_mclassdef.mmodule.full_name res.append "::" else if mproperty.visibility <= private_visibility then - # Same project ("p"=="q"), but private visibility, + # Same package ("p"=="q"), but private visibility, # does the module part ("::m") need to be displayed - if mclassdef.mmodule.namespace_for(mclassdef.mclass.visibility) != mproperty.intro_mclassdef.mmodule.mproject then + if mclassdef.mmodule.namespace_for(mclassdef.mclass.visibility) != mproperty.intro_mclassdef.mmodule.mpackage then res.append "::" res.append mproperty.intro_mclassdef.mmodule.name res.append "::" diff --git a/src/model/model_viz.nit b/src/model/model_viz.nit index 305cd23..66ab460 100644 --- a/src/model/model_viz.nit +++ b/src/model/model_viz.nit @@ -18,9 +18,9 @@ module model_viz import model import ordered_tree -# A simple specialisation of OrderedTree to display projects, groups and modules +# A simple specialisation of OrderedTree to display packages, groups and modules # FIXME do not use Object, but a better common interface of MModule and MGroup -class MProjectTree +class MPackageTree super OrderedTree[Object] # The model where to look for information @@ -28,7 +28,7 @@ class MProjectTree redef fun display(a) do if a isa MGroup then - if a.parent == null then return "{a.mproject.name} ({a.filepath.to_s})" + if a.parent == null then return "{a.mpackage.name} ({a.filepath.to_s})" return a.name + " (group)" else if a isa MModule then return a.name @@ -115,11 +115,11 @@ private class LinexComparator end redef class Model - # Generate a MProjectTree based on the projects, groups and modules known in the model - fun to_mproject_tree: MProjectTree + # Generate a MPackageTree based on the packages, groups and modules known in the model + fun to_mpackage_tree: MPackageTree do - var res = new MProjectTree(self) - for p in mprojects do + var res = new MPackageTree(self) + for p in mpackages do for g in p.mgroups do res.add(g.parent, g) for m in g.mmodules do @@ -131,19 +131,19 @@ redef class Model end end -# Generate graphiz files based on projects, groups and modules +# Generate graphiz files based on packages, groups and modules # # Interesting elements must be selected. See `mmodules`, `` -# Display configuration can be set. See `cluster_group`, `project_group` -class MProjectDot +# Display configuration can be set. See `cluster_group`, `package_group` +class MPackageDot super Writable # The model where to look for information var model: Model - # Set of projects to expand fully (ie all groups and modules are displayed) - # Initially empty, projects can be added - var mprojects = new HashSet[MProject] + # Set of packages to expand fully (ie all groups and modules are displayed) + # Initially empty, packages can be added + var mpackages = new HashSet[MPackage] # Set of modules to display # Initially empty, modules can be added @@ -157,17 +157,17 @@ class MProjectDot # Should groups be shown as clusters? var cluster_group = true is writable - # Should projects be shown as clusters? - var project_group = true is writable + # Should packages be shown as clusters? + var package_group = true is writable # Recursively generate node and clusters for a mgroup private fun dot_cluster(o: Writer, mgroup: MGroup) do # Open the cluster, if required if mgroup.parent == null then - # is is a root group, so display the project - if project_group then - o.write("subgraph cluster_{mgroup.object_id} \{\nlabel=\"{mgroup.mproject.name}\\n({mgroup.filepath.to_s})\"\ncolor=black\nstyle=dotted\n") + # is is a root group, so display the package + if package_group then + o.write("subgraph cluster_{mgroup.object_id} \{\nlabel=\"{mgroup.mpackage.name}\\n({mgroup.filepath.to_s})\"\ncolor=black\nstyle=dotted\n") end else if cluster_group then @@ -188,13 +188,13 @@ class MProjectDot # close the cluster if required if mgroup.parent == null then - if project_group then o.write("\}\n") + if package_group then o.write("\}\n") else if cluster_group then o.write("\}\n") end end - # Extends the set of `mmodules` by recursively adding the most specific imported modules of foreign projects + # Extends the set of `mmodules` by recursively adding the most specific imported modules of foreign packages fun collect_important_importation do var todo = new List[MModule] @@ -203,9 +203,9 @@ class MProjectDot var m = todo.pop for psm in m.in_importation.greaters do - if m.mgroup.mproject != psm.mgroup.mproject then continue + if m.mgroup.mpackage != psm.mgroup.mpackage then continue for ssm in psm.in_importation.direct_greaters do - if psm.mgroup.mproject == ssm.mgroup.mproject then continue + if psm.mgroup.mpackage == ssm.mgroup.mpackage then continue mmodules.add(ssm) todo.add(ssm) end @@ -218,9 +218,9 @@ class MProjectDot do # Collect interesting nodes for m in model.mmodules do - # filter out modules outside wanted projects + # filter out modules outside wanted packages if m.mgroup == null then continue - if not mprojects.has(m.mgroup.mproject) then continue + if not mpackages.has(m.mgroup.mpackage) then continue mmodules.add(m) end @@ -241,7 +241,7 @@ class MProjectDot stream.write("digraph g \{\n") stream.write("rankdir=BT;node[shape=box];\n") # Generate the nodes - for p in model.mprojects do + for p in model.mpackages do dot_cluster(stream, p.root.as(not null)) end # Generate the edges diff --git a/src/model/mproject.nit b/src/model/mpackage.nit similarity index 65% rename from src/model/mproject.nit rename to src/model/mpackage.nit index 283d54c..c1625ee 100644 --- a/src/model/mproject.nit +++ b/src/model/mpackage.nit @@ -12,26 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Modelisation of a Nit project -module mproject +# Modelisation of a Nit package +module mpackage import model_base private import more_collections import poset import mdoc -# A Nit project, that encompass a product -class MProject +# A Nit package, that encompass a product +class MPackage super MConcern - # The name of the project + # The name of the package redef var name: String redef fun full_name do return name redef var c_name = name.to_cmangle is lazy - # The model of the project + # The model of the package redef var model: Model # The root of the group tree @@ -44,11 +44,11 @@ class MProject init do - model.mprojects.add(self) - model.mproject_by_name.add_one(name, self) + model.mpackages.add(self) + model.mpackage_by_name.add_one(name, self) end - # MProject are always roots of the concerns hierarchy + # MPackage are always roots of the concerns hierarchy redef fun parent_concern do return null redef fun mdoc_or_fallback @@ -58,16 +58,16 @@ class MProject end end -# A group of modules in a project +# A group of modules in a package class MGroup super MConcern # The name of the group - # empty name for a default group in a single-module project + # empty name for a default group in a single-module package redef var name: String - # The enclosing project - var mproject: MProject + # The enclosing package + var mpackage: MPackage # The parent group if any # see `in_nesting` for more @@ -82,20 +82,20 @@ class MGroup return "{p.full_name}/{name}" end - # The group is the group tree on the project (`mproject.mgroups`) + # The group is the group tree on the package (`mpackage.mgroups`) # nested groups (children) are smaller # nesting group (see `parent`) is bigger var in_nesting: POSetElement[MGroup] is noinit - # Is `self` the root of its project? - fun is_root: Bool do return mproject.root == self + # Is `self` the root of its package? + fun is_root: Bool do return mpackage.root == self # The filepath (usually a directory) of the group, if any var filepath: nullable String = null is writable init do - var tree = mproject.mgroups + var tree = mpackage.mgroups self.in_nesting = tree.add_node(self) var parent = self.parent if parent != null then @@ -103,29 +103,29 @@ class MGroup end end - redef fun model do return mproject.model + redef fun model do return mpackage.model redef fun parent_concern do if not is_root then return parent - return mproject + return mpackage end redef fun to_s do return name end redef class Model - # projects of the model - var mprojects = new Array[MProject] + # packages of the model + var mpackages = new Array[MPackage] - # Collections of project grouped by their names - private var mproject_by_name = new MultiHashMap[String, MProject] + # Collections of package grouped by their names + private var mpackage_by_name = new MultiHashMap[String, MPackage] - # Return all project named `name` - # If such a project is not yet loaded, null is returned (instead of an empty array) - fun get_mprojects_by_name(name: String): nullable Array[MProject] + # Return all package named `name` + # If such a package is not yet loaded, null is returned (instead of an empty array) + fun get_mpackages_by_name(name: String): nullable Array[MPackage] do - if mproject_by_name.has_key(name) then - return mproject_by_name[name] + if mpackage_by_name.has_key(name) then + return mpackage_by_name[name] else return null end diff --git a/src/modelize/modelize_class.nit b/src/modelize/modelize_class.nit index 5fd0381..14c8e94 100644 --- a/src/modelize/modelize_class.nit +++ b/src/modelize/modelize_class.nit @@ -99,11 +99,11 @@ redef class ModelBuilder return end - # Check for conflicting class full-names in the project + # Check for conflicting class full-names in the package if mmodule.mgroup != null and mvisibility >= protected_visibility then var mclasses = model.get_mclasses_by_name(name) if mclasses != null then for other in mclasses do - if other.intro_mmodule.mgroup != null and other.intro_mmodule.mgroup.mproject == mmodule.mgroup.mproject then + if other.intro_mmodule.mgroup != null and other.intro_mmodule.mgroup.mpackage == mmodule.mgroup.mpackage then # Skip classes that are buggy if other.try_intro == null then continue warning(nclassdef, "full-name-conflict", "Error: a class named `{other.full_name}` is already defined in module `{other.intro_mmodule}` at {other.intro.location}.") diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index 97312f2..eec36f4 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -629,12 +629,12 @@ redef class APropdef return false end - # Check for full-name conflicts in the project. - # A public property should have a unique qualified name `project::class::prop`. + # Check for full-name conflicts in the package. + # A public property should have a unique qualified name `package::class::prop`. if mprop.intro_mclassdef.mmodule.mgroup != null and mprop.visibility >= protected_visibility then var others = modelbuilder.model.get_mproperties_by_name(mprop.name) if others != null then for other in others do - if other != mprop and other.intro_mclassdef.mmodule.mgroup != null and other.intro_mclassdef.mmodule.mgroup.mproject == mprop.intro_mclassdef.mmodule.mgroup.mproject and other.intro_mclassdef.mclass.name == mprop.intro_mclassdef.mclass.name and other.visibility >= protected_visibility then + if other != mprop and other.intro_mclassdef.mmodule.mgroup != null and other.intro_mclassdef.mmodule.mgroup.mpackage == mprop.intro_mclassdef.mmodule.mgroup.mpackage and other.intro_mclassdef.mclass.name == mprop.intro_mclassdef.mclass.name and other.visibility >= protected_visibility then modelbuilder.advice(self, "full-name-conflict", "Warning: A property named `{other.full_name}` is already defined in module `{other.intro_mclassdef.mmodule}` for the class `{other.intro_mclassdef.mclass.name}`.") break end diff --git a/src/neo.nit b/src/neo.nit index 79799e8..c110468 100644 --- a/src/neo.nit +++ b/src/neo.nit @@ -35,15 +35,15 @@ # # Note : All nodes described here are MEntities. # -# `MProject` +# `MPackage` # -# * labels: `MProject`, `model_name` and `MEntity`. -# * `(:MProject)-[:ROOT]->(:MGroup)`: root of the group tree. +# * labels: `MPackage`, `model_name` and `MEntity`. +# * `(:MPackage)-[:ROOT]->(:MGroup)`: root of the group tree. # # `MGroup` # # * labels: `MGroup`, `model_name` and `MEntity`. -# * `(:MGroup)-[:PROJECT]->(:MProject)`: associated project. +# * `(:MGroup)-[:PROJECT]->(:MPackage)`: associated package. # * `(:MGroup)-[:PARENT]->(:MGroup)`: parent group. Does not exist for the root # group. # * `(:MGroup)-[:DECLARES]->(:MModule)`: modules that are direct children of @@ -233,9 +233,9 @@ class NeoModel fun load(model: Model): Model do var nodes: Array[NeoNode] - toolcontext.info("Loading project node...", 1) - nodes = client.nodes_with_labels([model_name, "MProject"]) - for node in nodes do to_mproject(model, node) + toolcontext.info("Loading package node...", 1) + nodes = client.nodes_with_labels([model_name, "MPackage"]) + for node in nodes do to_mpackage(model, node) toolcontext.info("Loading groups...", 1) nodes = client.nodes_with_labels([model_name, "MGroup"]) for node in nodes do to_mgroup(model, node) @@ -304,9 +304,9 @@ class NeoModel # Collect all nodes from the current `model`. private fun collect_model_nodes(model: Model): Collection[NeoNode] do - for mproject in model.mprojects do - to_node(mproject) - for mgroup in mproject.mgroups do to_node(mgroup) + for mpackage in model.mpackages do + to_node(mpackage) + for mgroup in mpackage.mgroups do to_node(mgroup) end return nodes.values end @@ -332,7 +332,7 @@ class NeoModel # `mentities` are stored locally to avoid duplication. fun to_node(mentity: MEntity): NeoNode do if nodes.has_key(mentity) then return nodes[mentity] - if mentity isa MProject then return mproject_node(mentity) + if mentity isa MPackage then return mpackage_node(mentity) if mentity isa MGroup then return mgroup_node(mentity) if mentity isa MModule then return mmodule_node(mentity) if mentity isa MClass then return mclass_node(mentity) @@ -346,7 +346,7 @@ class NeoModel # Get the `MEntity` associated with `node`. fun to_mentity(model: Model, node: NeoNode): MEntity do - if node.labels.has("MProject") then return to_mproject(model, node) + if node.labels.has("MPackage") then return to_mpackage(model, node) if node.labels.has("MGroup") then return to_mgroup(model, node) if node.labels.has("MModule") then return to_mmodule(model, node) if node.labels.has("MClass") then return to_mclass(model, node) @@ -372,30 +372,30 @@ class NeoModel return node end - # Build a `NeoNode` representing `mproject`. - private fun mproject_node(mproject: MProject): NeoNode do - var node = make_node(mproject) - node.labels.add "MProject" - var root = mproject.root + # Build a `NeoNode` representing `mpackage`. + private fun mpackage_node(mpackage: MPackage): NeoNode do + var node = make_node(mpackage) + node.labels.add "MPackage" + var root = mpackage.root if root != null then node.out_edges.add(new NeoEdge(node, "ROOT", to_node(root))) end return node end - # Build a new `MProject` from a `node`. + # Build a new `MPackage` from a `node`. # - # REQUIRE `node.labels.has("MProject")` - private fun to_mproject(model: Model, node: NeoNode): MProject do + # REQUIRE `node.labels.has("MPackage")` + private fun to_mpackage(model: Model, node: NeoNode): MPackage do var m = mentities.get_or_null(node.id.as(Int)) - if m isa MProject then return m + if m isa MPackage then return m - assert node.labels.has("MProject") - var mproject = new MProject(node["name"].to_s, model) - mentities[node.id.as(Int)] = mproject - set_doc(node, mproject) - mproject.root = to_mgroup(model, node.out_nodes("ROOT").first) - return mproject + assert node.labels.has("MPackage") + var mpackage = new MPackage(node["name"].to_s, model) + mentities[node.id.as(Int)] = mpackage + set_doc(node, mpackage) + mpackage.root = to_mgroup(model, node.out_nodes("ROOT").first) + return mpackage end # Build a `NeoNode` representing `mgroup`. @@ -403,7 +403,7 @@ class NeoModel var node = make_node(mgroup) node.labels.add "MGroup" var parent = mgroup.parent - node.out_edges.add(new NeoEdge(node, "PROJECT", to_node(mgroup.mproject))) + node.out_edges.add(new NeoEdge(node, "PROJECT", to_node(mgroup.mpackage))) if parent != null then node.out_edges.add(new NeoEdge(node, "PARENT", to_node(parent))) end @@ -424,13 +424,13 @@ class NeoModel if m isa MGroup then return m assert node.labels.has("MGroup") - var mproject = to_mproject(model, node.out_nodes("PROJECT").first) + var mpackage = to_mpackage(model, node.out_nodes("PROJECT").first) var parent: nullable MGroup = null var out = node.out_nodes("PARENT") if not out.is_empty then parent = to_mgroup(model, out.first) end - var mgroup = new MGroup(node["name"].to_s, mproject, parent) + var mgroup = new MGroup(node["name"].to_s, mpackage, parent) mentities[node.id.as(Int)] = mgroup set_doc(node, mgroup) return mgroup diff --git a/src/nitcatalog.nit b/src/nitcatalog.nit index 6aba6f1..c843b51 100644 --- a/src/nitcatalog.nit +++ b/src/nitcatalog.nit @@ -12,23 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Basic catalog generator for Nit projects +# Basic catalog generator for Nit packages # # See: # -# The tool scans projects and generates the HTML files of a catalog. +# The tool scans packages and generates the HTML files of a catalog. # # ## Features # -# * [X] scan projects and their `.ini` -# * [X] generate lists of projects -# * [X] generate a page per project with the readme and most metadata +# * [X] scan packages and their `.ini` +# * [X] generate lists of packages +# * [X] generate a page per package with the readme and most metadata # * [ ] link/include/be included in the documentation -# * [ ] propose `related projects` +# * [ ] propose `related packages` # * [ ] show directory content (a la nitls) # * [X] gather git information from the working directory # * [ ] gather git information from the repository -# * [ ] gather project information from github +# * [ ] gather package information from github # * [ ] gather people information from github # * [ ] reify people # * [ ] separate information gathering from rendering @@ -48,13 +48,13 @@ # How to use the tool as the basis of a Nit code archive on the web usable with a package manager is not clear. module nitcatalog -import loader # Scan&load projects, groups and modules +import loader # Scan&load packages, groups and modules import doc::doc_down # Display mdoc import md5 # To get gravatar images import counter # For statistics import modelize # To process and count classes and methods -redef class MProject +redef class MPackage # Return the associated metadata from the `ini`, if any fun metadata(key: String): nullable String do @@ -139,7 +139,7 @@ class CatalogPage end redef class Int - # Returns `log(self+1)`. Used to compute score of projects + # Returns `log(self+1)`. Used to compute score of packages fun score: Float do return (self+1).to_f.log end @@ -150,46 +150,46 @@ class Catalog # used to access the files and count source lines of code var modelbuilder: ModelBuilder - # Projects by tag - var tag2proj = new MultiHashMap[String, MProject] + # Packages by tag + var tag2proj = new MultiHashMap[String, MPackage] - # Projects by category - var cat2proj = new MultiHashMap[String, MProject] + # Packages by category + var cat2proj = new MultiHashMap[String, MPackage] - # Projects by maintainer - var maint2proj = new MultiHashMap[String, MProject] + # Packages by maintainer + var maint2proj = new MultiHashMap[String, MPackage] - # Projects by contributors - var contrib2proj = new MultiHashMap[String, MProject] + # Packages by contributors + var contrib2proj = new MultiHashMap[String, MPackage] - # Dependency between projects - var deps = new POSet[MProject] + # Dependency between packages + var deps = new POSet[MPackage] - # Number of modules by project - var mmodules = new Counter[MProject] + # Number of modules by package + var mmodules = new Counter[MPackage] - # Number of classes by project - var mclasses = new Counter[MProject] + # Number of classes by package + var mclasses = new Counter[MPackage] - # Number of methods by project - var mmethods = new Counter[MProject] + # Number of methods by package + var mmethods = new Counter[MPackage] - # Number of line of code by project - var loc = new Counter[MProject] + # Number of line of code by package + var loc = new Counter[MPackage] - # Number of commits by project - var commits = new Counter[MProject] + # Number of commits by package + var commits = new Counter[MPackage] - # Score by project + # Score by package # # The score is loosely computed using other metrics - var score = new Counter[MProject] + var score = new Counter[MPackage] - # Scan, register and add a contributor to a project - fun add_contrib(person: String, mproject: MProject, res: Template) + # Scan, register and add a contributor to a package + fun add_contrib(person: String, mpackage: MPackage, res: Template) do var projs = contrib2proj[person] - if not projs.has(mproject) then projs.add mproject + if not projs.has(mpackage) then projs.add mpackage var name = person var email = null var page = null @@ -239,19 +239,19 @@ class Catalog end - # Compute information and generate a full HTML page for a project - fun project_page(mproject: MProject): Writable + # Compute information and generate a full HTML page for a package + fun package_page(mpackage: MPackage): Writable do var res = new CatalogPage - var score = score[mproject].to_f - var name = mproject.name.html_escape + var score = score[mpackage].to_f + var name = mpackage.name.html_escape res.more_head.add """{{{name}}}""" res.add """

{{{name}}}

""" - var mdoc = mproject.mdoc_or_fallback + var mdoc = mpackage.mdoc_or_fallback if mdoc != null then score += 100.0 res.add mdoc.html_documentation @@ -262,21 +262,21 @@ class Catalog """ - self.score[mproject] = score.to_i + self.score[mpackage] = score.to_i return res end - # Return a short HTML sequence for a project + # Return a short HTML sequence for a package # # Intended to use in lists. - fun li_project(p: MProject): String + fun li_package(p: MPackage): String do var res = "" var f = "{p.name}.html" @@ -456,14 +456,14 @@ class Catalog return res end - # List projects by group. + # List packages by group. # # For each key of the `map` a `

` is generated. - # Each project is then listed. + # Each package is then listed. # # The list of keys is generated first to allow fast access to the correct `

`. # `id_prefix` is used to give an id to the `

` element. - fun list_by(map: MultiHashMap[String, MProject], id_prefix: String): Template + fun list_by(map: MultiHashMap[String, MPackage], id_prefix: String): Template do var res = new Template var keys = map.keys.to_a @@ -478,7 +478,7 @@ class Catalog res.add "

{e} ({projs.length})

\n
    \n" for p in projs do res.add "
  • " - res.add li_project(p) + res.add li_package(p) res.add "
  • " end res.add "
" @@ -486,8 +486,8 @@ class Catalog return res end - # List the 10 best projects from `cpt` - fun list_best(cpt: Counter[MProject]): Template + # List the 10 best packages from `cpt` + fun list_best(cpt: Counter[MPackage]): Template do var res = new Template res.add "
    " @@ -496,7 +496,7 @@ class Catalog if i > best.length then break var p = best[best.length-i] res.add "
  • " - res.add li_project(p) + res.add li_package(p) # res.add " ({cpt[p]})" res.add "
  • " end @@ -504,10 +504,10 @@ class Catalog return res end - # Collect more information on a project using the `git` tool. - fun git_info(mproject: MProject) + # Collect more information on a package using the `git` tool. + fun git_info(mpackage: MPackage) do - var ini = mproject.ini + var ini = mpackage.ini if ini == null then return # TODO use real git info @@ -515,7 +515,7 @@ class Catalog #var branch = ini.get_or_null("upstream.git.branch") #var directory = ini.get_or_null("upstream.git.directory") - var dirpath = mproject.root.filepath + var dirpath = mpackage.root.filepath if dirpath == null then return # Collect commits info @@ -523,30 +523,30 @@ class Catalog var contributors = new Counter[String] var commits = res.split("\n") if commits.not_empty and commits.last == "" then commits.pop - self.commits[mproject] = commits.length + self.commits[mpackage] = commits.length for l in commits do var s = l.split_once_on(';') if s.length != 2 or s.last == "" then continue # Collect date of last and first commit - if mproject.last_date == null then mproject.last_date = s.first - mproject.first_date = s.first + if mpackage.last_date == null then mpackage.last_date = s.first + mpackage.first_date = s.first # Count contributors contributors.inc(s.last) end for c in contributors.sort.reverse_iterator do - mproject.contributors.add c + mpackage.contributors.add c end end - # Produce a HTML table containig information on the projects + # Produce a HTML table containig information on the packages # - # `project_page` must have been called before so that information is computed. - fun table_projects(mprojects: Array[MProject]): Template + # `package_page` must have been called before so that information is computed. + fun table_packages(mpackages: Array[MPackage]): Template do - alpha_comparator.sort(mprojects) + alpha_comparator.sort(mpackages) var res = new Template res.add "\n" res.add "\n" @@ -563,7 +563,7 @@ class Catalog res.add "\n" res.add "\n" res.add "" - for p in mprojects do + for p in mpackages do res.add "" res.add "" var maint = "?" @@ -612,8 +612,8 @@ for a in tc.option_context.rest do modelbuilder.identify_file(a) end -# Scan projects and compute information -for p in model.mprojects do +# Scan packages and compute information +for p in model.mpackages do var g = p.root assert g != null modelbuilder.scan_group(g) @@ -624,7 +624,7 @@ for p in model.mprojects do catalog.deps.add_node(p) for gg in p.mgroups do for m in gg.mmodules do for im in m.in_importation.direct_greaters do - var ip = im.mproject + var ip = im.mpackage if ip == null or ip == p then continue catalog.deps.add_edge(p, ip) end @@ -741,28 +741,28 @@ css.write_to_file(out/"style.css") # PAGES -for p in model.mprojects do +for p in model.mpackages do # print p var f = "{p.name}.html" - catalog.project_page(p).write_to_file(out/f) + catalog.package_page(p).write_to_file(out/f) end # INDEX var index = new CatalogPage -index.more_head.add "Projects in Nit" +index.more_head.add "Packages in Nit" index.add """
    -

    Projects in Nit

    +

    Packages in Nit

    """ -index.add "

    Highlighted Projects

    \n" +index.add "

    Highlighted Packages

    \n" index.add catalog.list_best(catalog.score) index.add "

    Most Required

    \n" -var reqs = new Counter[MProject] -for p in model.mprojects do +var reqs = new Counter[MPackage] +for p in model.mpackages do reqs[p] = catalog.deps[p].smallers.length - 1 end index.add catalog.list_best(reqs) @@ -778,7 +778,7 @@ index.add """
    linesscore
    {p.name}