nitc :: DocCommand
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.
nitc :: DocCommand :: cmd_filter
Return a new filter for that command execution.nitc :: DocCommand :: defaultinit
nitc :: DocCommand :: execute
nitc :: DocCommand :: filter=
ModelFilter to apply if anynitc :: DocCommand :: http_init
Init the command from an HTTPRequestnitc :: DocCommand :: parser_init
Initialize the command from the CommandParser datanitc :: DocCommand :: to_json
Return a JSON Serializable representation ofself
results
nitc $ DocCommand :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: DocCommand :: cmd_filter
Return a new filter for that command execution.core :: Object :: defaultinit
nitc :: DocCommand :: defaultinit
nitc :: DocCommand :: execute
nitc :: DocCommand :: filter=
ModelFilter to apply if anynitc :: DocCommand :: http_init
Init the command from an HTTPRequestcore :: 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.
core :: 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 :: DocCommand :: parser_init
Initialize the command from the CommandParser datanitc :: DocCommand :: to_json
Return a JSON Serializable representation ofself
results
nitc :: CmdCatalogContributing
Retrieve the packages contributed by a personmentity
mentity
mentity
mentity
mentity
mentity
# 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
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
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
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
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
redef class DocCommand
fun execute(no_color: nullable Bool) is abstract
end
src/doc/term/term.nit:44,1--46,3
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