Doc commands about a Model or a MEntity

This module defines several commands to retrieve data about a Model and MEntities.

Introduced classes

class CmdAllProps

nitc :: CmdAllProps

TODO remove once the filters/sorters are merged
class CmdAncestors

nitc :: CmdAncestors

MEntity ancestors command
class CmdChildren

nitc :: CmdChildren

MEntity children command
abstract class CmdCode

nitc :: CmdCode

Abstract command that returns source-code pieces
class CmdComment

nitc :: CmdComment

Retrieve the MDoc related to a MEntity
class CmdDescendants

nitc :: CmdDescendants

MEntity descendants command
class CmdEntityCode

nitc :: CmdEntityCode

Cmd that finds the source code related to an mentity
class CmdFeatures

nitc :: CmdFeatures

MEntity feature list
abstract class CmdInheritance

nitc :: CmdInheritance

An abstract inheritance command
class CmdIntros

nitc :: CmdIntros

TODO remove once the filters/sorters are merged
class CmdLinearization

nitc :: CmdLinearization

Linearization command
class CmdModelEntities

nitc :: CmdModelEntities

A command that returns a list of all mentities in a model
class CmdParents

nitc :: CmdParents

MEntity parents command
class CmdRandomEntities

nitc :: CmdRandomEntities

A command that returns a random list of mentities from a model
class CmdRedefs

nitc :: CmdRedefs

TODO remove once the filters/sorters are merged
class CmdSearch

nitc :: CmdSearch

A free text search command
class ErrorNoQuery

nitc :: ErrorNoQuery

No query string given
class WarningNoCode

nitc :: WarningNoCode

No code for mentity
class WarningNoFeatures

nitc :: WarningNoFeatures

No feature list for mentity
class WarningNoLinearization

nitc :: WarningNoLinearization

No linearization computed for mentity.
class WarningNoMDoc

nitc :: WarningNoMDoc

No MDoc for mentity

All class definitions

class CmdAllProps

nitc $ CmdAllProps

TODO remove once the filters/sorters are merged
class CmdAncestors

nitc $ CmdAncestors

MEntity ancestors command
class CmdChildren

nitc $ CmdChildren

MEntity children command
abstract class CmdCode

nitc $ CmdCode

Abstract command that returns source-code pieces
class CmdComment

nitc $ CmdComment

Retrieve the MDoc related to a MEntity
class CmdDescendants

nitc $ CmdDescendants

MEntity descendants command
class CmdEntityCode

nitc $ CmdEntityCode

Cmd that finds the source code related to an mentity
class CmdFeatures

nitc $ CmdFeatures

MEntity feature list
abstract class CmdInheritance

nitc $ CmdInheritance

An abstract inheritance command
class CmdIntros

nitc $ CmdIntros

TODO remove once the filters/sorters are merged
class CmdLinearization

nitc $ CmdLinearization

Linearization command
class CmdModelEntities

nitc $ CmdModelEntities

A command that returns a list of all mentities in a model
class CmdParents

nitc $ CmdParents

MEntity parents command
class CmdRandomEntities

nitc $ CmdRandomEntities

A command that returns a random list of mentities from a model
class CmdRedefs

nitc $ CmdRedefs

TODO remove once the filters/sorters are merged
class CmdSearch

nitc $ CmdSearch

A free text search command
class ErrorNoQuery

nitc $ ErrorNoQuery

No query string given
class WarningNoCode

nitc $ WarningNoCode

No code for mentity
class WarningNoFeatures

nitc $ WarningNoFeatures

No feature list for mentity
class WarningNoLinearization

nitc $ WarningNoLinearization

No linearization computed for mentity.
class WarningNoMDoc

nitc $ WarningNoMDoc

