From: Jean Privat Date: Wed, 14 Jan 2015 06:07:44 +0000 (-0500) Subject: Merge: Do not display test suite modules in Nitdoc X-Git-Tag: v0.7.1~27 X-Git-Url: http://nitlanguage.org?hp=-c Merge: Do not display test suite modules in Nitdoc Do not display test suite modules in Nitdoc Fixes #779 Pull-Request: #1097 Reviewed-by: Jean Privat --- 9ed8557045416e9795b55078f38e248008619376 diff --combined src/doc/doc_pages.nit index f8a1250,eeb2553..38e6cdf --- a/src/doc/doc_pages.nit +++ b/src/doc/doc_pages.nit @@@ -166,7 -166,7 +166,7 @@@ class Nitdo private fun modules do for mmodule in model.mmodules do - if mmodule.is_fictive then continue + 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 @@@ -211,7 -211,7 +211,7 @@@ class QuickSearc init do for mmodule in model.mmodules do - if mmodule.is_fictive then continue + if mmodule.is_fictive or mmodule.is_test_suite then continue add_result_for(mmodule.name, mmodule.full_name, mmodule.nitdoc_url) end for mclass in model.mclasses do @@@ -543,8 -543,8 +543,8 @@@ abstract class NitdocPag redef_article.title_classes.add "signature info" redef_article.css_classes.add "nospace" var redef_content = new Template - if mpropdef.mdoc_or_fallback != null then - redef_content.add mpropdef.mdoc_or_fallback.tpl_comment + if mpropdef.mdoc != null then + redef_content.add mpropdef.mdoc.tpl_comment end redef_article.content = redef_content subarticle.add_child redef_article @@@ -667,7 -667,7 +667,7 @@@ class NitdocSearc private fun modules_list: Array[MModule] do var sorted = new Array[MModule] for mmodule in model.mmodule_importation_hierarchy do - if mmodule.is_fictive then continue + if mmodule.is_fictive or mmodule.is_test_suite then continue sorted.add mmodule end name_sorter.sort(sorted) @@@ -933,7 -933,7 +933,7 @@@ class NitdocModul # Imports var lst = new Array[MModule] for dep in imports do - if dep.is_fictive then continue + if dep.is_fictive or dep.is_test_suite then continue if dep == mmodule then continue lst.add(dep) end @@@ -945,7 -945,7 +945,7 @@@ # Clients lst = new Array[MModule] for dep in clients do - if dep.is_fictive then continue + if dep.is_fictive or dep.is_test_suite then continue if dep == mmodule then continue lst.add(dep) end @@@ -1024,10 -1024,10 +1024,10 @@@ fun tpl_dot(mmodules: Collection[MModule]): nullable TplArticle do var poset = new POSet[MModule] for mmodule in mmodules do - if mmodule.is_fictive then continue + if mmodule.is_fictive or mmodule.is_test_suite then continue poset.add_node mmodule for omodule in mmodules do - if mmodule.is_fictive then continue + if omodule.is_fictive or omodule.is_test_suite then continue poset.add_node mmodule if mmodule.in_importation < omodule then poset.add_edge(mmodule, omodule) diff --combined src/loader.nit index 58d3506,72921c7..a046815 --- a/src/loader.nit +++ b/src/loader.nit @@@ -508,19 -508,6 +508,19 @@@ redef class ModelBuilde end end + # Check for conflicting module names in the project + 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 + 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}") + break + end + end + end + # Create the module var mmodule = new MModule(model, mgroup, mod_name, nmodule.location) nmodule.mmodule = mmodule @@@ -528,6 -515,7 +528,7 @@@ self.mmodule2nmodule[mmodule] = nmodule if decl != null then + # Extract documentation var ndoc = decl.n_doc if ndoc != null then var mdoc = ndoc.to_mdoc @@@ -536,6 -524,8 +537,8 @@@ else advice(decl, "missing-doc", "Documentation warning: Undocumented module `{mmodule}`") end + # Is the module a test suite? + mmodule.is_test_suite = not decl.get_annotations("test_suite").is_empty end return mmodule diff --combined src/model/mmodule.nit index b11a594,8020cc3..d88a0ba --- a/src/model/mmodule.nit +++ b/src/model/mmodule.nit @@@ -76,14 -76,6 +76,14 @@@ class MModul # The group of module in the project if any var mgroup: nullable MGroup + # The project of the module if any + # Safe alias for `mgroup.mproject` + fun mproject: nullable MProject + do + var g = mgroup + if g == null then return null else return g.mproject + end + # The short name of the module redef var name: String @@@ -112,22 -104,6 +112,22 @@@ 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") + # + # This method is used by entities to implement their `full_name`. + fun namespace_for(v: MVisibility): String do + if v <= private_visibility then return full_name + var mgroup = self.mgroup + if mgroup == null then + return full_name + else + return mgroup.mproject.full_name + end + end + # Return the name of the global C identifier associated to `self`. # This name is used to prefix files and other C identifiers associated with `self`. redef var c_name: String is lazy do @@@ -141,19 -117,6 +141,19 @@@ return res end + # C identifier version of `namespace_for`. + # See `c_name` + # + # This method is used by entities to implement their `c_name`. + fun c_namespace_for(v: MVisibility): String do + if v <= private_visibility then return c_name + var mgroup = self.mgroup + if mgroup == null then + return c_name + else + return mgroup.mproject.c_name + end + end # Create a new empty module and register it to a model init @@@ -166,6 -129,12 +166,6 @@@ assert mgroup.default_mmodule == null mgroup.default_mmodule = self end - # placebo for old module nesting hierarchy - var direct_owner = mgroup.default_mmodule - if direct_owner == self then - # The potential owner is the default_mmodule of the parent group - if mgroup.parent != null then direct_owner = mgroup.parent.default_mmodule - end end self.in_importation = model.mmodule_importation_hierarchy.add_node(self) end @@@ -240,5 -209,8 +240,8 @@@ # exposed to the final user. var is_fictive: Bool = false is writable + # Is `self` a unit test module used by `nitunit`? + var is_test_suite: Bool = false is writable + redef fun parent_concern do return mgroup end