Documentation command

An abstract command that works on a Model.

Since they are used by a wide variety of clients, initialization of DocCommands works in two steps.

First, you pass the data you already have to the command at init:

var c1 = new CmdEntity(view, mentity_name = "Array")
var c2 = new CmdEntity(view, mentity = my_entity)

Then, you call init_command to initialize the missing field from the stub data:

var r1 = c1.init_command
assert c1.mentity != null
assert r1 isa CmdSuccess

var r2 = c2.init_command
assert c2.mentity_name != null
assert r2 isa CmdSuccess

See init_command for more details about the returned statuses.

Introduced properties

private var _filter: nullable ModelFilter

nitc :: DocCommand :: _filter

ModelFilter to apply if any
private var _model: Model

nitc :: DocCommand :: _model

Model to retrieve data for
fun cmd_filter: ModelFilter

nitc :: DocCommand :: cmd_filter

Return a new filter for that command execution.
init defaultinit(model: Model, filter: nullable ModelFilter)

nitc :: DocCommand :: defaultinit

abstract fun execute(no_color: nullable Bool)

nitc :: DocCommand :: execute

fun filter: nullable ModelFilter

nitc :: DocCommand :: filter

ModelFilter to apply if any
protected fun filter=(filter: nullable ModelFilter)

nitc :: DocCommand :: filter=

ModelFilter to apply if any
fun http_init(req: HttpRequest): CmdMessage

nitc :: DocCommand :: http_init

Init the command from an HTTPRequest
fun init_command: CmdMessage

nitc :: DocCommand :: init_command

Initialize the command
fun model: Model

nitc :: DocCommand :: model

Model to retrieve data for
protected fun model=(model: Model)

nitc :: DocCommand :: model=

Model to retrieve data for
fun parser_init(arg: String, options: CmdOptions): CmdMessage

nitc :: DocCommand :: parser_init

Initialize the command from the CommandParser data
fun to_html: Writable

nitc :: DocCommand :: to_html

Render results as a HTML string
abstract fun to_json: nullable Serializable

nitc :: DocCommand :: to_json

Return a JSON Serializable representation of self results
fun to_md: Writable

nitc :: DocCommand :: to_md

Render results as a Markdown string

Redefined properties

redef type SELF: DocCommand

nitc $ DocCommand :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _filter: nullable ModelFilter

nitc :: DocCommand :: _filter

ModelFilter to apply if any
private var _model: Model

nitc :: DocCommand :: _model

Model to retrieve data for
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun cmd_filter: ModelFilter

nitc :: DocCommand :: cmd_filter

Return a new filter for that command execution.
init defaultinit(model: Model, filter: nullable ModelFilter)

nitc :: DocCommand :: defaultinit

abstract fun execute(no_color: nullable Bool)

nitc :: DocCommand :: execute

fun filter: nullable ModelFilter

nitc :: DocCommand :: filter

ModelFilter to apply if any
protected fun filter=(filter: nullable ModelFilter)

nitc :: DocCommand :: filter=

ModelFilter to apply if any
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun http_init(req: HttpRequest): CmdMessage

nitc :: DocCommand :: http_init

Init the command from an HTTPRequest
init init

core :: Object :: init

fun init_command: CmdMessage

nitc :: DocCommand :: init_command

Initialize the command
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun model: Model

nitc :: DocCommand :: model

Model to retrieve data for
protected fun model=(model: Model)

nitc :: DocCommand :: model=

Model to retrieve data for
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun parser_init(arg: String, options: CmdOptions): CmdMessage

nitc :: DocCommand :: parser_init

Initialize the command from the CommandParser data
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun to_html: Writable

nitc :: DocCommand :: to_html

Render results as a HTML string
abstract fun to_json: nullable Serializable

nitc :: DocCommand :: to_json

Return a JSON Serializable representation of self results
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_md: Writable

nitc :: DocCommand :: to_md

