Introduced classes

class CmdMainCompile

nitc :: CmdMainCompile

Cmd that finds the nitc command related to an mentity
class CmdMains

nitc :: CmdMains

Cmd that finds the mains of an mentity
class CmdManFile

nitc :: CmdManFile

Cmd that finds the man file related to an mentity
class CmdTesting

nitc :: CmdTesting

Cmd that finds the nitunit command related to an mentity
class WarningNoMain

nitc :: WarningNoMain

No tests for mentity
class WarningNoMains

nitc :: WarningNoMains

No tests for mentity
class WarningNoManFile

nitc :: WarningNoManFile

No man file for mentity
class WarningNoManOptions

nitc :: WarningNoManOptions

No options description found in the man file for mentity
class WarningNoManSynopsis

nitc :: WarningNoManSynopsis

No synopsis found in the man file for mentity
class WarningNoTest

nitc :: WarningNoTest

No tests for mentity

All class definitions

class CmdMainCompile

nitc $ CmdMainCompile

Cmd that finds the nitc command related to an mentity
class CmdMains

nitc $ CmdMains

Cmd that finds the mains of an mentity
class CmdManFile

nitc $ CmdManFile

Cmd that finds the man file related to an mentity
class CmdTesting

nitc $ CmdTesting

Cmd that finds the nitunit command related to an mentity
class WarningNoMain

nitc $ WarningNoMain

No tests for mentity
class WarningNoMains

nitc $ WarningNoMains

No tests for mentity
class WarningNoManFile

nitc $ WarningNoManFile

No man file for mentity
class WarningNoManOptions

nitc $ WarningNoManOptions

No options description found in the man file for mentity
class WarningNoManSynopsis

nitc $ WarningNoManSynopsis

No synopsis found in the man file for mentity
class WarningNoTest

nitc $ WarningNoTest

No tests for mentity
package_diagram nitc::commands_main commands_main nitc::commands_model commands_model nitc::commands_main->nitc::commands_model nitc::commands_base commands_base nitc::commands_model->nitc::commands_base nitc\>modelize\> modelize nitc::commands_model->nitc\>modelize\> ...nitc::commands_base ... ...nitc::commands_base->nitc::commands_base ...nitc\>modelize\> ... ...nitc\>modelize\>->nitc\>modelize\> nitc::md_commands md_commands nitc::md_commands->nitc::commands_main nitc::commands_parser commands_parser nitc::commands_parser->nitc::commands_main nitc::nitpackage nitpackage nitc::nitpackage->nitc::commands_main nitc::commands_http commands_http nitc::commands_http->nitc::commands_main nitc::json_commands json_commands nitc::json_commands->nitc::commands_main nitc::commands_docdown commands_docdown nitc::commands_docdown->nitc::md_commands nitc::term term nitc::term->nitc::md_commands nitc::term->nitc::commands_parser nitc::commands_docdown... ... nitc::commands_docdown...->nitc::commands_docdown nitc::term... ... nitc::term...->nitc::term nitc::html_commands html_commands nitc::html_commands->nitc::commands_parser nitc::html_commands... ... nitc::html_commands...->nitc::html_commands a_star-m a_star-m a_star-m->nitc::nitpackage a_star-m... ... a_star-m...->a_star-m nitc::api_base api_base nitc::api_base->nitc::commands_http nitc::api_base->nitc::json_commands nitc::api_base... ... nitc::api_base...->nitc::api_base

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module abstract_tree

trees :: abstract_tree

Introduce tree structures abstraction
module annotation

nitc :: annotation

Management and utilities on annotations
module array

core :: array

This module introduces the standard array structure.
module bintree

trees :: bintree

Binary Tree data-structure
module bitset

core :: bitset

Services to handle BitSet
module bktree

trees :: bktree

Implementation of BKTree
module bytes

core :: bytes

Services for byte streams and arrays
module caching

serialization :: caching

Services for caching serialization engines
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module commands_base

nitc :: commands_base

Documentation commands
module console

console :: console

Defines some ANSI Terminal Control Escape Sequences.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module digraph

graph :: digraph

Implementation of directed graphs, also called digraphs.
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module ini

ini :: ini

Read and write INI configuration files
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module lexer

nitc :: lexer

Lexer and its tokens.
module lexer_work

nitc :: lexer_work

Internal algorithm and data structures for the Nit lexer
module list

core :: list

This module handle double linked lists
module literal

nitc :: literal

Parsing of literal values in the abstract syntax tree.
module loader

nitc :: loader

Loading of Nit source files
module location

nitc :: location

