nitc :: CmdComment
nitc :: CmdComment :: defaultinit
nitc :: CmdComment :: full_doc=
Retrieve the full documentationnitc :: CmdComment :: render_comment
Rendermdoc
depending on full_doc
and format
nitc $ CmdComment :: SELF
Type of this instance, automatically specialized in every classnitc :: commands_http $ CmdComment :: http_init
Init the command from an HTTPRequestnitc $ CmdComment :: init_command
Same states thanCmdEntity::init_mentity
nitc :: commands_parser $ CmdComment :: parser_init
Initialize the command from the CommandParser datanitc :: md_commands $ CmdComment :: render_comment
Rendermdoc
depending on full_doc
and format
nitc :: html_commands $ CmdComment :: render_comment
Rendermdoc
depending on full_doc
and format
nitc :: html_commands $ CmdComment :: to_html
Render results as a HTML stringnitc :: json_commands $ CmdComment :: to_json
Return a JSON Serializable representation ofself
results
nitc :: md_commands $ CmdComment :: to_md
Render results as a Markdown stringnitc :: CmdEntity :: _mentity_name
Name of the mentity this command is aboutcore :: 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 :: CmdComment :: defaultinit
nitc :: DocCommand :: defaultinit
nitc :: CmdEntity :: defaultinit
nitc :: DocCommand :: execute
nitc :: DocCommand :: filter=
ModelFilter to apply if anynitc :: CmdComment :: full_doc=
Retrieve the full documentationnitc :: 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.
nitc :: CmdEntity :: mentity_name
Name of the mentity this command is aboutnitc :: CmdEntity :: mentity_name=
Name of the mentity this command is aboutcore :: 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 :: CmdComment :: render_comment
Rendermdoc
depending on full_doc
and format
nitc :: DocCommand :: to_json
Return a JSON Serializable representation ofself
results
# 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
src/doc/commands/commands_model.nit:23,1--75,3
redef class CmdComment
redef fun parser_init(mentity_name, options) do
var opt_full_doc = options.opt_bool("only-synopsis")
if opt_full_doc != null then full_doc = not opt_full_doc
var opt_fallback = options.opt_bool("no-fallback")
if opt_fallback != null then fallback = not opt_fallback
var opt_format = options.opt_string("format")
if opt_format != null then format = opt_format
return super
end
end
src/doc/commands/commands_parser.nit:303,1--313,3
redef class CmdComment
redef fun http_init(req) do
var opt_full_doc = req.bool_arg("full_doc")
if opt_full_doc != null then full_doc = opt_full_doc
var opt_fallback = req.bool_arg("fallback")
if opt_fallback != null then fallback = opt_fallback
var opt_format = req.string_arg("format")
if opt_format != null then format = opt_format
return super
end
end
src/doc/commands/commands_http.nit:109,1--119,3
redef class CmdComment
redef fun to_md do
var mentity = self.mentity
if mentity == null then return ""
var mdoc = self.mdoc
var tpl = new Template
tpl.add "### `{mentity}`"
if mdoc != null then
tpl.add " - "
tpl.add mdoc.synopsis
end
tpl.add "\n"
if mdoc != null then
tpl.add mdoc.comment
end
return tpl.write_to_string
end
redef fun render_comment do
var mdoc = self.mdoc
if mdoc == null then return null
if format == "md" then
if full_doc then return mdoc.md_documentation
return mdoc.md_synopsis
end
return super
end
end
src/doc/templates/md_commands.nit:75,1--104,3
redef class CmdComment
redef fun to_json do
var obj = new JsonObject
var render = self.render_comment
if render != null then
obj["documentation"] = render.write_to_string
end
return obj
end
end
src/doc/templates/json_commands.nit:66,1--75,3
redef class CmdComment
redef fun execute(no_color) do
var mentity = self.mentity
if mentity == null then return
var full_name = mentity.cs_full_name(no_color)
if no_color == null or not no_color then
print "Documentation for `{full_name}`:".bold
else
print "Documentation for `{full_name}`:"
end
print ""
print " {mentity.cs_icon(no_color)} {mentity.cs_full_name(no_color)}"
print " {mentity.cs_declaration(no_color)}"
print " {mentity.cs_location(no_color)}"
print ""
var mdoc = self.mdoc
if mdoc == null then return
if full_doc then
print mdoc.cs_comment(no_color, 3)
else
print " {mdoc.cs_short_comment(no_color)}\n"
end
end
end
src/doc/term/term.nit:129,1--153,3
redef class CmdComment
redef fun to_html do
var mentity = self.mentity
if mentity == null then return ""
var mdoc = self.mdoc
var tpl = new Template
tpl.add "<h3>"
# FIXME comments left here until I figure out what to do about the presentation options
# if not opts.has_key("no-link") then
tpl.add mentity.html_link
# end
if mdoc != null then
# if not opts.has_key("no-link") and not opts.has_key("no-synopsis") then
tpl.add " - "
# end
# if not opts.has_key("no-synopsis") then
tpl.add mdoc.html_synopsis
# end
end
tpl.add "</h3>"
if mdoc != null then
# if not opts.has_key("no-comment") then
tpl.add mdoc.html_comment
# end
end
return tpl.write_to_string
end
redef fun render_comment do
var mdoc = self.mdoc
if mdoc == null then return null
if format == "html" then
if full_doc then return mdoc.html_documentation
return mdoc.html_synopsis
end
return super
end
end
src/doc/templates/html_commands.nit:81,1--120,3