MEntity
objectnitc :: MDoc :: _html_comment
Renders the comment without the synopsis as a HTML comment block.nitc :: MDoc :: _html_documentation
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: _html_synopsis
Renders the synopsis as a HTML comment block.nitc :: MDoc :: _inline_proc
nitc :: MDoc :: _markdown_proc
nitc :: MDoc :: _md_comment
nitc :: MDoc :: _md_documentation
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: _md_synopsis
Renders the synopsis as a HTML comment block.nitc :: MDoc :: _original_mentity
The entity where the documentation is originally attached to.nitc :: MDoc :: cs_comment
Returns the full comment formatted for the consolenitc :: MDoc :: cs_short_comment
Returns the synopsis formatted for the consolenitc :: MDoc :: defaultinit
nitc :: MDoc :: fill_infobox
Append an entry for the doc in the given infoboxnitc :: MDoc :: html_comment
Renders the comment without the synopsis as a HTML comment block.nitc :: MDoc :: html_comment=
Renders the comment without the synopsis as a HTML comment block.nitc :: MDoc :: html_documentation
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: html_documentation=
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: html_synopsis
Renders the synopsis as a HTML comment block.nitc :: MDoc :: html_synopsis=
Renders the synopsis as a HTML comment block.nitc :: MDoc :: inline_proc
nitc :: MDoc :: inline_proc=
nitc :: MDoc :: lines_to_html
Renders markdown line as a HTML comment block.nitc :: MDoc :: lines_to_md
nitc :: MDoc :: markdown_proc
nitc :: MDoc :: markdown_proc=
nitc :: MDoc :: md_comment
nitc :: MDoc :: md_comment=
nitc :: MDoc :: md_documentation
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: md_documentation=
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: md_synopsis=
Renders the synopsis as a HTML comment block.nitc :: MDoc :: original_mentity
The entity where the documentation is originally attached to.nitc :: MDoc :: original_mentity=
The entity where the documentation is originally attached to.nitc :: json_model $ MDoc :: core_serialize_to
Actual serialization ofself
to serializer
nitc :: json_model $ MDoc :: from_deserializer
Create an instance of this class from thedeserializer
nitc :: MDoc :: _html_comment
Renders the comment without the synopsis as a HTML comment block.nitc :: MDoc :: _html_documentation
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: _html_synopsis
Renders the synopsis as a HTML comment block.nitc :: MDoc :: _inline_proc
nitc :: MDoc :: _markdown_proc
nitc :: MDoc :: _md_comment
nitc :: MDoc :: _md_documentation
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: _md_synopsis
Renders the synopsis as a HTML comment block.nitc :: MDoc :: _original_mentity
The entity where the documentation is originally attached to.serialization :: Serializable :: accept_inspect_serializer_core
serialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
nitc :: MDoc :: cs_comment
Returns the full comment formatted for the consolenitc :: MDoc :: cs_short_comment
Returns the synopsis formatted for the consolenitc :: MDoc :: defaultinit
core :: Object :: defaultinit
nitc :: MDoc :: fill_infobox
Append an entry for the doc in the given infoboxserialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
nitc :: MDoc :: html_comment
Renders the comment without the synopsis as a HTML comment block.nitc :: MDoc :: html_comment=
Renders the comment without the synopsis as a HTML comment block.nitc :: MDoc :: html_documentation
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: html_documentation=
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: html_synopsis
Renders the synopsis as a HTML comment block.nitc :: MDoc :: html_synopsis=
Renders the synopsis as a HTML comment block.nitc :: MDoc :: inline_proc
nitc :: MDoc :: inline_proc=
core :: 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 :: MDoc :: lines_to_html
Renders markdown line as a HTML comment block.nitc :: MDoc :: lines_to_md
nitc :: MDoc :: markdown_proc
nitc :: MDoc :: markdown_proc=
nitc :: MDoc :: md_comment
nitc :: MDoc :: md_comment=
nitc :: MDoc :: md_documentation
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: md_documentation=
Renders the synopsis and the comment as a HTML comment block.nitc :: MDoc :: md_synopsis=
Renders the synopsis as a HTML comment block.serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: native_class_name
The class name of the object in CString format.nitc :: MDoc :: original_mentity
The entity where the documentation is originally attached to.nitc :: MDoc :: original_mentity=
The entity where the documentation is originally attached to.core :: Object :: output_class_name
Display class name on stdout (debug only).serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
serialization :: Serializable :: serialize_to_or_delay
Accept references or force direct serialization (usingserialize_to
)
serialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
Serializer::serialize
# Structured documentation of a `MEntity` object
class MDoc
# Raw content, line by line
# The starting `#` and first space are stripped.
# The trailing `\n` are chomped.
var content = new Array[String]
# The entity where the documentation is originally attached to.
# This gives some context to resolve identifiers or to run examples.
var original_mentity: nullable MEntity = null is writable
# The original location of the doc for error messages
var location: Location
# The comment first line
var synopsis: String is lazy do return content.first
# All comment lines except for the synopsis
var comment: String is lazy do
var lines = content.to_a
if not lines.is_empty then lines.shift
return lines.join("\n")
end
# Full comment
var documentation: String is lazy do return content.join("\n")
end
src/model/mdoc.nit:21,1--47,3
redef class MDoc
# Returns the full comment formatted for the console
fun cs_comment(no_color: nullable Bool, indent: nullable Int): String do
var res = new FlatBuffer
indent = indent or else 0
for line in content do
res.append "{" " * indent}{line}\n"
end
if no_color == null or not no_color then
return res.write_to_string.green
end
return res.write_to_string
end
# Returns the synopsis formatted for the console
fun cs_short_comment(no_color: nullable Bool): String do
if no_color == null or not no_color then
return content.first.green
end
return content.first
end
end
src/doc/templates/term_model.nit:24,1--45,3
redef class MDoc
# Append an entry for the doc in the given infobox
fun fill_infobox(res: HInfoBox)
do
if content.length < 2 then
res.new_field("doc").text(content.first)
return
end
var c = res.new_dropdown("doc", content.first)
for x in content.iterator.skip_head(1) do
c.append x
c.add_raw_html "<br>"
end
end
end
src/htmlight.nit:424,1--438,3
redef class MDoc
# Renders the synopsis as a HTML comment block.
var md_synopsis: Writable is lazy do
if content.is_empty then return ""
return content.first
end
#
var md_comment: Writable is lazy do
if content.is_empty then return ""
var lines = content.to_a
lines.shift
return lines.join("\n")
end
# Renders the synopsis and the comment as a HTML comment block.
var md_documentation: Writable is lazy do return lines_to_md(content.to_a)
private fun lines_to_md(lines: Array[String]): Writable do
var res = new Template
if not lines.is_empty then
var syn = lines.first
if not syn.has_prefix(" ") and not syn.has_prefix("\t") and
not syn.trim.has_prefix("#") then
lines.shift
res.add "# {syn}\n"
end
end
res.add lines.join("\n")
return res
end
end
src/doc/templates/md_commands.nit:348,1--380,3
redef class MDoc
private var markdown_proc: MarkdownProcessor is lazy, writable do
return original_mentity.as(not null).model.nitdoc_md_processor
end
private var inline_proc: MarkdownProcessor is lazy, writable do
return original_mentity.as(not null).model.nitdoc_inline_processor
end
# Renders the synopsis as a HTML comment block.
var html_synopsis: Writable is lazy do
var res = new Template
var syn = inline_proc.process(content.first)
res.add "<span class=\"synopsis nitdoc\">{syn}</span>"
return res
end
# Renders the comment without the synopsis as a HTML comment block.
var html_comment: Writable is lazy do
var lines = content.to_a
if not lines.is_empty then lines.shift
return lines_to_html(lines)
end
# Renders the synopsis and the comment as a HTML comment block.
var html_documentation: Writable is lazy do return lines_to_html(content.to_a)
# Renders markdown line as a HTML comment block.
private fun lines_to_html(lines: Array[String]): Writable do
var res = new Template
var decorator = markdown_proc.decorator.as(NitdocDecorator)
decorator.current_mdoc = self
res.add "<div class=\"nitdoc\">"
# do not use DocUnit as synopsis
if not lines.is_empty then
if not lines.first.has_prefix(" ") and
not lines.first.has_prefix("\t") then
# parse synopsis
var syn = inline_proc.process(lines.shift)
res.add "<h1 class=\"synopsis\">{syn}</h1>"
end
end
# check for annotations
for i in [0 .. lines.length[ do
var line = lines[i]
if line.to_upper.has_prefix("ENSURE") or line.to_upper.has_prefix("REQUIRE") then
var html = inline_proc.process(line)
lines[i] = "<p class=\"contract\">{html}</p>"
else if line.to_upper.has_prefix("TODO") or line.to_upper.has_prefix("FIXME") then
var html = inline_proc.process(line)
lines[i] = "<p class=\"todo\">{html}</p>"
end
end
# add other lines
res.add markdown_proc.process(lines.join("\n"))
res.add "</div>"
decorator.current_mdoc = null
return res
end
end
src/doc/templates/html_model.nit:385,1--445,3
redef class MDoc
serialize
redef fun core_serialize_to(v) do
var doc = html_documentation.write_to_string.trim
if not doc.is_empty then
v.serialize_attribute("html_documentation", doc)
end
end
end
src/doc/templates/json_model.nit:69,1--78,3