Merge: src/doc: Introduce doc commands
authorJean Privat <jean@pryen.org>
Fri, 24 Nov 2017 00:16:07 +0000 (19:16 -0500)
committerJean Privat <jean@pryen.org>
Fri, 24 Nov 2017 00:16:07 +0000 (19:16 -0500)
There is 3 doc related tools:
* nitdoc
* nitweb
* nitx

Each tool currently uses an ad-hoc way to explore the model, retrieve and present the results.

This PR aims at unifying the process between all the documentation tools by providing a unique API to explore model and entities.

A `DocCommand` represents a query to perform on the model.
Since a command can be used by a wide variety of clients, initialization of DocCommands works in two steps.

First, you pass the data you already have to the command at init:
~~~nit
# var c1 = new CmdEntity(view, mentity_name = "Array")
# var c2 = new CmdEntity(view, mentity = my_entity)
~~~

Then, you call `init_command` to initialize the missing field from the stub data:
~~~nit
var r1 = c1.init_command
assert c1.mentity != null
assert r1 isa CmdSuccess

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

There is a variety of commands that can be used to fulfill the tool objectives:
* `commands_model`: commands related to model and entities
* `commands_catalog`: commands related to catalog and statistics
* `commands_graph`: commands related to visual representations
* `commands_usage`: commands related to classes and methods usage
* `commands_docdown`: commands related to MDoc parsing and markdown features

To make the integration with tools easier some features are added in:
* `commands_parser`: parse commands from string such as `graph: array | pdepth: 1`
* `commands_http`: initialize commands options from HTTP requests

Rendering options:
* `commands_json`: render the command results as JSON
* `commands_html`: render the command results as HTML

A lot of examples can be found in the test modules.

Pull-Request: #2580
Reviewed-by: Jean Privat <jean@pryen.org>


Trivial merge