Render results as a Markdown string
fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::DocCommand DocCommand core::Object Object nitc::DocCommand->core::Object nitc::CmdCatalog CmdCatalog nitc::CmdCatalog->nitc::DocCommand nitc::CmdCode CmdCode nitc::CmdCode->nitc::DocCommand nitc::CmdEntity CmdEntity nitc::CmdEntity->nitc::DocCommand nitc::CmdList CmdList nitc::CmdList->nitc::DocCommand nitc::CmdGraph CmdGraph nitc::CmdGraph->nitc::DocCommand nitc::CmdCatalogSearch CmdCatalogSearch nitc::CmdCatalogSearch->nitc::CmdCatalog nitc::CmdCatalogPackages CmdCatalogPackages nitc::CmdCatalogPackages->nitc::CmdCatalog nitc::CmdCatalogStats CmdCatalogStats nitc::CmdCatalogStats->nitc::CmdCatalog nitc::CmdCatalogTags CmdCatalogTags nitc::CmdCatalogTags->nitc::CmdCatalog nitc::CmdCatalogPerson CmdCatalogPerson nitc::CmdCatalogPerson->nitc::CmdCatalog nitc::CmdCatalogSearch... ... nitc::CmdCatalogSearch...->nitc::CmdCatalogSearch nitc::CmdCatalogPackages... ... nitc::CmdCatalogPackages...->nitc::CmdCatalogPackages nitc::CmdCatalogStats... ... nitc::CmdCatalogStats...->nitc::CmdCatalogStats nitc::CmdCatalogTags... ... nitc::CmdCatalogTags...->nitc::CmdCatalogTags nitc::CmdCatalogPerson... ... nitc::CmdCatalogPerson...->nitc::CmdCatalogPerson nitc::CmdEntityCode CmdEntityCode nitc::CmdEntityCode->nitc::CmdCode nitc::CmdEntityCode... ... nitc::CmdEntityCode...->nitc::CmdEntityCode nitc::CmdEntity... ... nitc::CmdEntity...->nitc::CmdEntity nitc::CmdEntities CmdEntities nitc::CmdEntities->nitc::CmdList nitc::CmdEntities... ... nitc::CmdEntities...->nitc::CmdEntities nitc::CmdUML CmdUML nitc::CmdUML->nitc::CmdGraph nitc::CmdInheritanceGraph CmdInheritanceGraph nitc::CmdInheritanceGraph->nitc::CmdGraph nitc::CmdUML... ... nitc::CmdUML...->nitc::CmdUML nitc::CmdInheritanceGraph... ... nitc::CmdInheritanceGraph...->nitc::CmdInheritanceGraph

Parents

interface Object

core :: Object

The root of the class hierarchy.

Children

abstract class CmdCatalog

nitc :: CmdCatalog

A DocCommand based on a Catalog
abstract class CmdCode

nitc :: CmdCode

Abstract command that returns source-code pieces
class CmdEntity

nitc :: CmdEntity

A command about a MEntity
abstract class CmdGraph

nitc :: CmdGraph

An abstract command that returns a dot graph
abstract class CmdList

nitc :: CmdList

A command that returns a list of results

Descendants

class CmdAllProps

nitc :: CmdAllProps

TODO remove once the filters/sorters are merged
class CmdAncestors

nitc :: CmdAncestors

MEntity ancestors command
class CmdCall

nitc :: CmdCall

Retrieve all the mproperties that call mentity
class CmdCatalogContributing

nitc :: CmdCatalogContributing

Retrieve the packages contributed by a person
class CmdCatalogMaintaining

nitc :: CmdCatalogMaintaining

Retrieve the packages maintained by a person
class CmdCatalogPackages

nitc :: CmdCatalogPackages

Retrieve the packages in the catalog
class CmdCatalogPerson

nitc :: CmdCatalogPerson

Retrieve a person from the catalog
class CmdCatalogSearch

nitc :: CmdCatalogSearch

A CmdSearch command using a Catalog
class CmdCatalogStats

nitc :: CmdCatalogStats

Retrieve the catalog stats
class CmdCatalogTag

nitc :: CmdCatalogTag

Retrieve the packages for a tag
class CmdCatalogTags

nitc :: CmdCatalogTags

Retrieve the catalog tags list
class CmdChildren

nitc :: CmdChildren

