Skip to content

Commit

Permalink
Merge: nitx: use doc commands
Browse files Browse the repository at this point in the history
Three things in this PR:
* `nitx` now uses doc-commands (and related cleaning), bye bye the heavy `DocModel` with pre built `DocPages`
* More tests for `nitx`
* Move `nitx` to the `doc` tools suite, the group is now known as `doc::term`

Pull-Request: nitlang#2591
Reviewed-by: Jean Privat <jean@pryen.org>
  • Loading branch information
privat committed Dec 19, 2017
2 parents 85ed72a + 85de593 commit 88b16ba
Show file tree
Hide file tree
Showing 46 changed files with 1,424 additions and 1,411 deletions.
5 changes: 5 additions & 0 deletions share/man/nitx.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ Ignore the attributes.
### `--private`
Also generate private API.

### `--catalog`
Use catalog.

Allow queries to catalog data (can be long on large code base).

# SEE ALSO

The Nit language documentation and the source code of its tools and libraries may be downloaded from <http://nitlanguage.org>
11 changes: 8 additions & 3 deletions src/doc/commands/commands_model.nit
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class CmdCode
# Rendering format
#
# Set the output format for this piece of code.
# Can be "raw" or "html".
# Can be "raw", "html" or "ansi".
# Default is "raw".
#
# This format can be different than the format used in the command response.
Expand Down Expand Up @@ -431,9 +431,14 @@ class CmdCode
var hl = new HtmlightVisitor
hl.highlight_node node
return hl.html
else if format == "ansi" then
var hl = new AnsiHighlightVisitor
hl.highlight_node node
return hl.result
end
# TODO make a raw visitor
return node.to_s
var mentity = self.mentity
if mentity == null then return null
return mentity.location.text
end
end

Expand Down
29 changes: 29 additions & 0 deletions src/doc/commands/commands_parser.nit
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,35 @@ class CommandParser
"param", "return", "new", "call", "defs", "list", "random",
"catalog", "stats", "tags", "tag", "person", "contrib", "maintain"] is writable

# List of commands usage and documentation
var commands_usage: Map[String, String] do
var usage = new ArrayMap[String, String]
usage["search: <string>"] = "list entities matching `string`"
usage["doc: <name>"] = "display the documentation for `name`"
usage["defs: <name>"] = "list all definitions for `name`"
usage["code: <name>"] = "display the code for `name`"
usage["lin: <name>"] = "display the linearization for `name`"
usage["uml: <name>"] = "display the UML diagram for `name`"
usage["graph: <name>"] = "display the inheritance graph for `name`"
usage["parents: <name>"] = "list the direct parents of `name`"
usage["ancestors: <name>"] = "list all ancestors of `name`"
usage["children: <name>"] = "list direct children of `name`"
usage["descendants: <name>"] = "list all descendants of `name`"
usage["param: <type>"] = "list all methods accepting `type` as parameter"
usage["return: <type>"] = "list all methods returning `type`"
usage["new: <class>"] = "list all methods initializing `class`"
usage["call: <property>"] = "list all methods calling `property`"
usage["list: <kind>"] = "list all entities of `kind` from the model"
usage["random: <kind>"] = "list random entities of `kind` from the model"
usage["catalog:"] = "list packages from catalog"
usage["stats:"] = "display catalog statistics"
usage["tags:"] = "list all tabs from catalog"
usage["tag: <tag>"] = "list all packages with `tag`"
usage["maintain: <person>"] = "list all packages maintained by `person`"
usage["contrib: <person>"] = "list all packages contributed by `person`"
return usage
end

# Parse `string` as a DocCommand
#
# Returns `null` if the string cannot be parsed.
Expand Down
Loading

0 comments on commit 88b16ba

Please sign in to comment.