Nit source-file and locations in source-file
module math

core :: math

Mathematical operations
module mdoc

nitc :: mdoc

Documentation of model entities
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module mmodule

nitc :: mmodule

modules and module hierarchies in the metamodel
module mmodule_data

nitc :: mmodule_data

Define and retrieve data in modules
module model

nitc :: model

Classes, types and properties
module model_base

nitc :: model_base

The abstract concept of model and related common things
module model_collect

nitc :: model_collect

Collect things from the model.
module model_examples

nitc :: model_examples

Examples for Model entities
module model_index

nitc :: model_index

Search things from the Model
module modelbuilder_base

nitc :: modelbuilder_base

Load nit source files and build the associated model
module modelize

nitc :: modelize

Create a model from nit source files
module modelize_class

nitc :: modelize_class

Analysis and verification of class definitions to instantiate model element
module modelize_property

nitc :: modelize_property

Analysis and verification of property definitions to instantiate model element
module more_collections

more_collections :: more_collections

Highly specific, but useful, collections-related classes.
module mpackage

nitc :: mpackage

Modelisation of a Nit package
module native

core :: native

Native structures for text and bytes
module nitpm_shared

nitc :: nitpm_shared

Services related to the Nit package manager
module numeric

core :: numeric

Advanced services for Numeric types
module opts

opts :: opts

Management of options on the command line
module ordered_tree

ordered_tree :: ordered_tree

Manipulation and presentation of ordered trees.
module parse_annotations

nitc :: parse_annotations

Simple annotation parsing
module parser

nitc :: parser

Parser.
module parser_nodes

nitc :: parser_nodes

AST nodes of the Nit language
module parser_prod

nitc :: parser_prod

Production AST nodes full definition.
module parser_work

nitc :: parser_work

Internal algorithm and data structures for the Nit parser
module phase

nitc :: phase

Phases of the processing of nit programs
module poset

poset :: poset

Pre order sets and partial order set (ie hierarchies)
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module rbtree

trees :: rbtree

A red–black tree is a data structure which is a type of self-balancing binary search tree.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module serialization

serialization :: serialization

General serialization services
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module tables

nitc :: tables

Module that interfaces the parsing tables.
module template

template :: template

Basic template system
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module toolcontext

nitc :: toolcontext

Common command-line tool infrastructure than handle options and error messages
module trees

trees :: trees

General module for tree data structures
module trie

trees :: trie

A trie (or prefix tree) is a datastructure used to perform prefix searches.
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O
module version

nitc :: version

This file was generated by git-gen-version.sh

Parents

module commands_model

nitc :: commands_model

Doc commands about a Model or a MEntity

Children

module commands_http

nitc :: commands_http

Initialize commands from HTTP requests
module commands_parser

nitc :: commands_parser

A parser that create DocCommand from a string
module json_commands

nitc :: json_commands

Translate command results to json
module md_commands

nitc :: md_commands

Render commands results as Markdown
module nitpackage

nitc :: nitpackage

Helpful features about packages

Descendants

module a_star-m

a_star-m

module api

nitc :: api

Components required to build a web server about the nit model.
module api_auth

nitc :: api_auth

module api_base

nitc :: api_base

Base classes used by nitweb.
module api_docdown

nitc :: api_docdown

Nitdoc specific Markdown format handling for Nitweb
module api_feedback

nitc :: api_feedback

Feedback related features
module api_light

nitc :: api_light

Highlight and collect messages from a piece of code
module api_model

nitc :: api_model

module commands_docdown

nitc :: commands_docdown

Doc down related queries
module html_commands

nitc :: html_commands

Render commands results as HTML
module nitdoc

nitc :: nitdoc

Generator of static API documentation for the Nit language
module nitweb

nitc :: nitweb

Runs a webserver based on nitcorn that render things from model.
module nitx

nitc :: nitx

nitx, a command tool that displays useful data about Nit code
module static

nitc :: static

Nitdoc generation framework
module static_base

nitc :: static_base

Base entities shared by all the nitdoc code
module static_cards

nitc :: static_cards

Cards templates for the static documentation
module static_html

nitc :: static_html

Render documentation pages as HTML
module static_index

nitc :: static_index

Manage indexing of Nit model for Nitdoc QuickSearch.
module static_structure

nitc :: static_structure

Composes the pages of the static documentation
module term

nitc :: term

module commands_main

import commands_model