MEntity children command
class CmdComment

nitc :: CmdComment

Retrieve the MDoc related to a MEntity
class CmdContribFile

nitc :: CmdContribFile

Cmd that finds the contributing file related to an mentity
class CmdContribFileContent

nitc :: CmdContribFileContent

Cmd that finds the contrib file content related to an mentity
class CmdDescendants

nitc :: CmdDescendants

MEntity descendants command
abstract class CmdEntities

nitc :: CmdEntities

A list of mentities
class CmdEntityCode

nitc :: CmdEntityCode

Cmd that finds the source code related to an mentity
abstract class CmdEntityFile

nitc :: CmdEntityFile

abstract class CmdEntityList

nitc :: CmdEntityList

A command about a MEntity that returns a list of mentities
class CmdFeatures

nitc :: CmdFeatures

MEntity feature list
abstract class CmdInheritance

nitc :: CmdInheritance

An abstract inheritance command
class CmdInheritanceGraph

nitc :: CmdInheritanceGraph

Render a hierarchy graph for mentity if any.
abstract class CmdIni

nitc :: CmdIni

Cmd that finds the ini file related to an mentity
class CmdIniCloneCommand

nitc :: CmdIniCloneCommand

Cmd that finds the git clone command related to an mentity
class CmdIniContributors

nitc :: CmdIniContributors

Cmd that finds the contributors list of an mentity
class CmdIniDescription

nitc :: CmdIniDescription

Cmd that finds the ini description related to an mentity
class CmdIniGitUrl

nitc :: CmdIniGitUrl

Cmd that finds the clone url related to an mentity
class CmdIniIssuesUrl

nitc :: CmdIniIssuesUrl

Cmd that finds the issues link related to an mentity
class CmdIniLicense

nitc :: CmdIniLicense

Cmd that finds the license related to an mentity
class CmdIniMaintainer

nitc :: CmdIniMaintainer

Cmd that finds the maintainer name of an mentity
class CmdIntros

nitc :: CmdIntros

TODO remove once the filters/sorters are merged
class CmdLicenseFile

nitc :: CmdLicenseFile

Cmd that finds the license file related to an mentity
class CmdLicenseFileContent

nitc :: CmdLicenseFileContent

Cmd that finds the license file content related to an mentity
class CmdLinearization

nitc :: CmdLinearization

Linearization command
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 CmdMetadata

nitc :: CmdMetadata

Retrieve the catalog metadata for a MPackage
class CmdModelEntities

nitc :: CmdModelEntities

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

nitc :: CmdNew

Retrieve all the mproperties that initialize mentity
class CmdParam

nitc :: CmdParam

Retrieve all the mproperties using mentity as a type for its parameters
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 CmdReturn

nitc :: CmdReturn

Retrieve all the mproperties that return somethinf of the mentity type.
class CmdSearch

nitc :: CmdSearch

A free text search command
class CmdSummary

nitc :: CmdSummary

Retrieve the MDoc summary
class CmdTesting

nitc :: CmdTesting

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

nitc :: CmdUML

UML command

Class definitions

nitc $ DocCommand
# Documentation command
#
# An abstract command that works on a Model.
#
# Since they are used by a wide variety of clients, initialization of DocCommands
# works in two steps.
#
# First, you pass the data you already have to the command at init:
# ~~~nitish
# var c1 = new CmdEntity(view, mentity_name = "Array")
# var c2 = new CmdEntity(view, mentity = my_entity)
# ~~~
#
# Then, you call `init_command` to initialize the missing field from the stub data:
# ~~~nitish
# var r1 = c1.init_command
# assert c1.mentity != null
# assert r1 isa CmdSuccess
#
# var r2 = c2.init_command
# assert c2.mentity_name != null
# assert r2 isa CmdSuccess
# ~~~
#
# See `init_command` for more details about the returned statuses.
abstract class DocCommand

	# Model to retrieve data for
	var model: Model

	# ModelFilter to apply if any
	var filter: nullable ModelFilter

	# 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

	# Return a new filter for that command execution.
	fun cmd_filter: ModelFilter do
		var filter = self.filter
		if filter == null then return new ModelFilter
		return new ModelFilter.from(filter)
	end
