nitc :: DocCommand :: init_command
Returns a command message that gives the status of the command initialization.
There is 3 categories of messages:
CmdSuccess
: when the command that initialized correctly;CmdError
: when the command cannot be initialized;CmdWarning
: when something is wrong with the command but a result still can be produced.Warnings are generally used to distinguish empty list or mdoc from no data at all.
# Initialize the command
#
# Returns a command message that gives the status of the command initialization.
#
# There is 3 categories of messages:
# * `CmdSuccess`: when the command that initialized correctly;
# * `CmdError`: when the command cannot be initialized;
# * `CmdWarning`: when something is wrong with the command but a result still can be produced.
#
# Warnings are generally used to distinguish empty list or mdoc from no data at all.
fun init_command: CmdMessage do return new CmdSuccess
src/doc/commands/commands_base.nit:61,2--71,54
# See `init_mentity`.
redef fun init_command do return init_mentity
src/doc/commands/commands_base.nit:164,2--165,46
redef fun init_command do
if not allowed_formats.has(format) then
return new ErrorBadGraphFormat(format, allowed_formats)
end
return super
end
src/doc/commands/commands_graph.nit:60,2--65,4
# `init_command` is used to factorize the sorting and pagination of results
#
# See `init_results` for the result list initialization.
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
res = init_results
if not res isa CmdSuccess then return res
sort
paginate
return res
end
src/doc/commands/commands_base.nit:242,2--253,4
# Same states than `CmdEntity::init_mentity`
#
# Plus returns `WarningNoMDoc` if no MDoc was found for the MEntity.
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
if mdoc == null then
mdoc = if fallback then mentity.mdoc_or_fallback else mentity.mdoc
end
if mdoc == null then return new WarningNoMDoc(mentity)
return res
end
src/doc/commands/commands_model.nit:52,2--65,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
if text == null then
text = mentity.name
end
if title == null then
var mdoc = mentity.mdoc_or_fallback
if mdoc != null then
title = mdoc.synopsis
end
end
return res
end
src/doc/commands/commands_model.nit:97,2--112,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
return init_file
end
src/doc/commands/commands_ini.nit:290,2--294,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
if mentity isa MModule then
file = mmodule_main(mentity)
if file == null then return new WarningNoMain(mentity)
else
return new WarningNoMain(mentity)
end
return res
end
src/doc/commands/commands_main.nit:85,2--97,4
redef fun init_command do
if metadata != null then return new CmdSuccess
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
if mentity isa MPackage then
metadata = mentity.metadata
else
return new WarningNoMetadata(mentity)
end
return res
end
src/doc/commands/commands_catalog.nit:107,2--120,4
redef fun init_command do
super
self.stats = catalog.catalog_stats
return new CmdSuccess
end
src/doc/commands/commands_catalog.nit:160,2--164,4
redef fun init_command do
super
var tags_to_projects = new ArrayMap[String, Int]
var tags = catalog.tag2proj.keys.to_a
tags_sorter.sort(tags)
for tag in tags do
if not catalog.tag2proj.has_key(tag) then continue
tags_to_projects[tag] = catalog.tag2proj[tag].length
end
packages_count_by_tags = tags_to_projects
return new CmdSuccess
end
src/doc/commands/commands_catalog.nit:177,2--188,4
redef fun init_command do
init_person
return super
end
src/doc/commands/commands_catalog.nit:265,2--268,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
if not mentity isa MPackage then return new WarningNoIni(mentity)
var ini = mentity.ini
if ini == null then return new WarningNoIni(mentity)
self.ini = ini
return res
end
src/doc/commands/commands_ini.nit:26,2--39,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var mpackage = null
if mentity isa MPackage then
mpackage = mentity
else if mentity isa MGroup then
mpackage = mentity.mpackage
else if mentity isa MModule then
mpackage = mentity.mpackage
end
if mpackage == null then return new WarningNoManFile(mentity)
var source_file = mpackage.location.file
if source_file == null then return new WarningNoManFile(mentity)
var man_dir = source_file.filename / "man"
if not man_dir.file_exists then return new WarningNoManFile(mentity)
var man_file = null
for file in man_dir.files do
if not file.has_prefix(mentity.name) then continue
man_file = man_dir / file
end
if man_file == null then return new WarningNoManFile(mentity)
self.file = man_file
return res
end
src/doc/commands/commands_main.nit:204,2--236,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var ini = self.ini.as(not null)
var desc = ini["package.desc"]
if desc == null then return new WarningNoDescription(mentity)
self.desc = desc
return res
end
src/doc/commands/commands_ini.nit:59,2--71,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var ini = self.ini.as(not null)
var url = ini["upstream.git"]
if url == null then return new WarningNoGitUrl(mentity)
self.url = url
return res
end
src/doc/commands/commands_ini.nit:91,2--103,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var ini = self.ini.as(not null)
var url = ini["upstream.issues"]
if url == null then return new WarningNoIssuesUrl(mentity)
self.url = url
return res
end
src/doc/commands/commands_ini.nit:135,2--147,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var ini = self.ini.as(not null)
var maintainer = ini["package.maintainer"]
if maintainer == null then return new WarningNoMaintainer(mentity)
self.maintainer = maintainer
return res
end
src/doc/commands/commands_ini.nit:167,2--179,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var ini = self.ini.as(not null)
var names = ini["package.more_contributors"]
if names == null then return new WarningNoContributor(mentity)
var contributors = new Array[String]
for name in names.split(",") do
contributors.add name.trim
end
if contributors.is_empty then return new WarningNoContributor(mentity)
self.contributors = contributors
return res
end
src/doc/commands/commands_ini.nit:199,2--217,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var ini = self.ini.as(not null)
var license = ini["package.license"]
if license == null then return new WarningNoLicense(mentity)
self.license = license
return res
end
src/doc/commands/commands_ini.nit:237,2--249,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var file = self.file.as(not null)
var lines = file.to_path.read_lines
var in_synopsis = false
for line in lines do
if in_synopsis and line.has_prefix(mentity.name) then
synopsis = line
break
end
if line != "# SYNOPSIS" then continue
in_synopsis = true
end
if synopsis == null then return new WarningNoManSynopsis(mentity)
return res
end
src/doc/commands/commands_main.nit:255,2--275,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var file = self.file.as(not null)
var options = new ArrayMap[String, String]
var lines = file.to_path.read_lines
var in_options = false
for i in [0 .. lines.length[ do
var line = lines[i]
if line == "# OPTIONS" then
in_options = true
else if in_options and line.has_prefix("### ") then
var opt = line.substring(4, line.length).trim.replace("`", "")
var desc = ""
if i < lines.length - 1 then
desc = lines[i + 1].trim
end
options[opt] = desc
else if line.has_prefix("# ") then
in_options = false
end
end
if options.is_empty then return new WarningNoManOptions(mentity)
self.options = options
return res
end
src/doc/commands/commands_main.nit:294,2--324,4
# Same as `CmdEntity::init_mentity`
#
# Plus `WarningNoCode` if no code/AST node is found for `mentity`.
redef fun init_command do
if node != null then return new CmdSuccess
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
if mentity isa MClass then mentity = mentity.intro
if mentity isa MProperty then mentity = mentity.intro
node = modelbuilder.mentity2node(mentity)
if node == null then return new WarningNoCode(mentity)
return res
end
src/doc/commands/commands_model.nit:453,2--468,4
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var mdoc = self.mdoc
if mdoc == null then
mdoc = if fallback then mentity.mdoc_or_fallback else mentity.mdoc
self.mdoc = mdoc
end
if mdoc == null then return new WarningNoMDoc(mentity)
markdown_processor.process(mdoc.md_documentation.write_to_string)
var summary = new ArrayMap[String, HeadLine]
summary.add_all markdown_processor.decorator.headlines
self.summary = summary
return res
end
src/doc/commands/commands_docdown.nit:35,2--53,4
redef fun init_command do
if uml != null then return new CmdSuccess
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
if mentity isa MClassDef then mentity = mentity.mclass
if mentity isa MClass or mentity isa MModule then
uml = new UMLModel(model, mainmodule, filter)
else
return new WarningNoUML(mentity)
end
return res
end
src/doc/commands/commands_graph.nit:102,2--116,4
redef fun init_command do
if graph != null then return new CmdSuccess
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
graph = new InheritanceGraph(mentity, model, mainmodule, filter)
return res
end
src/doc/commands/commands_graph.nit:156,2--165,4
redef fun init_command do
var res = init_mentity
if not res isa CmdSuccess then return res
res = init_results
if not res isa CmdSuccess then return res
sort
paginate
return res
end
src/doc/commands/commands_base.nit:324,2--332,4
redef fun init_command do return super
src/doc/commands/commands_catalog.nit:295,2--39
# FIXME linearization
redef fun init_command do return super
src/doc/commands/commands_catalog.nit:321,2--322,39