# Cmd that finds the mains of an `mentity`
class CmdMains
	super CmdEntityList

	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)
		var mentities = new Array[MEntity]

		if mentity isa MPackage then
			for mmodule in mentity.collect_all_mmodules(filter) do
				if mmodule_has_main(mmodule) then mentities.add mmodule
			end
		else if mentity isa MGroup then
			for mmodule in mentity.collect_all_mmodules(filter) do
				if mmodule_has_main(mmodule) then mentities.add mmodule
			end
		else if mentity isa MModule then
			if mmodule_has_main(mentity) then mentities.add mentity
		else
			return new WarningNoMains(mentity)
		end

		if mentities.is_empty then return new WarningNoMains(mentity)

		self.results = mentities
		return res
	end

	# Does `mmodule` has a `main` method?
	private fun mmodule_has_main(mmodule: MModule): Bool do
		for mclassdef in mmodule.collect_redef_mclassdefs(filter) do
			if mclassdef.name != "Sys" then continue
			for mpropdef in mclassdef.collect_redef_mpropdefs(filter) do
				if mpropdef.name == "main" then return true
			end
		end
		return false
	end
end

# No tests for `mentity`
class WarningNoMains
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

	redef fun to_s do return "No main found for `{mentity.full_name}`"
end

# Cmd that finds the nitc command related to an `mentity`
class CmdMainCompile
	super CmdEntity

	var file: nullable SourceFile = null

	var command: nullable String is lazy do
		var path = test_path(file)
		if path == null then return null
		return "nitc {path}"
	end

	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

	# Does `mmodule` has a `main` method?
	private fun mmodule_main(mmodule: MModule): nullable SourceFile do
		for mclassdef in mmodule.mclassdefs do
			if mclassdef.name != "Sys" then continue
			for mpropdef in mclassdef.mpropdefs do
				if mpropdef.name == "main" then return mmodule.location.file
			end
		end
		return null
	end

	# Return the sourcefile path
	#
	# This method exists for the only purpose to be redefined by nitunit tests
	# to avoid path diffs.
	private fun test_path(file: nullable SourceFile): nullable String do
		if file == null then return null
		var base_path = mentity.as(MModule).mpackage.as(not null).location.file.as(not null).filename
		return file.filename.replace(base_path, "")
	end
end

# No tests for `mentity`
class WarningNoMain
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

	redef fun to_s do return "No main to compile for `{mentity.full_name}`"
end

# Cmd that finds the nitunit command related to an `mentity`
class CmdTesting
	super CmdEntityList

	var command: nullable String is lazy do
		var results = self.results
		if results == null then return null

		var tpl = new Template
		tpl.add "nitunit"
		for result in results do
			var path = test_path(result)
			if path == null then continue
			tpl.add " {path}"
		end
		return tpl.write_to_string
	end

	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		var mentities = new Array[MEntity]
		if not mentity isa MPackage then return new WarningNoTest(mentity)

		for mgroup in mentity.collect_all_mgroups(filter) do
			if mgroup.is_test then
				mentities.add mgroup
				continue
			end
			for mmodule in mgroup.collect_mmodules(filter) do
				if mmodule.is_test then mentities.add mmodule
			end
		end

		if mentities.is_empty then return new WarningNoTest(mentity)

		self.results = mentities
		return res
	end

	# Return the mentity path
	#
	# This method exists for the only purpose to be redefined by nitunit tests
	# to avoid path diffs.
	private fun test_path(mentity: MEntity): nullable String do
		var file = mentity.location.file
		if file == null then return null
		var base_path = self.mentity.as(not null).location.file.as(not null).filename
		return file.filename.replace(base_path, "")
	end
end

# No tests for `mentity`
class WarningNoTest
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

	redef fun to_s do return "No nitunit files for `{mentity.full_name}`"
end

# Cmd that finds the man file related to an `mentity`
class CmdManFile
	super CmdEntity

	# Man file
	var file: nullable String = null

	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
end

# No man file for `mentity`
class WarningNoManFile
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

	redef fun to_s do return "No man file for `{mentity.full_name}`"
end

class CmdManSynopsis
	super CmdManFile

	# Synopsis string extracted from man
	var synopsis: nullable String

	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
end

# No synopsis found in the man file for `mentity`
class WarningNoManSynopsis
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

	redef fun to_s do return "No synopsis found in the man file for `{mentity.full_name}`"
end

class CmdManOptions
	super CmdManFile

	# Options description
	var options: nullable ArrayMap[String, String]

	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
end

# No options description found in the man file for `mentity`
class WarningNoManOptions
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

	redef fun to_s do return "No options description found in the man file for `{mentity.full_name}`"
end
src/doc/commands/commands_main.nit:15,1--335,3