end
src/doc/commands/commands_base.nit:28,1--79,3

nitc :: commands_parser $ DocCommand
redef class DocCommand

	# Initialize the command from the CommandParser data
	fun parser_init(arg: String, options: CmdOptions): CmdMessage do
		var filter = cmd_filter
		var opt_vis = options.opt_visibility("min-visibility")
		if opt_vis != null then filter.min_visibility = opt_vis
		var opt_fictive = options.opt_bool("no-fictive")
		if opt_fictive != null then filter.accept_fictive = not opt_fictive
		var opt_test = options.opt_bool("no-test")
		if opt_test != null then filter.accept_test = not opt_test
		var opt_redef = options.opt_bool("no-redef")
		if opt_redef != null then filter.accept_redef = not opt_redef
		var opt_extern = options.opt_bool("no-extern")
		if opt_extern != null then filter.accept_extern = not opt_extern
		var opt_example = options.opt_bool("no-example")
		if opt_example != null then filter.accept_example = not opt_example
		var opt_attr = options.opt_bool("no-attribute")
		if opt_attr != null then filter.accept_attribute = not opt_attr
		var opt_doc = options.opt_bool("no-empty-doc")
		if opt_doc != null then filter.accept_empty_doc = not opt_doc
		var opt_inh = options.opt_mentity(model, "inherit")
		if opt_inh != null then filter.accept_inherited = opt_inh
		var opt_match = options.opt_string("match")
		if opt_match != null then filter.accept_full_name = opt_match
		self.filter = filter
		return init_command
	end
end
src/doc/commands/commands_parser.nit:254,1--282,3

nitc :: commands_http $ DocCommand
redef class DocCommand
	# Init the command from an HTTPRequest
	fun http_init(req: HttpRequest): CmdMessage do
		var filter = cmd_filter
		var opt_vis = req.visibility_arg("min-visibility")
		if opt_vis != null then filter.min_visibility = opt_vis
		var opt_fictive = req.bool_arg("no-fictive")
		if opt_fictive != null then filter.accept_fictive = not opt_fictive
		var opt_test = req.bool_arg("no-test")
		if opt_test != null then filter.accept_test = not opt_test
		var opt_redef = req.bool_arg("no-redef")
		if opt_redef != null then filter.accept_redef = not opt_redef
		var opt_extern = req.bool_arg("no-extern")
		if opt_extern != null then filter.accept_extern = not opt_extern
		var opt_example = req.bool_arg("no-example")
		if opt_example != null then filter.accept_example = not opt_example
		var opt_attr = req.bool_arg("no-attribute")
		if opt_attr != null then filter.accept_attribute = not opt_attr
		var opt_doc = req.bool_arg("no-empty-doc")
		if opt_doc != null then filter.accept_empty_doc = not opt_doc
		var opt_inh = req.mentity_arg(model, "inherit")
		if opt_inh != null then filter.accept_inherited = opt_inh
		var opt_match = req.string_arg("match")
		if opt_match != null then filter.accept_full_name = opt_match
		self.filter = filter
		return init_command
	end
end
src/doc/commands/commands_http.nit:29,1--56,3

nitc :: md_commands $ DocCommand
redef class DocCommand

	# Render results as a Markdown string
	fun to_md: Writable do return "**Not yet implemented**"
end
src/doc/templates/md_commands.nit:26,1--30,3

nitc :: json_commands $ DocCommand
redef class DocCommand
	# Return a JSON Serializable representation of `self` results
	fun to_json: nullable Serializable is abstract
end
src/doc/templates/json_commands.nit:27,1--30,3

nitc :: term $ DocCommand
redef class DocCommand
	fun execute(no_color: nullable Bool) is abstract
end
src/doc/term/term.nit:44,1--46,3

nitc :: html_commands $ DocCommand
redef class DocCommand

	# Render results as a HTML string
	fun to_html: Writable do return "<p class='text-danger'>Not yet implemented</p>"
end
src/doc/templates/html_commands.nit:29,1--33,3