No MDoc for mentity
package_diagram nitc::commands_model commands_model nitc::commands_base commands_base nitc::commands_model->nitc::commands_base nitc\>modelize\> modelize nitc::commands_model->nitc\>modelize\> nitc::model_index model_index nitc::commands_base->nitc::model_index nitc nitc nitc\>modelize\>->nitc ...nitc::model_index ... ...nitc::model_index->nitc::model_index ...nitc ... ...nitc->nitc nitc::commands_catalog commands_catalog nitc::commands_catalog->nitc::commands_model nitc::commands_graph commands_graph nitc::commands_graph->nitc::commands_model nitc::commands_ini commands_ini nitc::commands_ini->nitc::commands_model nitc::commands_main commands_main nitc::commands_main->nitc::commands_model nitc::commands_usage commands_usage nitc::commands_usage->nitc::commands_model nitc::md_commands md_commands nitc::md_commands->nitc::commands_catalog nitc::md_commands->nitc::commands_graph nitc::md_commands->nitc::commands_ini nitc::md_commands->nitc::commands_main nitc::md_commands->nitc::commands_usage nitc::commands_parser commands_parser nitc::commands_parser->nitc::commands_catalog nitc::commands_parser->nitc::commands_graph nitc::commands_parser->nitc::commands_ini nitc::commands_parser->nitc::commands_main nitc::commands_parser->nitc::commands_usage nitc::commands_http commands_http nitc::commands_http->nitc::commands_catalog nitc::commands_http->nitc::commands_graph nitc::commands_http->nitc::commands_ini nitc::commands_http->nitc::commands_main nitc::commands_http->nitc::commands_usage nitc::json_commands json_commands nitc::json_commands->nitc::commands_catalog nitc::json_commands->nitc::commands_graph nitc::json_commands->nitc::commands_ini nitc::json_commands->nitc::commands_main nitc::json_commands->nitc::commands_usage nitc::md_commands... ... nitc::md_commands...->nitc::md_commands nitc::commands_parser... ... nitc::commands_parser...->nitc::commands_parser nitc::commands_http... ... nitc::commands_http...->nitc::commands_http nitc::json_commands... ... nitc::json_commands...->nitc::json_commands nitc::nitpackage nitpackage nitc::nitpackage->nitc::commands_main nitc::nitpackage... ... nitc::nitpackage...->nitc::nitpackage

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 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_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_base

nitc :: commands_base

Documentation commands
module modelize

nitc :: modelize

Create a model from nit source files

Children

module commands_catalog

nitc :: commands_catalog

Commands to retrieve Catalog related data
module commands_graph

nitc :: commands_graph

Graph commands
module commands_usage

nitc :: commands_usage

Commands about how mentities are used

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 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 html_commands

nitc :: html_commands

Render commands results as HTML
module json_commands

nitc :: json_commands

Translate command results to json
module md_commands

nitc :: md_commands

Render commands results as Markdown
module nitdoc

nitc :: nitdoc

Generator of static API documentation for the Nit language
module nitpackage

nitc :: nitpackage

Helpful features about packages
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

# Doc commands about a Model or a MEntity
#
# This module defines several commands to retrieve data about a Model and MEntities.
module commands_model

import commands_base
import modelize

# Retrieve the MDoc related to a MEntity
class CmdComment
	super CmdEntity

	# Allow fallback
	#
	# If `true`, the command uses `mdoc_or_fallback`.
	# Default is `true`.
	var fallback = true is optional, writable

	# Retrieve the full documentation
	#
	# If `true`, retrieves the full documentation.
	# If `false`, retrieves only the synopsis.
	# Default is `true`.
	#
	# Since the rendering the final string (md, html...) depends on the kind of
	# client, the handling of this option is delegated to submodules.
	var full_doc = true is optional, writable

	# Format to render the comment
	#
	# Can be one of `raw`, `html` or `md`.
	# Default is `raw`.
	var format = "raw" is optional, writable

	# MDoc to return
	var mdoc: nullable MDoc = null is optional, writable

	# 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

	# Render `mdoc` depending on `full_doc` and `format`
	fun render_comment: nullable Writable do
		var mdoc = self.mdoc
		if mdoc == null then return null

		if full_doc then return mdoc.documentation
		return mdoc.synopsis
	end
end

# No MDoc for `mentity`
class WarningNoMDoc
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

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

# Get the link to a MEntity API documentation
class CmdEntityLink
	super CmdEntity

	# The link text to display
	var text: nullable String = null is optional, writable

	# The link title to display when the link is hovered
	var title: nullable String = null is optional, writable

	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
end

