nitc :: MPackage :: _allowed_ini_keys
nitc :: MPackage :: _browse_url
nitc :: MPackage :: _contributors
nitc :: MPackage :: _css_classes
nitc :: MPackage :: _homepage_url
nitc :: MPackage :: _issues_url
nitc :: MPackage :: _maintainer
nitc :: MPackage :: allowed_ini_keys
nitc :: MPackage :: allowed_ini_keys=
nitc :: MPackage :: browse_url
nitc :: MPackage :: browse_url=
nitc :: MPackage :: check_makefile
nitc :: MPackage :: check_readme
nitc :: MPackage :: collect_all_mgroups
Collect all groups contained inself
nitc :: MPackage :: collect_all_mmodules
Collect all modules contained inself
nitc :: MPackage :: collect_intro_attributes
Collect all attributes introduced inself
nitc :: MPackage :: collect_intro_inits
Collect all inits introduced inself
nitc :: MPackage :: collect_intro_mclasses
Collect all classes introduced inself
nitc :: MPackage :: collect_intro_methods
Collect all methods introduced inself
excluding inits
nitc :: MPackage :: collect_intro_mproperties
Collect all properties introduced inself
nitc :: MPackage :: collect_intro_vts
Collect all virtual types introduced inself
nitc :: MPackage :: collect_mgroups
Collect only groups contained inself.root
nitc :: MPackage :: collect_mmodules
Collect only modules contained inself.root
nitc :: MPackage :: collect_redef_mclasses
Collect all classes redefined or refined inself
nitc :: MPackage :: collect_redef_mproperties
Collect all properties redefined inself
nitc :: MPackage :: contributors
nitc :: MPackage :: contributors=
nitc :: MPackage :: defaultinit
nitc :: MPackage :: gen_makefile
nitc :: MPackage :: homepage_url
nitc :: MPackage :: homepage_url=
nitc :: MPackage :: import_alias
Get the name to search for, for aroot_name
declared as import
in ini
nitc :: MPackage :: issues_url
nitc :: MPackage :: issues_url=
nitc :: MPackage :: maintainer
nitc :: MPackage :: maintainer=
nitc :: model_collect $ MPackage :: collect_children
Collect all packages that directly depends onself
nitc :: api_metrics $ MPackage :: collect_metrics
nitc :: model_collect $ MPackage :: collect_modifiers
Collect modifier keywords likeredef
, private
etc
nitc :: model_collect $ MPackage :: collect_parents
Collect all packages directly imported byself
nitc :: json_model $ MPackage :: core_serialize_to
Actual serialization ofself
to serializer
nitc :: html_model $ MPackage :: css_classes
CSS classes used to decorateself
nitc :: html_model $ MPackage :: css_classes=
CSS classes used to decorateself
nitc :: html_model $ MPackage :: html_namespace
Returnsfull_name
decorated with HTML links
nitc :: json_model $ MPackage :: json_namespace
Returnself.full_name
as an object that can be serialized to json.
nitc $ MPackage :: mdoc_or_fallback
The documentation associated to the entity or their main nested entity.nitc :: model_index $ MPackage :: mentity_kind_rank
Compare MEntity class kindnitc $ MPackage :: parent_concern
MPackage are always roots of the concerns hierarchynitc :: commands_graph $ MPackage :: to_dot_node
Returnself
as a DotNode
nitc :: model_visitor $ MPackage :: visit_all
Visit the root group of the package.nitc :: MPackage :: _allowed_ini_keys
nitc :: MPackage :: _browse_url
nitc :: MEntity :: _const_color
nitc :: MPackage :: _contributors
nitc :: MEntity :: _css_classes
CSS classes used to decorateself
nitc :: MPackage :: _css_classes
nitc :: MEntity :: _deprecation
Is the entity deprecated?nitc :: MPackage :: _homepage_url
nitc :: MEntity :: _html_full_name
The MEntityfull_name
escaped for HTML
nitc :: MEntity :: _is_broken
The indication that the entity did not pass some semantic verifications.nitc :: MPackage :: _issues_url
nitc :: MPackage :: _maintainer
serialization :: Serializable :: accept_inspect_serializer_core
serialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePacknitc :: MEntity :: add_doc_to_infobox
Append an entry for the doc in the given infoboxserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
nitc :: MPackage :: allowed_ini_keys
nitc :: MPackage :: allowed_ini_keys=
nitc :: MPackage :: browse_url
nitc :: MPackage :: browse_url=
nitc :: MPackage :: check_makefile
nitc :: MPackage :: check_readme
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: MPackage :: collect_all_mgroups
Collect all groups contained inself
nitc :: MPackage :: collect_all_mmodules
Collect all modules contained inself
nitc :: MEntity :: collect_ancestors
Collectself
ancestors (direct and indirect)
nitc :: MEntity :: collect_children
Collectself
children (direct descendants)
nitc :: MEntity :: collect_descendants
Collectself
descendants (direct and direct)
nitc :: MPackage :: collect_intro_attributes
Collect all attributes introduced inself
nitc :: MPackage :: collect_intro_inits
Collect all inits introduced inself
nitc :: MPackage :: collect_intro_mclasses
Collect all classes introduced inself
nitc :: MPackage :: collect_intro_methods
Collect all methods introduced inself
excluding inits
nitc :: MPackage :: collect_intro_mproperties
Collect all properties introduced inself
nitc :: MPackage :: collect_intro_vts
Collect all virtual types introduced inself
nitc :: MEntity :: collect_linearization
Collectself
linearization anchored on mainmodule
nitc :: MEntity :: collect_metrics
nitc :: MPackage :: collect_mgroups
Collect only groups contained inself.root
nitc :: MPackage :: collect_mmodules
Collect only modules contained inself.root
nitc :: MEntity :: collect_modifiers
Collect modifier keywords likeredef
, private
etc
nitc :: MEntity :: collect_parents
Collectself
parents (direct ancestors)
nitc :: MPackage :: collect_redef_mclasses
Collect all classes redefined or refined inself
nitc :: MPackage :: collect_redef_mproperties
Collect all properties redefined inself
nitc :: MEntity :: const_color
nitc :: MEntity :: const_color=
nitc :: MPackage :: contributors
nitc :: MPackage :: contributors=
nitc :: MEntity :: core_serialize_base
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
nitc :: MEntity :: create_ast_representation
Build a ANode fromself
nitc :: MEntity :: cs_comment
Returns the comment of this MEntity formatted for console.nitc :: MEntity :: cs_declaration
Returns the complete MEntity declaration (modifiers + name + signature).nitc :: MEntity :: cs_full_name
Returnsself.full_name
formatted for console
nitc :: MEntity :: cs_list_item
Returnsself
as a list element that can be displayed in console.
nitc :: MEntity :: cs_location
Source code location of this MEntity formatted for consolenitc :: MEntity :: cs_short_comment
Returns the comment of this MEntity formatted for console.nitc :: MEntity :: cs_signature
Returnsself
signature formatted for console.
nitc :: MEntity :: cs_source_code
Source code associated to this MEntity.nitc :: MEntity :: css_classes=
CSS classes used to decorateself
core :: Object :: defaultinit
nitc :: HInfoBoxable :: defaultinit
nitc :: MPackage :: defaultinit
nitc :: MEntity :: defaultinit
nitc :: MConcern :: defaultinit
nitc :: MEntity :: deprecation=
Is the entity deprecated?nitc :: MEntity :: field_separator
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
nitc :: MPackage :: gen_makefile
nitc :: MEntity :: hierarchy_poset
Build a poset representingself
in it's own hierarchy
nitc :: MPackage :: homepage_url
nitc :: MPackage :: homepage_url=
nitc :: MEntity :: html_declaration
Returns the complete MEntity declaration decorated with HTMLnitc :: MEntity :: html_full_name=
The MEntityfull_name
escaped for HTML
nitc :: MEntity :: html_name=
The MEntity name escaped for HTMLnitc :: MEntity :: html_namespace
Returnsfull_name
decorated with HTML links
nitc :: MEntity :: html_signature
Returns the MEntity signature decorated with HTMLnitc :: MPackage :: import_alias
Get the name to search for, for aroot_name
declared as import
in ini
nitc :: HInfoBoxable :: infobox
An new infobox documenting the entitynitc :: MEntity :: is_broken=
The indication that the entity did not pass some semantic verifications.nitc :: MEntity :: is_fictive=
Isself
created for internal purpose?
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: MPackage :: issues_url
nitc :: MPackage :: issues_url=
nitc :: MEntity :: json_namespace
Returnself.full_name
as an object that can be serialized to json.
nitc :: MEntity :: line_separator
nitc :: MEntity :: linkto_text
Link to theself
with a specific text.
nitc :: MPackage :: maintainer
nitc :: MPackage :: maintainer=
nitc :: MEntity :: mdoc_or_fallback
The documentation associated to the entity or their main nested entity.serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: MConcern :: parent_concern
The concern that containsself
or null if self
is the root of the concern hierarchy
mentity
nitc :: MEntity :: ratings_by_dimension
Get the ratings of adimension
serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
serialization :: Serializable :: serialize_to_or_delay
Accept references or force direct serialization (usingserialize_to
)
nitc :: MEntity :: source_url
Render a HTML link for the MEntity locationserialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
nitc :: MEntity :: tpl_module
Builds a dot UML package diagram entity fromself
v.enter_visit
on all nested entities.
nitc :: MEntity :: write_extra_doc
Extra auto documentation to append to thestream
nitc :: MEntity :: write_location
Location (file and line when available) of related declarationsSerializer::serialize
# A Nit package, that encompass a product
class MPackage
super MConcern
# The name of the package
redef var name
redef fun full_name do return name
redef var c_name = name.to_cmangle is lazy
# The model of the package
redef var model
redef var location
# The root of the group tree
var root: nullable MGroup = null is writable
# The group tree, as a POSet
var mgroups = new POSet[MGroup]
redef fun to_s do return name
init
do
model.mpackages.add(self)
# Add `self` to the importation graph
model.mpackage_importation_graph.add_vertex(self)
model.mpackage_by_name.add_one(name, self)
end
# MPackage are always roots of the concerns hierarchy
redef fun parent_concern do return null
redef fun mdoc_or_fallback
do
var mdoc = self.mdoc
if mdoc != null then return mdoc
var root = self.root
if root != null then return root.mdoc_or_fallback
return null
end
# Does `self` have a source file?
fun has_source: Bool do return location.file != null
# The path to `self`
fun package_path: nullable String do
if not has_source then return null
return location.file.as(not null).filename
end
# Is `self` in its own directory?
fun is_expanded: Bool do
var path = package_path
if path == null then return false
return not path.has_suffix(".nit")
end
# The path to `self` ini file
fun ini_path: nullable String do
var path = package_path
if path == null then return null
if is_expanded then return path / "package.ini"
return path.dirname / "{name}.ini"
end
# Does `self` have a ini file?
fun has_ini: Bool do
var ini_path = self.ini_path
if ini_path == null then return false
return ini_path.file_exists
end
# The path to `self` README.md
fun readme_path: nullable String do
var path = package_path
if path == null then return null
if not is_expanded then return null
return path / "README.md"
end
# Does `self` have a README.md file?
fun has_readme: Bool do
var readme_path = self.readme_path
if readme_path == null then return false
return readme_path.file_exists
end
end
src/model/mpackage.nit:24,1--113,3
redef class MPackage
# The associated `.ini` file, if any
#
# The `ini` file is given as is and might contain invalid or missing information.
#
# Some packages, like stand-alone packages or virtual packages have no `ini` file associated.
var ini: nullable IniFile = null
# Array of relative source paths excluded according to the `source.exclude` key of the `ini`
var excludes: nullable Array[String] is lazy do
var ini = self.ini
if ini == null then return null
var exclude = ini["source.exclude"]
if exclude == null then return null
var excludes = exclude.split(":")
return excludes
end
# Does the source inclusion/inclusion rules of the package `ini` accept such path?
fun accept(filepath: String): Bool
do
var excludes = self.excludes
if excludes != null then
var relpath = root.filepath.relpath(filepath)
if excludes.has(relpath) then return false
end
return true
end
# Get the name to search for, for a `root_name` declared as `import` in `ini`
fun import_alias(root_name: String): nullable String
do
var map = import_aliases_parsed
if map == null then return null
var val = map.get_or_null(root_name)
if val == null then return null
return val.dir_name
end
private var import_aliases_parsed: nullable Map[String, ExternalPackage] is lazy do
var ini = ini
if ini == null then return null
var import_line = ini["package.import"]
if import_line == null then return null
var map = import_line.parse_import
if map.is_empty then return null
return map
end
end
src/loader.nit:1175,1--1228,3
redef class MPackage
redef fun to_node(nodes: HashMap[MEntity, NeoNode], model_name: nullable String): NeoNode do
if nodes.has_key(self) then return nodes[self]
var node = super
var root = root
if root != null then
node.out_edges.add(new NeoEdge(node, "ROOT", root.to_node(nodes, model_name)))
end
return node
end
end
src/neo.nit:685,1--695,3
redef class MPackage
redef fun collect_modifiers do return super + ["package"]
# Collect all packages directly imported by `self`
redef fun collect_parents(mainmodule, filter) do
var res = new HashSet[MENTITY]
for mgroup in mgroups do
for parent in mgroup.collect_parents(mainmodule, filter) do
var mpackage = parent.mpackage
if mpackage == self then continue
if filter == null or filter.accept_mentity(mpackage) then res.add(mpackage)
end
end
return res
end
# Collect all packages that directly depends on `self`
redef fun collect_children(mainmodule, filter) do
var res = new HashSet[MENTITY]
for mpackage in model.collect_mpackages(filter) do
if mpackage.collect_parents(mainmodule, filter).has(self) then res.add mpackage
end
return res
end
# Collect all groups contained in `self`
fun collect_all_mgroups(filter: nullable ModelFilter): HashSet[MGroup] do
var res = new HashSet[MGroup]
for mgroup in mgroups do
if filter == null or filter.accept_mentity(mgroup) then res.add(mgroup)
end
return res
end
# Collect only groups contained in `self.root`
fun collect_mgroups(filter: nullable ModelFilter): HashSet[MGroup] do
var res = new HashSet[MGroup]
var root = self.root
if root == null then return res
res.add_all root.collect_mgroups(filter)
return res
end
# Collect all modules contained in `self`
fun collect_all_mmodules(filter: nullable ModelFilter): HashSet[MModule] do
var res = new HashSet[MModule]
for mgroup in collect_all_mgroups(filter) do
res.add_all mgroup.collect_mmodules(filter)
end
return res
end
# Collect only modules contained in `self.root`
fun collect_mmodules(filter: nullable ModelFilter): HashSet[MModule] do
var res = new HashSet[MModule]
var root = self.root
if root == null then return res
res.add_all root.collect_mmodules(filter)
return res
end
# Collect all classes introduced in `self`
fun collect_intro_mclasses(filter: nullable ModelFilter): HashSet[MClass] do
var res = new HashSet[MClass]
for mgroup in mgroups do
for mmodule in collect_all_mmodules(filter) do
res.add_all mmodule.collect_intro_mclasses(filter)
end
end
return res
end
# Collect all classes redefined or refined in `self`
fun collect_redef_mclasses(filter: nullable ModelFilter): Set[MClass] do
var res = new HashSet[MClass]
for mgroup in mgroups do
for mmodule in collect_all_mmodules(filter) do
res.add_all mmodule.collect_redef_mclasses(filter)
end
end
return res
end
# Collect all properties introduced in `self`
fun collect_intro_mproperties(filter: nullable ModelFilter): HashSet[MProperty] do
var res = new HashSet[MProperty]
for mgroup in mgroups do
for mmodule in collect_all_mmodules(filter) do
res.add_all mmodule.collect_intro_mproperties(filter)
end
end
return res
end
# Collect all properties redefined in `self`
fun collect_redef_mproperties(filter: nullable ModelFilter): HashSet[MProperty] do
var res = new HashSet[MProperty]
for mgroup in mgroups do
for mmodule in collect_all_mmodules(filter) do
res.add_all mmodule.collect_redef_mproperties(filter)
end
end
return res
end
# Collect all attributes introduced in `self`
fun collect_intro_attributes(filter: nullable ModelFilter): Set[MAttribute] do
var res = new HashSet[MAttribute]
for mgroup in mgroups do
for mmodule in collect_all_mmodules(filter) do
res.add_all mmodule.collect_intro_attributes(filter)
end
end
return res
end
# Collect all inits introduced in `self`
fun collect_intro_inits(filter: nullable ModelFilter): Set[MMethod] do
var res = new HashSet[MMethod]
for mgroup in mgroups do
for mmodule in collect_all_mmodules(filter) do
res.add_all mmodule.collect_intro_inits(filter)
end
end
return res
end
# Collect all methods introduced in `self` excluding inits
#
# See `collect_intro_inits`.
fun collect_intro_methods(filter: nullable ModelFilter): Set[MMethod] do
var res = new HashSet[MMethod]
for mgroup in mgroups do
for mmodule in collect_all_mmodules(filter) do
res.add_all mmodule.collect_intro_methods(filter)
end
end
return res
end
# Collect all virtual types introduced in `self`
fun collect_intro_vts(filter: nullable ModelFilter): Set[MVirtualTypeProp] do
var res = new HashSet[MVirtualTypeProp]
for mgroup in mgroups do
for mmodule in collect_all_mmodules(filter) do
res.add_all mmodule.collect_intro_vts(filter)
end
end
return res
end
end
src/model/model_collect.nit:266,1--417,3
redef class MPackage
# Visit the root group of the package.
redef fun visit_all(v) do
v.enter_visit(root)
end
end
src/model/model_visitor.nit:113,1--118,3
redef class MPackage
redef fun mentity_kind_rank do return 1
end
src/model/model_index.nit:646,1--648,3
redef class MPackage
# Expand `self` in its own directory
private fun expand: String do
assert not is_expanded
var ori_path = package_path.as(not null)
var new_path = ori_path.dirname / name
new_path.mkdir
sys.system "mv {ori_path} {new_path / name}.nit"
var ini_file = "{new_path}.ini"
if ini_file.file_exists then
sys.system "mv {new_path}.ini {new_path}/package.ini"
end
return new_path
end
private var maintainer: nullable String is lazy do
return git_exec("git shortlog -esn . | head -n 1 | sed 's/\\s*[0-9]*\\s*//'")
end
private var contributors: Array[String] is lazy do
var contribs = git_exec("git shortlog -esn . | head -n -1 | " +
"sed 's/\\s*[0-9]*\\s*//'")
if contribs == null then return new Array[String]
return contribs.split("\n")
end
private var git_url: nullable String is lazy do
var git = git_exec("git remote get-url origin")
if git == null then return null
git = git.replace("git@github.com:", "https://github.com/")
git = git.replace("git@gitlab.com:", "https://gitlab.com/")
return git
end
private var git_dir: nullable String is lazy do
return git_exec("git rev-parse --show-prefix")
end
private var browse_url: nullable String is lazy do
var git = git_url
if git == null then return null
var browse = git.replace(".git", "")
var dir = git_dir
if dir == null or dir.is_empty then return browse
return "{browse}/tree/master/{dir}"
end
private var homepage_url: nullable String is lazy do
var git = git_url
if git == null then return null
# Special case for nit files
if git.has_suffix("/nit.git") then
return "http://nitlanguage.org"
end
return git.replace(".git", "")
end
private var issues_url: nullable String is lazy do
var git = git_url
if git == null then return null
return "{git.replace(".git", "")}/issues"
end
private var license: nullable String is lazy do
var git = git_url
if git == null then return null
# Special case for nit files
if git.has_suffix("/nit.git") then
return "Apache-2.0"
end
return null
end
private fun git_exec(cmd: String): nullable String do
var path = package_path
if path == null then return null
if not is_expanded then path = path.dirname
with pr = new ProcessReader("sh", "-c", "cd {path} && {cmd}") do
return pr.read_all.trim
end
end
private var allowed_ini_keys = [
"package.name", "package.desc", "package.tags", "package.license",
"package.maintainer", "package.more_contributors",
"upstream.browse", "upstream.git", "upstream.git.directory",
"upstream.homepage", "upstream.issues", "upstream.apk", "upstream.tryit",
"source.exclude"
]
private fun check_ini(toolcontext: ToolContext) do
if not has_ini then
toolcontext.error(location, "No `package.ini` file for `{name}`")
return
end
var pkg_path = package_path
if pkg_path == null then return
var ini_path = ini_path
if ini_path == null then return
var ini = new IniFile.from_file(ini_path)
ini.check_key(ini_path, toolcontext, self, "package.name", name)
ini.check_key(ini_path, toolcontext, self, "package.desc")
ini.check_key(ini_path, toolcontext, self, "package.tags")
# FIXME since `git reflog --follow` seems bugged
ini.check_key(ini_path, toolcontext, self, "package.maintainer")
# var maint = mpackage.maintainer
# if maint != null then
# ini.check_key(toolcontext, self, "package.maintainer", maint)
# end
# FIXME since `git reflog --follow` seems bugged
# var contribs = mpackage.contributors
# if contribs.not_empty then
# ini.check_key(toolcontext, self, "package.more_contributors", contribs.join(", "))
# end
ini.check_key(ini_path, toolcontext, self, "package.license", license)
ini.check_key(ini_path, toolcontext, self, "upstream.browse", browse_url)
ini.check_key(ini_path, toolcontext, self, "upstream.git", git_url)
ini.check_key(ini_path, toolcontext, self, "upstream.git.directory", git_dir)
ini.check_key(ini_path, toolcontext, self, "upstream.homepage", homepage_url)
ini.check_key(ini_path, toolcontext, self, "upstream.issues", issues_url)
for key in ini.flatten.keys do
if not allowed_ini_keys.has(key) then
toolcontext.warning(location, "unknown-ini-key",
"Warning: ignoring unknown `{key}` key in `{ini_path}`")
end
end
end
private fun gen_ini: String do
var ini_path = self.ini_path.as(not null)
var ini = new IniFile.from_file(ini_path)
ini.update_value("package.name", name)
ini.update_value("package.desc", "")
ini.update_value("package.tags", "")
ini.update_value("package.maintainer", maintainer)
ini.update_value("package.more_contributors", contributors.join(","))
ini.update_value("package.license", license or else "")
ini.update_value("upstream.browse", browse_url)
ini.update_value("upstream.git", git_url)
ini.update_value("upstream.git.directory", git_dir)
ini.update_value("upstream.homepage", homepage_url)
ini.update_value("upstream.issues", issues_url)
ini.write_to_file(ini_path)
return ini_path
end
# Makefile
# The path to `self` Makefile
fun makefile_path: nullable String do
var path = package_path
if path == null then return null
if not is_expanded then return null
return path / "Makefile"
end
# Does `self` have a Makefile?
fun has_makefile: Bool do
var makefile_path = self.makefile_path
if makefile_path == null then return false
return makefile_path.file_exists
end
private fun check_makefile(toolcontext: ToolContext, mainmodule: MModule) do
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(accept_example = false, accept_test = false)
var cmd_bin = new CmdMains(model, filter, mentity = self)
var res_bin = cmd_bin.init_command
if not res_bin isa CmdSuccess then return
for mmodule in cmd_bin.results.as(not null) do
if not mmodule isa MModule then continue
if mmodule.makefile_path == null then
toolcontext.warning(location, "missing-makefile",
"Warning: no Makefile for executable module `{mmodule.full_name}`")
end
end
end
private fun gen_makefile(model: Model, mainmodule: MModule): nullable String do
var filter = new ModelFilter(accept_example = false, accept_test = false)
var pkg_path = package_path.as(not null)
var makefile_path = makefile_path.as(not null)
var bins = new Array[String]
var cmd_bin = new CmdMains(model, filter, mentity = self)
var res_bin = cmd_bin.init_command
if res_bin isa CmdSuccess then
for mmodule in cmd_bin.results.as(not null) do
if not mmodule isa MModule then continue
var mmodule_makefile = mmodule.makefile_path
if mmodule_makefile != null and mmodule_makefile != makefile_path then continue
var file = mmodule.location.file
if file == null then continue
# Remove package path prefix
var bin_path = file.filename
if pkg_path.has_suffix("/") then
bin_path = bin_path.replace(pkg_path, "")
else
bin_path = bin_path.replace("{pkg_path}/", "")
end
bins.add bin_path
end
end
if bins.is_empty then return null
var make = new NitMakefile(bins)
make.render.write_to_file(makefile_path)
return makefile_path
end
# Manpages
# The path to `self` manpage files
private fun man_path: nullable String do
var path = package_path
if path == null then return null
if not is_expanded then return null
return path / "man"
end
# Does `self` have a manpage files?
private fun has_man: Bool do
var man_path = self.man_path
if man_path == null then return false
return man_path.file_exists
end
private fun check_man(toolcontext: ToolContext, mainmodule: MModule) do
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(accept_example = false, accept_test = false)
var cmd = new CmdMains(model, filter, mentity = self)
var res = cmd.init_command
if not res isa CmdSuccess then return
for mmodule in cmd.results.as(not null) do
if not mmodule isa MModule then continue
mmodule.check_man(toolcontext)
end
end
private fun gen_man(toolcontext: ToolContext, mainmodule: MModule) do
var model = toolcontext.modelbuilder.model
var filter = new ModelFilter(accept_example = false, accept_test = false)
var cmd = new CmdMains(model, filter, mentity = self)
var res = cmd.init_command
if not res isa CmdSuccess then return
var pkg_man = man_path.as(not null)
for mmodule in cmd.results.as(not null) do
if not mmodule isa MModule then continue
if not has_man then pkg_man.mkdir
mmodule.gen_man(toolcontext)
end
end
# README
private fun check_readme(toolcontext: ToolContext) do
if not has_readme then
toolcontext.error(location, "No `README.md` file for `{name}`")
return
end
end
end
src/nitpackage.nit:149,1--434,3
redef class MPackage
redef fun html_namespace do return html_link
redef fun html_icon do return new BSIcon("book", ["text-muted"])
redef var css_classes = ["public"]
end
src/doc/templates/html_model.nit:98,1--102,3
redef class MPackage
redef fun core_serialize_to(v) do
super
var metadata = self.metadata
if metadata.license != null then
v.serialize_attribute("license", metadata.license)
end
if metadata.maintainers.not_empty then
v.serialize_attribute("maintainer", metadata.maintainers.first)
end
if metadata.tags.not_empty then
v.serialize_attribute("tags", metadata.tags)
end
end
redef fun json_namespace do
var ns = new JsonNamespace
ns.add to_json_ref
return ns
end
end
src/doc/templates/json_model.nit:95,1--116,3
redef class MPackage
redef var html_url is lazy do return "package_{super}"
end
src/doc/static/static_html.nit:376,1--378,3
redef class MPackage
redef fun collect_metrics(h) do
var mclasses = new HashSet[MClass]
for mgroup in self.mgroups do
for mmodule in mgroup.mmodules do mclasses.add_all mmodule.intro_mclasses
end
var mclasses_metrics = h.mclasses_metrics
mclasses_metrics.collect(new HashSet[MClass].from(mclasses))
var mmodules = new HashSet[MModule]
for mgroup in self.mgroups do
mmodules.add_all mgroup.mmodules
end
var mmodules_metrics = h.mmodules_metrics
mmodules_metrics.collect(new HashSet[MModule].from(mmodules))
var metrics = new JsonObject
metrics["mclasses"] = mclasses_metrics
metrics["mmodules"] = mmodules_metrics
return metrics
end
end
src/doc/api/api_metrics.nit:83,1--106,3