diff --git a/lib/html/bootstrap.nit b/lib/html/bootstrap.nit
index cc3d6e2986..3e12dd79e6 100644
--- a/lib/html/bootstrap.nit
+++ b/lib/html/bootstrap.nit
@@ -72,7 +72,7 @@ class Link
redef fun rendering do
add "{text}"
end
end
diff --git a/src/catalog/catalog.nit b/src/catalog/catalog.nit
index 6a12238d53..140278e3a7 100644
--- a/src/catalog/catalog.nit
+++ b/src/catalog/catalog.nit
@@ -165,24 +165,6 @@ class Person
return email.md5.to_lower
end
- # Return a full-featured link to a person
- fun to_html: String
- do
- var res = ""
- var e = name.html_escape
- var page = self.page
- if page != null then
- res += ""
- end
- var gravatar = self.gravatar
- if gravatar != null then
- res += " "
- end
- res += e
- if page != null then res += ""
- return res
- end
-
# The standard representation of a person.
#
# ~~~
diff --git a/src/catalog/catalog_json.nit b/src/catalog/catalog_json.nit
deleted file mode 100644
index da1bcfcbe2..0000000000
--- a/src/catalog/catalog_json.nit
+++ /dev/null
@@ -1,85 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Translate catalog entities to JSON
-module catalog_json
-
-import catalog
-
-redef class MPackageMetadata
- serialize
-
- redef fun core_serialize_to(v) do
- super
- v.serialize_attribute("license", license)
- v.serialize_attribute("maintainers", maintainers)
- v.serialize_attribute("contributors", contributors)
- v.serialize_attribute("tags", tags)
- v.serialize_attribute("tryit", tryit)
- v.serialize_attribute("apk", apk)
- v.serialize_attribute("homepage", homepage)
- v.serialize_attribute("browse", browse)
- v.serialize_attribute("git", git)
- v.serialize_attribute("issues", issues)
- v.serialize_attribute("first_date", first_date)
- v.serialize_attribute("last_date", last_date)
- end
-end
-
-# Catalog statistics
-redef class CatalogStats
- serialize
-
- redef fun core_serialize_to(v) do
- super
- v.serialize_attribute("packages", packages)
- v.serialize_attribute("maintainers", maintainers)
- v.serialize_attribute("contributors", contributors)
- v.serialize_attribute("tags", tags)
- v.serialize_attribute("modules", modules)
- v.serialize_attribute("classes", classes)
- v.serialize_attribute("methods", methods)
- v.serialize_attribute("loc", loc)
- end
-end
-
-# MPackage statistics for the catalog
-redef class MPackageStats
- serialize
-
- redef fun core_serialize_to(v) do
- super
- v.serialize_attribute("mmodules", mmodules)
- v.serialize_attribute("mclasses", mclasses)
- v.serialize_attribute("mmethods", mmethods)
- v.serialize_attribute("loc", loc)
- v.serialize_attribute("errors", errors)
- v.serialize_attribute("warnings", warnings)
- v.serialize_attribute("warnings_per_kloc", warnings_per_kloc)
- v.serialize_attribute("documentation_score", documentation_score)
- v.serialize_attribute("commits", commits)
- v.serialize_attribute("score", score)
- end
-end
-
-redef class Person
- serialize
-
- redef fun core_serialize_to(v) do
- super
- v.serialize_attribute("name", name)
- v.serialize_attribute("email", email)
- v.serialize_attribute("gravatar", gravatar)
- end
-end
diff --git a/src/doc/api/api_base.nit b/src/doc/api/api_base.nit
index 4c3db90912..95a6ff071d 100644
--- a/src/doc/api/api_base.nit
+++ b/src/doc/api/api_base.nit
@@ -21,8 +21,9 @@ import popcorn::pop_repos
import popcorn::pop_json
import commands::commands_http
-import commands::commands_json
-import commands::commands_html
+
+import templates::json_commands
+import templates::html_commands
# Nitweb config file.
class NitwebConfig
diff --git a/src/doc/commands/commands_base.nit b/src/doc/commands/commands_base.nit
index 822b509d49..bde3f8e12c 100644
--- a/src/doc/commands/commands_base.nit
+++ b/src/doc/commands/commands_base.nit
@@ -24,7 +24,6 @@
module commands_base
import model::model_index
-import catalog
# Documentation command
#
diff --git a/src/doc/commands/commands_catalog.nit b/src/doc/commands/commands_catalog.nit
index 90f631a7b8..f7bce8e3ea 100644
--- a/src/doc/commands/commands_catalog.nit
+++ b/src/doc/commands/commands_catalog.nit
@@ -16,6 +16,7 @@
module commands_catalog
import commands_model
+import catalog
# A DocCommand based on a Catalog
abstract class CmdCatalog
diff --git a/src/doc/commands/commands_docdown.nit b/src/doc/commands/commands_docdown.nit
index fe7345e8e4..ece9daec3e 100644
--- a/src/doc/commands/commands_docdown.nit
+++ b/src/doc/commands/commands_docdown.nit
@@ -15,11 +15,8 @@
# Doc down related queries
module commands_docdown
-import commands::commands_parser
-import commands::commands_html
-
-intrude import doc_down
-intrude import markdown::wikilinks
+import templates::md_commands
+import markdown
# Retrieve the MDoc summary
#
@@ -28,7 +25,7 @@ class CmdSummary
super CmdComment
# Markdown processor used to parse the headlines
- var markdown_processor: nullable MarkdownProcessor = null is optional, writable
+ var markdown_processor: MarkdownProcessor is writable
# Resulting summary
#
@@ -40,12 +37,6 @@ class CmdSummary
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
- var markdown_processor = self.markdown_processor
- if markdown_processor == null then
- markdown_processor = new MarkdownProcessor
- self.markdown_processor = markdown_processor
- end
-
var mdoc = self.mdoc
if mdoc == null then
mdoc = if fallback then mentity.mdoc_or_fallback else mentity.mdoc
@@ -61,103 +52,3 @@ class CmdSummary
return res
end
end
-
-# Custom Markdown processor able to process doc commands
-class CmdDecorator
- super NitdocDecorator
-
- redef type PROCESSOR: CmdMarkdownProcessor
-
- # Model used by wikilink commands to find entities
- var model: Model
-
- # Filter to apply if any
- var filter: nullable ModelFilter
-
- redef fun add_span_code(v, buffer, from, to) do
- var text = new FlatBuffer
- buffer.read(text, from, to)
- var name = text.write_to_string
- name = name.replace("nullable ", "")
- var mentity = try_find_mentity(name)
- if mentity == null then
- super
- else
- v.add ""
- v.emit_text mentity.html_link.write_to_string
- v.add "
"
- end
- end
-
- private fun try_find_mentity(text: String): nullable MEntity do
- var mentity = model.mentity_by_full_name(text, filter)
- if mentity != null then return mentity
-
- var mentities = model.mentities_by_name(text, filter)
- if mentities.is_empty then
- return null
- else if mentities.length > 1 then
- # TODO smart resolve conflicts
- end
- return mentities.first
- end
-
- redef fun add_wikilink(v, token) do
- v.render_wikilink(token, model)
- end
-end
-
-# Same as `InlineDecorator` but with wikilink commands handling
-class CmdInlineDecorator
- super InlineDecorator
-
- redef type PROCESSOR: CmdMarkdownProcessor
-
- # Model used by wikilink commands to find entities
- var model: Model
-
- redef fun add_wikilink(v, token) do
- v.render_wikilink(token, model)
- end
-end
-
-# Custom MarkdownEmitter for commands
-class CmdMarkdownProcessor
- super MarkdownProcessor
-
- # Parser used to process doc commands
- var parser: CommandParser
-
- # Render a wikilink
- fun render_wikilink(token: TokenWikiLink, model: Model) do
- var link = token.link
- if link == null then return
- var name = token.name
- if name != null then link = "{name} | {link}"
-
- var command = parser.parse(link.write_to_string)
- var error = parser.error
-
- if error isa CmdError then
- emit_text error.to_html.write_to_string
- return
- end
- if error isa CmdWarning then
- emit_text error.to_html.write_to_string
- end
- add command.as(not null).to_html
- end
-end
-
-redef class Text
- # Read `self` between `nstart` and `nend` (excluded) and writte chars to `out`.
- private fun read(out: FlatBuffer, nstart, nend: Int): Int do
- var pos = nstart
- while pos < length and pos < nend do
- out.add self[pos]
- pos += 1
- end
- if pos == length then return -1
- return pos
- end
-end
diff --git a/src/doc/commands/commands_http.nit b/src/doc/commands/commands_http.nit
index cc26f7faf0..c018ad2fb1 100644
--- a/src/doc/commands/commands_http.nit
+++ b/src/doc/commands/commands_http.nit
@@ -18,8 +18,12 @@
# To be more generic, param names should be extracted as variables.
module commands_http
-import commands
-import commands::commands_catalog
+import commands_catalog
+import commands_graph
+import commands_ini
+import commands_main
+import commands_usage
+
import nitcorn::vararg_routes
redef class DocCommand
diff --git a/src/doc/commands/commands_ini.nit b/src/doc/commands/commands_ini.nit
index 9274fd09b0..df312c4ef8 100644
--- a/src/doc/commands/commands_ini.nit
+++ b/src/doc/commands/commands_ini.nit
@@ -14,7 +14,7 @@
module commands_ini
-import doc::commands::commands_model
+import commands_model
# Cmd that finds the ini file related to an `mentity`
abstract class CmdIni
diff --git a/src/doc/commands/commands_main.nit b/src/doc/commands/commands_main.nit
index 9533722516..2b3e861cd9 100644
--- a/src/doc/commands/commands_main.nit
+++ b/src/doc/commands/commands_main.nit
@@ -14,7 +14,7 @@
module commands_main
-import doc::commands::commands_model
+import commands_model
# Cmd that finds the mains of an `mentity`
class CmdMains
diff --git a/src/doc/commands/commands_model.nit b/src/doc/commands/commands_model.nit
index abf5d7d04f..3a7215b36a 100644
--- a/src/doc/commands/commands_model.nit
+++ b/src/doc/commands/commands_model.nit
@@ -18,12 +18,7 @@
module commands_model
import commands_base
-
-import model::model_collect
import modelize
-import modelbuilder
-import htmlight
-import doc_down
# Retrieve the MDoc related to a MEntity
class CmdComment
@@ -47,7 +42,7 @@ class CmdComment
# Format to render the comment
#
- # Can be one of `raw` or `html`.
+ # Can be one of `raw`, `html` or `md`.
# Default is `raw`.
var format = "raw" is optional, writable
@@ -74,10 +69,6 @@ class CmdComment
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
if full_doc then return mdoc.documentation
return mdoc.synopsis
end
@@ -427,10 +418,10 @@ end
abstract class CmdCode
super DocCommand
- autoinit(model, modelbuilder, filter, format)
+ autoinit(model, filter, node, format)
- # ModelBuilder used to get AST nodes
- var modelbuilder: ModelBuilder
+ # AST node to display code from
+ var node: nullable ANode = null is optional, writable
# Rendering format
#
@@ -444,30 +435,11 @@ abstract class CmdCode
var format = "raw" is optional, writable
# Render `node` depending on the selected `format`
- fun render_code(node: nullable ANode): nullable Writable do
- if node == null then return null
- if format == "html" then
- var hl = new CmdHtmlightVisitor
- hl.show_infobox = false
- hl.highlight_node node
- return hl.html
- else if format == "ansi" then
- var hl = new AnsiHighlightVisitor
- hl.highlight_node node
- return hl.result
- end
+ fun render_code(node: ANode): Writable do
return node.location.text
end
end
-# Custom HtmlightVisitor for commands
-#
-# We create a new subclass so its behavior can be refined in clients without
-# breaking the main implementation.
-class CmdHtmlightVisitor
- super HtmlightVisitor
-end
-
# Cmd that finds the source code related to an `mentity`
class CmdEntityCode
super CmdEntity
@@ -475,8 +447,8 @@ class CmdEntityCode
autoinit(model, modelbuilder, filter, mentity, mentity_name, format)
- # AST node to return
- var node: nullable ANode = null is optional, writable
+ # ModelBuilder used to get AST nodes from entities
+ var modelbuilder: ModelBuilder
# Same as `CmdEntity::init_mentity`
#
diff --git a/src/doc/commands/commands_parser.nit b/src/doc/commands/commands_parser.nit
index c3e51184be..52ec92b08f 100644
--- a/src/doc/commands/commands_parser.nit
+++ b/src/doc/commands/commands_parser.nit
@@ -17,12 +17,11 @@
# Used by both Nitx and the Markdown doc commands.
module commands_parser
-import commands::commands_model
-import commands::commands_graph
-import commands::commands_usage
-import commands::commands_catalog
-import commands::commands_ini
-import commands::commands_main
+import commands_catalog
+import commands_graph
+import commands_ini
+import commands_main
+import commands_usage
# Parse string commands to create DocQueries
class CommandParser
diff --git a/src/doc/doc_down.nit b/src/doc/doc_down.nit
deleted file mode 100644
index f02b1fdf3c..0000000000
--- a/src/doc/doc_down.nit
+++ /dev/null
@@ -1,251 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Handle markdown formatting in Nit comments.
-module doc_down
-
-import markdown
-import htmlight
-private import parser_util
-
-redef class MDoc
-
- # Synopsis HTML escaped.
- var synopsis: String is lazy do return content.first.html_escape
-
- # Comment without synopsis HTML escaped
- 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 HTML escaped.
- var documentation: String is lazy do return content.join("\n")
-
- 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 "{syn}"
- return res
- end
-
- # 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
-
- # 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
-
- #
- 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 html_documentation: Writable is lazy do return lines_to_html(content.to_a)
-
- # 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)
-
- # 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 "
{html}
" - else if line.to_upper.has_prefix("TODO") or line.to_upper.has_prefix("FIXME") then - var html = inline_proc.process(line) - lines[i] = "{html}
" - end - end - # add other lines - res.add markdown_proc.process(lines.join("\n")) - res.add ""
- v.emit_in block
- v.add "
\n"
- return
- end
- # Try to parse code
- var code = block.raw_content
- var ast = toolcontext.parse_something(code)
- if ast isa AError then
- v.add ""
- v.emit_in block
- v.add "
\n"
- return
- end
- v.add ""
- var hl = new HtmlightVisitor
- hl.line_id_prefix = ""
- hl.highlight_node(ast)
- v.add(hl.html)
- v.add "
\n"
- end
-
- redef fun add_span_code(v, text, from, to) do
- # Try to parse it
- var code = code_from_text(text, from, to)
- var ast = toolcontext.parse_something(code)
-
- if ast isa AError then
- v.add ""
- append_code(v, text, from, to)
- else
- v.add ""
- var hl = new HtmlightVisitor
- hl.line_id_prefix = ""
- hl.highlight_node(ast)
- v.add(hl.html)
- end
- v.add "
"
- end
-
- private fun code_from_text(buffer: Text, from, to: Int): String do
- var out = new FlatBuffer
- for i in [from..to[ do out.add buffer[i]
- return out.write_to_string
- end
-end
-
-# Decorator for span elements.
-#
-# Because inline comments can appear as span elements,
-# InlineDecorator do not decorate things like paragraphs or headers.
-private class InlineDecorator
- super NitdocDecorator
-
- redef fun add_paragraph(v, block) do
- v.emit_in block
- end
-
- redef fun add_headline(v, block) do
- # save headline
- var line = block.block.first_line
- if line == null then return
- var txt = line.value
- var id = strip_id(txt)
- var lvl = block.depth
- headlines[id] = new HeadLine(id, txt, lvl)
-
- v.emit_in block
- end
-
- redef fun add_code(v, block) do
- # Try to parse code
- var ast = toolcontext.parse_something(block.block.text.to_s)
- if ast isa AError then
- v.add ""
- v.emit_in block
- v.add "
"
- return
- end
- v.add ""
- var hl = new HtmlightVisitor
- hl.highlight_node(ast)
- v.add(hl.html)
- v.add "
"
- end
-end
-
-redef class Model
- # Get a markdown processor for Nitdoc comments.
- var nitdoc_md_processor: MarkdownProcessor is lazy, writable do
- var proc = new MarkdownProcessor
- proc.decorator = new NitdocDecorator
- return proc
- end
-
- # Get a markdown inline processor for Nitdoc comments.
- #
- # This processor is specificaly designed to inlinable doc elements like synopsys.
- var nitdoc_inline_processor: MarkdownProcessor is lazy, writable do
- var proc = new MarkdownProcessor
- proc.decorator = new InlineDecorator
- return proc
- end
-end
diff --git a/src/doc/static/static_base.nit b/src/doc/static/static_base.nit
index a7ae6bbe49..16f09aaac9 100644
--- a/src/doc/static/static_base.nit
+++ b/src/doc/static/static_base.nit
@@ -18,8 +18,6 @@ module static_base
import static_cards
import modelize
-intrude import markdown::wikilinks
-
# The model of a Nitdoc documentation
class DocModel
diff --git a/src/doc/static/static_cards.nit b/src/doc/static/static_cards.nit
index e589ca6ef8..c02f56586f 100644
--- a/src/doc/static/static_cards.nit
+++ b/src/doc/static/static_cards.nit
@@ -15,10 +15,7 @@
# Cards templates for the static documentation
module static_cards
-import doc::commands::commands_graph
-import doc::commands::commands_catalog
-import doc::commands::commands_docdown
-import templates_html
+import templates::html_commands
# A card that can be rendered to HTML
#
@@ -282,10 +279,21 @@ class CardInheritance
addn "{title}
"
addn ""
for mentity in mentities do
- addn mentity.html_list_item
+ addn html_list_item(mentity)
end
addn "
"
end
+
+ private fun html_list_item(mentity: MEntity): ListItem do
+ var tpl = new Template
+ tpl.add mentity.html_namespace
+ var comment = mentity.mdoc_or_fallback
+ if comment != null then
+ tpl.add ": "
+ tpl.add comment.html_synopsis
+ end
+ return new ListItem(tpl)
+ end
end
# A card about the linearization of a MEntity
diff --git a/src/doc/commands/commands_html.nit b/src/doc/templates/html_commands.nit
similarity index 65%
rename from src/doc/commands/commands_html.nit
rename to src/doc/templates/html_commands.nit
index 7aac39ab2d..39e088c35a 100644
--- a/src/doc/commands/commands_html.nit
+++ b/src/doc/templates/html_commands.nit
@@ -13,16 +13,18 @@
# limitations under the License.
# Render commands results as HTML
-module commands_html
+module html_commands
-import commands::commands_graph
-import commands::commands_usage
-import commands::commands_ini
-import commands::commands_main
+import commands_catalog
+import commands_docdown
+import commands_graph
+import commands_ini
+import commands_main
+import commands_parser
+import commands_usage
-import templates::templates_html
-import doc_down
-import highlight
+import templates::html_model
+intrude import markdown::wikilinks
redef class DocCommand
@@ -104,6 +106,17 @@ redef class CmdComment
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
redef class CmdEntityLink
@@ -114,11 +127,37 @@ redef class CmdEntityLink
end
end
-redef class CmdEntityCode
+redef class CmdCode
redef fun to_html do
- var output = render_code(node)
- if output == null then return ""
- return "{output.write_to_string}
"
+ var node = self.node
+ if node == null then return ""
+
+ var code = render_code(node)
+ return "{code.write_to_string}
"
+ end
+
+ redef fun render_code(node) do
+ if format == "html" then
+ var hl = new CmdHtmlightVisitor
+ hl.show_infobox = false
+ hl.highlight_node node
+ return hl.html
+ end
+ return super
+ end
+end
+
+# Custom HtmlightVisitor for commands
+#
+# We create a new subclass so its behavior can be refined in clients without
+# breaking the main implementation.
+class CmdHtmlightVisitor
+ super HtmlightVisitor
+
+ redef fun hrefto(mentity) do
+ if mentity isa MClassDef then return mentity.mclass.html_url
+ if mentity isa MPropDef then return mentity.mproperty.html_url
+ return mentity.html_url
end
end
@@ -246,12 +285,6 @@ redef class CmdIniLicense
end
redef class CmdEntityFile
-
- # URL to the file
- #
- # Can be refined in subtools.
- var file_url: nullable String = file is lazy, writable
-
redef fun to_html do
var file = self.file
if file == null then return ""
@@ -323,12 +356,104 @@ redef class CmdTesting
end
end
-# Misc
+# MDoc
-redef class CmdHtmlightVisitor
- redef fun hrefto(mentity) do
- if mentity isa MClassDef then return mentity.mclass.html_url
- if mentity isa MPropDef then return mentity.mproperty.html_url
- return mentity.html_url
+# Custom Markdown processor able to process doc commands
+class CmdDecorator
+ super NitdocDecorator
+
+ redef type PROCESSOR: CmdMarkdownProcessor
+
+ # Model used by wikilink commands to find entities
+ var model: Model
+
+ # Filter to apply if any
+ var filter: nullable ModelFilter
+
+ redef fun add_span_code(v, buffer, from, to) do
+ var text = new FlatBuffer
+ buffer.read(text, from, to)
+ var name = text.write_to_string
+ name = name.replace("nullable ", "")
+ var mentity = try_find_mentity(name)
+ if mentity == null then
+ super
+ else
+ v.add ""
+ v.emit_text mentity.html_link.write_to_string
+ v.add "
"
+ end
+ end
+
+ private fun try_find_mentity(text: String): nullable MEntity do
+ var mentity = model.mentity_by_full_name(text, filter)
+ if mentity != null then return mentity
+
+ var mentities = model.mentities_by_name(text, filter)
+ if mentities.is_empty then
+ return null
+ else if mentities.length > 1 then
+ # TODO smart resolve conflicts
+ end
+ return mentities.first
+ end
+
+ redef fun add_wikilink(v, token) do
+ v.render_wikilink(token, model)
+ end
+end
+
+# Same as `InlineDecorator` but with wikilink commands handling
+class CmdInlineDecorator
+ super InlineDecorator
+
+ redef type PROCESSOR: CmdMarkdownProcessor
+
+ # Model used by wikilink commands to find entities
+ var model: Model
+
+ redef fun add_wikilink(v, token) do
+ v.render_wikilink(token, model)
+ end
+end
+
+# Custom MarkdownEmitter for commands
+class CmdMarkdownProcessor
+ super MarkdownProcessor
+
+ # Parser used to process doc commands
+ var parser: CommandParser
+
+ # Render a wikilink
+ fun render_wikilink(token: TokenWikiLink, model: Model) do
+ var link = token.link
+ if link == null then return
+ var name = token.name
+ if name != null then link = "{name} | {link}"
+
+ var command = parser.parse(link.write_to_string)
+ var error = parser.error
+
+ if error isa CmdError then
+ emit_text error.to_html.write_to_string
+ return
+ end
+ if error isa CmdWarning then
+ emit_text error.to_html.write_to_string
+ end
+ add command.as(not null).to_html
+ end
+end
+
+redef class Text
+ # Read `self` between `nstart` and `nend` (excluded) and writte chars to `out`.
+ private fun read(out: FlatBuffer, nstart, nend: Int): Int do
+ var pos = nstart
+ while pos < length and pos < nend do
+ out.add self[pos]
+ pos += 1
+ end
+ if pos == length then return -1
+ return pos
end
end
diff --git a/src/doc/templates/templates_html.nit b/src/doc/templates/html_model.nit
similarity index 64%
rename from src/doc/templates/templates_html.nit
rename to src/doc/templates/html_model.nit
index 4faf0a6570..6ec000ff84 100644
--- a/src/doc/templates/templates_html.nit
+++ b/src/doc/templates/html_model.nit
@@ -13,13 +13,16 @@
# limitations under the License.
# Translate mentities to html blocks.
-module templates_html
+module html_model
import model::model_collect
-import doc::doc_down
-import html::bootstrap
import catalog
+import markdown
+import htmlight
+import html::bootstrap
+private import parser_util
+
redef class MEntity
# The MEntity unique ID in the HTML output
@@ -47,7 +50,7 @@ redef class MEntity
end
var mdoc = self.mdoc_or_fallback
if title == null and mdoc != null then
- title = mdoc.synopsis.html_escape
+ title = mdoc.synopsis
end
return new Link(html_url, text, title)
end
@@ -86,18 +89,6 @@ redef class MEntity
# An icon representative of the mentity
fun html_icon: BSIcon do return new BSIcon("tag", ["text-muted"])
- # A li element that can go in a `HTMLList`
- fun html_list_item: ListItem do
- var tpl = new Template
- tpl.add html_namespace
- var comment = mdoc_or_fallback
- if comment != null then
- tpl.add ": "
- tpl.add comment.html_synopsis
- end
- return new ListItem(tpl)
- end
-
# CSS classes used to decorate `self`
#
# Mainly used for icons.
@@ -364,6 +355,8 @@ redef class MParameter
end
end
+# Catalog
+
redef class Person
# HTML uniq id
@@ -377,7 +370,8 @@ redef class Person
# Link to this person `html_url`
fun html_link: Link do return new Link(html_url, name)
- redef fun to_html do
+ # Render `self` as HTML
+ fun to_html: String do
var tpl = new Template
tpl.addn ""
var gravatar = self.gravatar
@@ -389,3 +383,192 @@ redef class Person
return tpl.write_to_string
end
end
+
+# MDoc
+
+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 "{syn}"
+ 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 ""
+ # do not use DocUnit as synopsys
+ if not lines.is_empty then
+ if not lines.first.has_prefix(" ") and
+ not lines.first.has_prefix("\t") then
+ # parse synopsys
+ var syn = inline_proc.process(lines.shift)
+ res.add "{syn}
"
+ 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] = "{html}
"
+ else if line.to_upper.has_prefix("TODO") or line.to_upper.has_prefix("FIXME") then
+ var html = inline_proc.process(line)
+ lines[i] = "{html}
"
+ end
+ end
+ # add other lines
+ res.add markdown_proc.process(lines.join("\n"))
+ res.add ""
+ decorator.current_mdoc = null
+ return res
+ end
+end
+
+# The specific markdown decorator used internally to process MDoc object.
+#
+# You should use the various methods of `MDoc` like `MDoc::html_documentation`
+#
+# The class is public so specific behavior can be plugged on it.
+class NitdocDecorator
+ super HTMLDecorator
+
+ private var toolcontext = new ToolContext
+
+ # The currently processed mdoc.
+ #
+ # Unfortunately, this seems to be the simpler way to get the currently processed `MDoc` object.
+ var current_mdoc: nullable MDoc = null
+
+ redef fun add_code(v, block) do
+ var meta = block.meta or else "nit"
+
+ # Do not try to highlight non-nit code.
+ if meta != "nit" and meta != "nitish" then
+ v.add ""
+ v.emit_in block
+ v.add "
\n"
+ return
+ end
+ # Try to parse code
+ var code = block.raw_content
+ var ast = toolcontext.parse_something(code)
+ if ast isa AError then
+ v.add ""
+ v.emit_in block
+ v.add "
\n"
+ return
+ end
+ v.add ""
+ var hl = new HtmlightVisitor
+ hl.line_id_prefix = ""
+ hl.highlight_node(ast)
+ v.add(hl.html)
+ v.add "
\n"
+ end
+
+ redef fun add_span_code(v, text, from, to) do
+ # Try to parse it
+ var code = code_from_text(text, from, to)
+ var ast = toolcontext.parse_something(code)
+
+ if ast isa AError then
+ v.add ""
+ append_code(v, text, from, to)
+ else
+ v.add ""
+ var hl = new HtmlightVisitor
+ hl.line_id_prefix = ""
+ hl.highlight_node(ast)
+ v.add(hl.html)
+ end
+ v.add "
"
+ end
+
+ private fun code_from_text(buffer: Text, from, to: Int): String do
+ var out = new FlatBuffer
+ for i in [from..to[ do out.add buffer[i]
+ return out.write_to_string
+ end
+end
+
+# Decorator for span elements.
+#
+# Because inline comments can appear as span elements,
+# InlineDecorator do not decorate things like paragraphs or headers.
+class InlineDecorator
+ super NitdocDecorator
+
+ redef fun add_paragraph(v, block) do
+ v.emit_in block
+ end
+
+ redef fun add_headline(v, block) do
+ # save headline
+ var line = block.block.first_line
+ if line == null then return
+ var txt = line.value
+ var id = strip_id(txt)
+ var lvl = block.depth
+ headlines[id] = new HeadLine(id, txt, lvl)
+
+ v.emit_in block
+ end
+
+ redef fun add_code(v, block) do
+ # Try to parse code
+ var ast = toolcontext.parse_something(block.block.text.to_s)
+ if ast isa AError then
+ v.add ""
+ v.emit_in block
+ v.add "
"
+ return
+ end
+ v.add ""
+ var hl = new HtmlightVisitor
+ hl.highlight_node(ast)
+ v.add(hl.html)
+ v.add "
"
+ end
+end
+
+redef class Model
+ # Get a markdown processor for Nitdoc comments.
+ var nitdoc_md_processor: MarkdownProcessor is lazy, writable do
+ var proc = new MarkdownProcessor
+ proc.decorator = new NitdocDecorator
+ return proc
+ end
+
+ # Get a markdown inline processor for Nitdoc comments.
+ #
+ # This processor is specificaly designed to inlinable doc elements like synopsys.
+ var nitdoc_inline_processor: MarkdownProcessor is lazy, writable do
+ var proc = new MarkdownProcessor
+ proc.decorator = new InlineDecorator
+ return proc
+ end
+end
diff --git a/src/doc/commands/commands_json.nit b/src/doc/templates/json_commands.nit
similarity index 91%
rename from src/doc/commands/commands_json.nit
rename to src/doc/templates/json_commands.nit
index b109c87b5c..aea7be3ad5 100644
--- a/src/doc/commands/commands_json.nit
+++ b/src/doc/templates/json_commands.nit
@@ -13,17 +13,16 @@
# limitations under the License.
# Translate command results to json
-module commands_json
+module json_commands
-import commands::commands_model
-import commands::commands_graph
-import commands::commands_usage
-import commands::commands_catalog
-import commands::commands_ini
-import commands::commands_main
+import commands_catalog
+import commands_graph
+import commands_ini
+import commands_main
+import commands_usage
-import templates::templates_json
-import catalog::catalog_json
+import templates::json_model
+import json::static
redef class DocCommand
# Return a JSON Serializable representation of `self` results
@@ -86,17 +85,15 @@ redef class CmdEntityLink
end
end
-redef class CmdEntityCode
+redef class CmdCode
redef fun to_json do
var obj = new JsonObject
var node = self.node
- if node != null then
- obj["location"] = node.location
- end
- var output = render_code(node)
- if output != null then
- obj["code"] = output.write_to_string
- end
+ if node == null then return obj
+
+ var code = render_code(node)
+ obj["location"] = node.location
+ obj["code"] = code.write_to_string
return obj
end
end
diff --git a/src/doc/templates/templates_json.nit b/src/doc/templates/json_model.nit
similarity index 82%
rename from src/doc/templates/templates_json.nit
rename to src/doc/templates/json_model.nit
index a75dc49d7c..b91a23725b 100644
--- a/src/doc/templates/templates_json.nit
+++ b/src/doc/templates/json_model.nit
@@ -22,13 +22,13 @@
# rather than the refs.
#
# TODO consider serialization module?
-module templates_json
+module json_model
import model::model_collect
-import json::static
import json::serialization_write
import catalog
-import doc_down
+
+import html_model
redef class MEntity
serialize
@@ -376,3 +376,72 @@ end
redef class String
super JsonRef
end
+
+# Catalog
+
+redef class MPackageMetadata
+ serialize
+
+ redef fun core_serialize_to(v) do
+ super
+ v.serialize_attribute("license", license)
+ v.serialize_attribute("maintainers", maintainers)
+ v.serialize_attribute("contributors", contributors)
+ v.serialize_attribute("tags", tags)
+ v.serialize_attribute("tryit", tryit)
+ v.serialize_attribute("apk", apk)
+ v.serialize_attribute("homepage", homepage)
+ v.serialize_attribute("browse", browse)
+ v.serialize_attribute("git", git)
+ v.serialize_attribute("issues", issues)
+ v.serialize_attribute("first_date", first_date)
+ v.serialize_attribute("last_date", last_date)
+ end
+end
+
+# Catalog statistics
+redef class CatalogStats
+ serialize
+
+ redef fun core_serialize_to(v) do
+ super
+ v.serialize_attribute("packages", packages)
+ v.serialize_attribute("maintainers", maintainers)
+ v.serialize_attribute("contributors", contributors)
+ v.serialize_attribute("tags", tags)
+ v.serialize_attribute("modules", modules)
+ v.serialize_attribute("classes", classes)
+ v.serialize_attribute("methods", methods)
+ v.serialize_attribute("loc", loc)
+ end
+end
+
+# MPackage statistics for the catalog
+redef class MPackageStats
+ serialize
+
+ redef fun core_serialize_to(v) do
+ super
+ v.serialize_attribute("mmodules", mmodules)
+ v.serialize_attribute("mclasses", mclasses)
+ v.serialize_attribute("mmethods", mmethods)
+ v.serialize_attribute("loc", loc)
+ v.serialize_attribute("errors", errors)
+ v.serialize_attribute("warnings", warnings)
+ v.serialize_attribute("warnings_per_kloc", warnings_per_kloc)
+ v.serialize_attribute("documentation_score", documentation_score)
+ v.serialize_attribute("commits", commits)
+ v.serialize_attribute("score", score)
+ end
+end
+
+redef class Person
+ serialize
+
+ redef fun core_serialize_to(v) do
+ super
+ v.serialize_attribute("name", name)
+ v.serialize_attribute("email", email)
+ v.serialize_attribute("gravatar", gravatar)
+ end
+end
diff --git a/src/doc/commands/commands_md.nit b/src/doc/templates/md_commands.nit
similarity index 79%
rename from src/doc/commands/commands_md.nit
rename to src/doc/templates/md_commands.nit
index 77ad14a02c..4c004c7a97 100644
--- a/src/doc/commands/commands_md.nit
+++ b/src/doc/templates/md_commands.nit
@@ -13,14 +13,15 @@
# limitations under the License.
# Render commands results as Markdown
-module commands_md
+module md_commands
-import commands::commands_graph
-import commands::commands_usage
-import commands::commands_ini
-import commands::commands_main
+import commands_catalog
+import commands_graph
+import commands_ini
+import commands_main
+import commands_usage
-import doc_down
+import highlight
redef class DocCommand
@@ -89,6 +90,17 @@ redef class CmdComment
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
redef class CmdEntityLink
@@ -99,17 +111,27 @@ redef class CmdEntityLink
end
end
-redef class CmdEntityCode
+redef class CmdCode
redef fun to_md do
- var output = render_code(node)
- if output == null then return ""
+ var node = self.node
+ if node == null then return ""
+ var code = render_code(node)
var tpl = new Template
tpl.addn "~~~nit"
- tpl.add output.write_to_string
+ tpl.add code.write_to_string
tpl.addn "~~~"
return tpl.write_to_string
end
+
+ redef fun render_code(node) do
+ if format == "ansi" then
+ var hl = new AnsiHighlightVisitor
+ hl.highlight_node node
+ return hl.result
+ end
+ return super
+ end
end
redef class CmdAncestors
@@ -320,3 +342,39 @@ redef class CmdTesting
return tpl.write_to_string
end
end
+
+# MDoc
+
+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
diff --git a/src/doc/templates/templates_term.nit b/src/doc/templates/term_model.nit
similarity index 99%
rename from src/doc/templates/templates_term.nit
rename to src/doc/templates/term_model.nit
index b4fc2fe3d5..4a442c5508 100644
--- a/src/doc/templates/templates_term.nit
+++ b/src/doc/templates/term_model.nit
@@ -16,7 +16,7 @@
#
# This module introduces Markdown rendering services in model entities.
# With the `no_color` option set to `false`, the output can be highlighted for console.
-module templates_term
+module term_model
import model_collect
import console
diff --git a/src/doc/commands/tests/test_commands_html.nit b/src/doc/templates/tests/test_html_commands.nit
similarity index 98%
rename from src/doc/commands/tests/test_commands_html.nit
rename to src/doc/templates/tests/test_html_commands.nit
index bd28d91280..dbaa9df0e6 100644
--- a/src/doc/commands/tests/test_commands_html.nit
+++ b/src/doc/templates/tests/test_html_commands.nit
@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-module test_commands_html is test
+module test_html_commands is test
import test_commands
intrude import doc::commands::commands_main
-import doc::commands::commands_html
+import html_commands
class TestCommandsHtml
super TestCommands
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ancestors.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ancestors.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ancestors.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ancestors.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_call.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_call.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_call.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_call.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_children.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_children.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_children.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_children.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_comment.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_comment.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_comment.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_comment.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_descendants.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_descendants.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_descendants.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_descendants.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_entity.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_entity.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_entity.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_entity.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_features.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_features.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_features.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_features.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_clone.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_clone.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_clone.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_clone.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_contrib_file.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_contrib_file.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_contrib_file.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_contrib_file.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_contrib_file_content.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_contrib_file_content.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_contrib_file_content.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_contrib_file_content.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_contributors.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_contributors.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_contributors.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_contributors.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_desc.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_desc.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_desc.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_desc.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_git.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_git.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_git.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_git.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_issues.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_issues.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_issues.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_issues.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_license.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_license.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_license.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_license.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_license_file.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_license_file.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_license_file.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_license_file.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_license_file_content.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_license_file_content.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_license_file_content.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_license_file_content.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_maintainer.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_maintainer.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_ini_maintainer.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_ini_maintainer.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_lin.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_lin.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_lin.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_lin.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_link.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_link.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_link.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_link.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_main_compile.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_main_compile.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_main_compile.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_main_compile.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_mains.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_mains.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_mains.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_mains.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_man_options.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_man_options.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_man_options.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_man_options.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_man_synopsis.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_man_synopsis.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_man_synopsis.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_man_synopsis.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_mentities.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_mentities.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_mentities.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_mentities.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_new.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_new.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_new.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_new.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_param.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_param.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_param.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_param.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_parents.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_parents.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_parents.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_parents.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_return.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_return.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_return.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_return.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_search.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_search.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_search.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_search.res
diff --git a/src/doc/commands/tests/test_commands_html.sav/test_cmd_testing.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_testing.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_html.sav/test_cmd_testing.res
rename to src/doc/templates/tests/test_html_commands.sav/test_cmd_testing.res
diff --git a/src/doc/commands/tests/test_commands_json.nit b/src/doc/templates/tests/test_json_commands.nit
similarity index 99%
rename from src/doc/commands/tests/test_commands_json.nit
rename to src/doc/templates/tests/test_json_commands.nit
index 7f616b40c8..db00f3a7ee 100644
--- a/src/doc/commands/tests/test_commands_json.nit
+++ b/src/doc/templates/tests/test_json_commands.nit
@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-module test_commands_json is test
+module test_json_commands is test
import test_commands
intrude import doc::commands::commands_main
-import doc::commands::commands_json
+import json_commands
class TestCommandsJson
super TestCommands
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ancestors.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ancestors.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ancestors.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ancestors.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_call.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_call.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_call.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_call.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_children.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_children.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_children.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_children.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_comment.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_comment.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_comment.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_comment.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_descendants.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_descendants.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_descendants.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_descendants.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_entity.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_entity.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_entity.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_entity.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_features.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_features.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_features.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_features.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_clone.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_clone.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_clone.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_clone.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_contrib_file.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_contrib_file.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file_content.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_contrib_file_content.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contrib_file_content.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_contrib_file_content.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contributors.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_contributors.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_contributors.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_contributors.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_desc.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_desc.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_desc.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_desc.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_git.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_git.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_git.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_git.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_issues.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_issues.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_issues.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_issues.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_license.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_license.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_license_file.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_license_file.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file_content.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_license_file_content.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_license_file_content.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_license_file_content.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_maintainer.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_maintainer.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_ini_maintainer.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_ini_maintainer.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_lin.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_lin.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_lin.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_lin.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_link.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_link.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_link.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_link.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_main_compile.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_main_compile.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_main_compile.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_main_compile.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_mains.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_mains.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_mains.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_mains.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_man_options.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_man_options.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_man_options.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_man_options.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_man_synopsis.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_man_synopsis.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_man_synopsis.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_man_synopsis.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_mentities.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_mentities.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_new.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_new.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_new.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_new.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_param.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_param.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_param.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_param.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_parents.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_parents.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_parents.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_parents.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_return.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_return.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_return.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_return.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_search.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_search.res
diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_testing.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_testing.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_json.sav/test_cmd_testing.res
rename to src/doc/templates/tests/test_json_commands.sav/test_cmd_testing.res
diff --git a/src/doc/templates/tests/test_templates_json.nit b/src/doc/templates/tests/test_json_model.nit
similarity index 98%
rename from src/doc/templates/tests/test_templates_json.nit
rename to src/doc/templates/tests/test_json_model.nit
index f1ba5367fc..d2f6c128ec 100644
--- a/src/doc/templates/tests/test_templates_json.nit
+++ b/src/doc/templates/tests/test_json_model.nit
@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-module test_templates_json is test
+module test_json_model is test
-import templates_json
+import json_model
import frontend
class TestModelSerialization
diff --git a/src/doc/templates/tests/test_templates_json.sav/test_classdefs_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_classdefs_to_full_json.res
similarity index 100%
rename from src/doc/templates/tests/test_templates_json.sav/test_classdefs_to_full_json.res
rename to src/doc/templates/tests/test_json_model.sav/test_classdefs_to_full_json.res
diff --git a/src/doc/templates/tests/test_templates_json.sav/test_classes_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_classes_to_full_json.res
similarity index 100%
rename from src/doc/templates/tests/test_templates_json.sav/test_classes_to_full_json.res
rename to src/doc/templates/tests/test_json_model.sav/test_classes_to_full_json.res
diff --git a/src/doc/templates/tests/test_templates_json.sav/test_groups_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_groups_to_full_json.res
similarity index 100%
rename from src/doc/templates/tests/test_templates_json.sav/test_groups_to_full_json.res
rename to src/doc/templates/tests/test_json_model.sav/test_groups_to_full_json.res
diff --git a/src/doc/templates/tests/test_templates_json.sav/test_modules_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_modules_to_full_json.res
similarity index 100%
rename from src/doc/templates/tests/test_templates_json.sav/test_modules_to_full_json.res
rename to src/doc/templates/tests/test_json_model.sav/test_modules_to_full_json.res
diff --git a/src/doc/templates/tests/test_templates_json.sav/test_packages_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_packages_to_full_json.res
similarity index 100%
rename from src/doc/templates/tests/test_templates_json.sav/test_packages_to_full_json.res
rename to src/doc/templates/tests/test_json_model.sav/test_packages_to_full_json.res
diff --git a/src/doc/templates/tests/test_templates_json.sav/test_propdefs_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_propdefs_to_full_json.res
similarity index 100%
rename from src/doc/templates/tests/test_templates_json.sav/test_propdefs_to_full_json.res
rename to src/doc/templates/tests/test_json_model.sav/test_propdefs_to_full_json.res
diff --git a/src/doc/templates/tests/test_templates_json.sav/test_props_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_props_to_full_json.res
similarity index 100%
rename from src/doc/templates/tests/test_templates_json.sav/test_props_to_full_json.res
rename to src/doc/templates/tests/test_json_model.sav/test_props_to_full_json.res
diff --git a/src/doc/templates/tests/test_templates_json.sav/test_refs_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_refs_to_full_json.res
similarity index 100%
rename from src/doc/templates/tests/test_templates_json.sav/test_refs_to_full_json.res
rename to src/doc/templates/tests/test_json_model.sav/test_refs_to_full_json.res
diff --git a/src/doc/commands/tests/test_commands_md.nit b/src/doc/templates/tests/test_md_commands.nit
similarity index 98%
rename from src/doc/commands/tests/test_commands_md.nit
rename to src/doc/templates/tests/test_md_commands.nit
index 031e21e636..de7d65597b 100644
--- a/src/doc/commands/tests/test_commands_md.nit
+++ b/src/doc/templates/tests/test_md_commands.nit
@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-module test_commands_md is test
+module test_md_commands is test
import test_commands
intrude import doc::commands::commands_main
-import doc::commands::commands_md
+import md_commands
class TestCommandsMd
super TestCommands
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ancestors.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ancestors.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ancestors.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ancestors.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_call.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_call.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_call.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_call.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_children.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_children.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_children.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_children.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_comment.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_comment.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_comment.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_comment.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_descendants.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_descendants.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_descendants.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_descendants.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_entity.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_entity.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_entity.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_entity.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_features.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_features.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_features.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_features.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_clone.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_clone.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_clone.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_clone.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_contrib_file.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_contrib_file.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_contrib_file.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_contrib_file.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_contrib_file_content.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_contrib_file_content.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_contrib_file_content.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_contrib_file_content.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_contributors.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_contributors.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_contributors.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_contributors.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_desc.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_desc.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_desc.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_desc.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_git.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_git.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_git.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_git.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_issues.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_issues.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_issues.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_issues.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_license.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_license.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_license.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_license.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_license_file.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_license_file.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_license_file.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_license_file.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_license_file_content.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_license_file_content.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_license_file_content.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_license_file_content.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_maintainer.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_maintainer.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_ini_maintainer.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_ini_maintainer.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_lin.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_lin.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_lin.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_lin.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_link.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_link.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_link.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_link.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_main_compile.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_main_compile.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_main_compile.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_main_compile.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_mains.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_mains.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_mains.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_mains.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_man_options.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_man_options.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_man_options.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_man_options.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_man_synopsis.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_man_synopsis.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_man_synopsis.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_man_synopsis.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_mentities.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_mentities.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_mentities.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_mentities.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_new.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_new.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_new.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_new.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_param.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_param.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_param.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_param.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_parents.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_parents.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_parents.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_parents.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_return.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_return.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_return.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_return.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_search.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_search.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_search.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_search.res
diff --git a/src/doc/commands/tests/test_commands_md.sav/test_cmd_testing.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_testing.res
similarity index 100%
rename from src/doc/commands/tests/test_commands_md.sav/test_cmd_testing.res
rename to src/doc/templates/tests/test_md_commands.sav/test_cmd_testing.res
diff --git a/src/doc/term/term.nit b/src/doc/term/term.nit
index 5010fc9579..7d490e44d5 100644
--- a/src/doc/term/term.nit
+++ b/src/doc/term/term.nit
@@ -15,7 +15,8 @@
module term
import commands::commands_parser
-import templates::templates_term
+import templates::term_model
+import templates::md_commands
redef class CommandParser
@@ -221,13 +222,12 @@ redef class CmdEntityCode
else
print title
end
- if no_color == null or not no_color then
+ var node = self.node
+ if (no_color == null or not no_color) and node != null then
var ansi = render_code(node)
- if ansi != null then
- print "~~~"
- print ansi.write_to_string
- print "~~~"
- end
+ print "~~~"
+ print ansi.write_to_string
+ print "~~~"
else
printn mentity.cs_source_code
end
diff --git a/src/frontend/parse_examples.nit b/src/frontend/parse_examples.nit
index 84c83a6121..78258fa096 100644
--- a/src/frontend/parse_examples.nit
+++ b/src/frontend/parse_examples.nit
@@ -22,7 +22,6 @@ module parse_examples
import counter
import typing
import parse_annotations
-import doc_down
import model::model_examples
redef class ToolContext
diff --git a/src/model/mdoc.nit b/src/model/mdoc.nit
index 261fafe3d1..52a6b7aa7e 100644
--- a/src/model/mdoc.nit
+++ b/src/model/mdoc.nit
@@ -31,6 +31,19 @@ class MDoc
# 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
redef class MEntity
diff --git a/src/nitcatalog.nit b/src/nitcatalog.nit
index 244be796ed..2a0a4a5b06 100644
--- a/src/nitcatalog.nit
+++ b/src/nitcatalog.nit
@@ -22,9 +22,10 @@
module nitcatalog
import loader # Scan&load packages, groups and modules
-import doc::doc_down # Display mdoc
import catalog
+import doc::templates::html_model
+
# A HTML page in a catalog
#
# This is just a template with the header pre-filled and the footer injected at rendering.
@@ -531,6 +532,24 @@ redef class Catalog
var piwik_site_id: Int = 1
end
+redef class Person
+ redef fun to_html do
+ var res = ""
+ var e = name.html_escape
+ var page = self.page
+ if page != null then
+ res += ""
+ end
+ var gravatar = self.gravatar
+ if gravatar != null then
+ res += " "
+ end
+ res += e
+ if page != null then res += ""
+ return res
+ end
+end
+
var model = new Model
var tc = new ToolContext
diff --git a/src/nitweb.nit b/src/nitweb.nit
index ab16edc96e..4ba30f5537 100644
--- a/src/nitweb.nit
+++ b/src/nitweb.nit
@@ -17,7 +17,6 @@ module nitweb
import frontend
import doc::api
-import doc::doc_down
redef class ToolContext