# An abstract inheritance command
#
# For things like ancestors, parents, children and descendants.
abstract class CmdInheritance
	super CmdEntityList

	autoinit(model, mainmodule, filter, mentity, mentity_name, limit, page, count, max)

	# Mainmodule for class linearization
	var mainmodule: MModule
end

# MEntity ancestors command
#
# Retrieve all the ancestors (direct and indirect) of a MEntity.
class CmdAncestors
	super CmdInheritance

	# Include direct parents in the ancestors list
	#
	# Default is `true`.
	var parents = true is optional, writable

	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 ancestors = mentity.collect_ancestors(mainmodule, filter).to_a
		if parents then
			results = ancestors
			return res
		end

		var parents = mentity.collect_parents(mainmodule, filter)
		var mentities = new HashSet[MEntity]
		for ancestor in ancestors do
			if not parents.has(ancestor) then mentities.add ancestor
		end
		results = mentities.to_a
		return res
	end
end

# MEntity parents command
class CmdParents
	super CmdInheritance

	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)

		results = mentity.collect_parents(mainmodule, filter).to_a
		return res
	end
end

# MEntity children command
class CmdChildren
	super CmdInheritance

	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)

		results = mentity.collect_children(mainmodule, filter).to_a
		return res
	end
end

# MEntity descendants command
class CmdDescendants
	super CmdInheritance

	# Include direct children in the descendants list
	#
	# Default is `true`.
	var children = true is optional, writable

	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 descendants = mentity.collect_descendants(mainmodule, filter).to_a
		if children then
			results = descendants
			return res
		end

		var children = mentity.collect_children(mainmodule, filter)
		var mentities = new HashSet[MEntity]
		for descendant in descendants do
			if not children.has(descendant) then mentities.add descendant
		end
		results = mentities.to_a
		return res
	end
end

# Linearization command
#
# Collects and linearizes definitions about an MEntity.
class CmdLinearization
	super CmdInheritance

	# Same states than `CmdEntity::init_mentity`
	#
	# Plus returns `WarningNoLinearization` if no linearization can be computed
	# from the mentity.
	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)

		sorter = null
		results = mentity.collect_linearization(mainmodule)
		if results == null then return new WarningNoLinearization(mentity)
		return res
	end
end

# No linearization computed for `mentity`.
class WarningNoLinearization
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

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

# A free text search command
class CmdSearch
	super CmdEntities

	# Free text command string
	var query: nullable String = null is optional, writable

	# Return states:
	# * `CmdSuccess`: everything was ok;
	# * `ErrorNoQuery`: no `query` provided.
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res

		var query = self.query
		if query == null then return new ErrorNoQuery
		sorter = null
		results = model.find(query)
		return res
	end
end

# No query string given
class ErrorNoQuery
	super CmdError

	redef fun to_s do return "Missing search string"
end

# MEntity feature list
#
# Mostly a list of mentities defined in `mentity`.
class CmdFeatures
	super CmdEntityList

	# Same as `CmdEntity::init_mentity`
	#
	# Plus `WarningNoFeatures` if no features are found for `mentity`.
	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
			mentities.add_all mentity.collect_mgroups(filter)
			mentities.add_all mentity.collect_mmodules(filter)
		else if mentity isa MGroup then
			mentities.add_all mentity.collect_mgroups(filter)
			mentities.add_all mentity.collect_mmodules(filter)
		else if mentity isa MModule then
			mentities.add_all mentity.collect_local_mclassdefs(filter)
		else if mentity isa MClass then
			mentities.add_all mentity.collect_intro_mproperties(filter)
			mentities.add_all mentity.collect_redef_mpropdefs(filter)
		else if mentity isa MClassDef then
			mentities.add_all mentity.collect_intro_mpropdefs(filter)
			mentities.add_all mentity.collect_redef_mpropdefs(filter)
		else if mentity isa MProperty then
			mentities.add_all mentity.collect_mpropdefs(filter)
		else
			return new WarningNoFeatures(mentity)
		end
		self.results = mentities
		return res
	end
end

# TODO remove once the filters/sorters are merged
class CmdIntros
	super CmdInheritance

	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)

		if mentity isa MModule then
			var mentities = mentity.collect_intro_mclasses(filter).to_a
			self.results = mentities
		else if mentity isa MClass then
			var mentities = mentity.collect_intro_mproperties(filter).to_a
			self.results = mentities
		else if mentity isa MClassDef then
			var mentities = mentity.collect_intro_mpropdefs(filter).to_a
			mainmodule.linearize_mpropdefs(mentities)
			self.results = mentities
		else
			return new WarningNoFeatures(mentity)
		end
		return res
	end
end

# TODO remove once the filters/sorters are merged
class CmdRedefs
	super CmdInheritance

	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)

		if mentity isa MModule then
			var mentities = mentity.collect_redef_mclassdefs(filter).to_a
			self.results = mentities
		else if mentity isa MClass then
			var mentities = mentity.collect_redef_mpropdefs(filter).to_a
			self.results = mentities
		else if mentity isa MClassDef then
			var mentities = mentity.collect_redef_mpropdefs(filter).to_a
			mainmodule.linearize_mpropdefs(mentities)
			self.results = mentities
		else
			return new WarningNoFeatures(mentity)
		end
		return res
	end
end

# TODO remove once the filters/sorters are merged
class CmdAllProps
	super CmdInheritance

	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)

		if mentity isa MClass then
			results = mentity.collect_accessible_mproperties(mainmodule, filter).to_a
		else
			return new WarningNoFeatures(mentity)
		end
		return res
	end
end

# No feature list for `mentity`
class WarningNoFeatures
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

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

# Abstract command that returns source-code pieces
abstract class CmdCode
	super DocCommand

	autoinit(model, filter, node, format)

	# AST node to display code from
	var node: nullable ANode = null is optional, writable

	# Rendering format
	#
	# Set the output format for this piece of code.
	# Can be "raw", "html" or "ansi".
	# Default is "raw".
	#
	# This format can be different than the format used in the command response.
	# For example you can choose to render code as HTML inside a JSON object response.
	# Another example is to render raw format to put into a HTML code tag.
	var format = "raw" is optional, writable

	# Render `node` depending on the selected `format`
	fun render_code(node: ANode): Writable do
		return node.location.text
	end
end

# Cmd that finds the source code related to an `mentity`
class CmdEntityCode
	super CmdEntity
	super CmdCode

	autoinit(model, modelbuilder, filter, mentity, mentity_name, format)

	# ModelBuilder used to get AST nodes from entities
	var modelbuilder: ModelBuilder

	# 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
end

# No code for `mentity`
class WarningNoCode
	super CmdWarning

	# MEntity provided
	var mentity: MEntity

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

# Model commands

# A command that returns a list of all mentities in a model
class CmdModelEntities
	super CmdEntities

	# Kind of mentities to be returned.
	#
	# Value must be one of "packages", "groups", "modules", "classes", "classdefs",
	# "properties", "propdefs" or "all".
	#
	# Default is "all".
	var kind = "all" is optional, writable

	# Default limit is `10`
	redef var limit = 10

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

		var res = super
		if not res isa CmdSuccess then return res

		var mentities = new Array[MEntity]
		if kind == "packages" then
			mentities = model.collect_mpackages(filter).to_a
		else if kind == "groups" then
			mentities = model.collect_mgroups(filter).to_a
		else if kind == "modules" then
			mentities = model.collect_mmodules(filter).to_a
		else if kind == "classes" then
			mentities = model.collect_mclasses(filter).to_a
		else if kind == "classdefs" then
			mentities = model.collect_mclassdefs(filter).to_a
		else if kind == "properties" then
			mentities = model.collect_mproperties(filter).to_a
		else if kind == "propdefs" then
			mentities = model.collect_mpropdefs(filter).to_a
		else
			mentities = model.collect_mentities(filter).to_a
		end
		results = mentities
		return res
	end
end

# A command that returns a random list of mentities from a model
class CmdRandomEntities
	super CmdModelEntities

	# Always return `CmdSuccess`
	redef fun init_results do
		if results != null then return new CmdSuccess
		var res = super
		if not res isa CmdSuccess then return res
		randomize
		return res
	end

	# Randomize mentities order
	fun randomize do
		var results = self.results
		if results == null then return
		results.shuffle
	end
end
src/doc/commands/commands_model.nit:15,1--546,3