# See the License for the specific language governing permissions and
# limitations under the License.
-import java_api
+import java_api is example
# Get a Java string
var str = java_lang_integer_to_string_int(5678)
# See the License for the specific language governing permissions and
# limitations under the License.
+module user_test is example
+
import queue
var queue = new JavaQueue
# Example of a calculation used nitcc
# see `calc.sablecc` for the grammar
-module calc
+module calc is example
# Reuse the test program to simplify the code
import calc_test_parser
+module minilang is example
+
import minilang_test_parser
# An naive recursive stack-based interpreter of the minilang language.
# limitations under the License.
# Example that uses `shibuqam` to authenticate users and count the number of time they reload.
-module reloadgame
+module reloadgame is example
import popcorn
import counter
# * no `client_id`: because we do not want to code a db of clients. The `redirect_uri` can be seen as a simple client_id. We have also no way to present the client to the user since we do not control the authorization page of shibboleth since is done by the reverse proxy.
# * no `scope` and no `authorisation_code` since since there is nothing to access. We just get minimal information after the successful shibboleth login. Thus we have nothing more to authorise once the user is authenticated.
# * no `client_secret`: the user information are already public. There is no need to make the code more complex to protect public information.
-module shibuqamoauth
+module shibuqamoauth is example
import popcorn
import popcorn::pop_json
# 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.
+
+module blink is example
+
import wiringPi
if args.length != 1 then
# 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.
+
+module read is example
+
import wiringPi
if args.length != 1 then
# 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.
+
+module wiringPi is example
+
import wiringPi
if args.is_empty or args.length > 2 then
# Example of an implementation of circular lists
# This example shows the usage of generics and somewhat a specialisation of collections.
-module circular_list
+module circular_list is example
# Sequences of elements implemented with a double-linked circular list
class CircularList[E]
# limitations under the License.
# Simple example of refinement where a method is added to the integer class.
-module fibonacci
+module fibonacci is example
redef class Int
# Calculate the self-th element of the fibonacci sequence.
# An example that defines and uses stacks of integers.
# The implementation is done with a simple linked list.
# It features: free constructors, nullable types and some adaptive typing.
-module int_stack
+module int_stack is example
# A stack of integer implemented by a simple linked list.
# Note that this is only a toy class since a real linked list will gain to use
# Example of a procedural program (without explicit class definition).
# This program manipulates arrays of integers.
-module procedural_array
+module procedural_array is example
# The sum of the elements of `a'.
# Uses a 'for' control structure.
# limitations under the License.
# a "Framework" to make Multi-Agent Simulations in Nit
-module agent_simulation is no_warning("missing-doc")
+module agent_simulation is example, no_warning("missing-doc")
import actors
# The steps consist of each agent greeting each other, and
# waiting for every other agent to respond before notifying
# to the `ClockAgent` that they finished their step.
-module simple_simulation
+module simple_simulation is example
import agent_simulation
#
# Complete description of the chameneos-redux :
# https://benchmarksgame.alioth.debian.org/u64q/chameneosredux-description.html#chameneosredux
-module chameneosredux is no_warning("missing-doc")
+module chameneosredux is example, no_warning("missing-doc")
import actors
#
# Complete description of the fannkuch-redux :
# https://benchmarksgame.alioth.debian.org/u64q/fannkuchredux-description.html#fannkuchredux
-module fannkuchredux is no_warning("missing-doc")
+module fannkuchredux is example, no_warning("missing-doc")
import actors
#
# Complete description of mandelbrot :
# https://benchmarksgame.alioth.debian.org/u64q/mandelbrot-description.html#mandelbrot
-module mandelbrot is no_warning("missing-doc")
+module mandelbrot is example, no_warning("missing-doc")
import actors
# limitations under the License.
# A very simple example of the actor model
-module simple
+module simple is example
import actors
#
# Complete description of the thread-ring :
# http://benchmarksgame.alioth.debian.org/u64q/threadring-description.html#threadring
-module thread_ring
+module thread_ring is example
import actors
#
# The argument "abcd.fgeh" is the grid
#
-# ~~~
+# ~~~raw
# abc
# d.f
# geh
#
# The goal is:
#
-# ~~~
+# ~~~raw
# abc
# def
# gh.
#
# The shortest plan, in two steps, is to move *up* the tile under the hole (e),
# then to move *left* the tile after the hole (h).
+module puzzle is example
+
import ai::search
# The state (`S`) is a square grid, modeled as a one-dimensional array of Tile.
#
# This program takes an integer n as argument then display all solutions for the
# n-queens proglem (ie. on a n*n board).
-module queens
+module queens is example
import ai::backtrack
# Test for app.nit's UI services
module ui_test is
+ example
app_name "app.nit UI test"
app_version(0, 1, git_revision)
app_namespace "org.nitlanguage.ui_test"
# Example for the `app::http_request` main service `AsyncHttpRequest`
module http_request_example is
+ example
app_name "app.nit HTTP"
app_namespace "org.nitlanguage.http_example"
android_api_target 15
# User interface example using `app::ui`
module ui_example is
+ example
app_name "app.nit UI"
app_namespace "org.nitlanguage.ui_example"
android_api_min 21
# See the License for the specific language governing permissions and
# limitations under the License.
-module blink
+module blink is example
import bcm2835
# See the License for the specific language governing permissions and
# limitations under the License.
-module input
+module input is example
import bcm2835
# limitations under the License.
# Test extern classes from the Cocoa framework and extern factories
-module cocoa_extern_types
+module cocoa_extern_types is example
import cocoa
# limitations under the License.
# Simple message box using the Cocoa framework
-module cocoa_message_box
+module cocoa_message_box is example
import cocoa
# limitations under the License.
# Hello world using the Cocoa framework
-module hello_cocoa
+module hello_cocoa is example
import cocoa::foundation
# Standard classes and methods used by default by Nit programs and libraries.
# This module is implicitly imported by every module.
-module core is
- new_annotation test
- new_annotation before
- new_annotation before_all
- new_annotation after
- new_annotation after_all
-end
+module core
import posix
import environ
# See the License for the specific language governing permissions and
# limitations under the License.
+module repeating_key_xor_solve is example
+
import base64
import crapto
# limitations under the License.
# Example use of the Curl module
-module curl_http
+module curl_http is example
import curl
# another product.
# Simple XML validity checker using the `dom` module
-module checker
+module checker is example
import dom
# limitations under the License.
# Example from http://www.graphviz.org/content/cluster
+module clusters is example
import dot
# limitations under the License.
# Example from http://www.graphviz.org/content/hello
+module hello is example
import dot
# limitations under the License.
# Example from http://www.graphviz.org/Gallery/undirected/fdpclust.html
+module undirected_clusters is example
import dot
# Font support showcase
module fonts_showcase is
+ example
app_name "gamnit fonts"
app_namespace "org.gamnit.fonts_showcase"
app_version(1, 0, git_revision)
# Template for a 2D gamnit game
module template is
+ example
app_name "gamnit template"
app_namespace "org.gamnit.template"
app_version(0, 1, git_revision)
# * The book OpenGL ES 2.0 Programming Guide
# * https://code.google.com/p/opengles-book-samples/source/browse/trunk/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c
module portable_triangle is
+ example
app_name "gamnit Triangle"
app_namespace "org.nitlanguage.triangle"
app_version(1, 1, git_revision)
# References:
# * The book OpenGL ES 2.0 Programming Guide
# * https://code.google.com/p/opengles-book-samples/source/browse/trunk/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c
-module standalone_triangle
+module standalone_triangle is example
import app
import gamnit::display
# limitations under the License.
# Sample module showing the use of the i18n annotation
-module langannot is i18n
+module langannot is example, i18n
import gettext
#
# From the book OpenGL ES 2.0 Programming Guide, see code reference:
# https://code.google.com/p/opengles-book-samples/source/browse/trunk/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c
-module opengles2_hello_triangle
+module opengles2_hello_triangle is example
import glesv2
import egl
# See the License for the specific language governing permissions and
# limitations under the License.
+module html_page is example
+
import html
class NitHomepage
# Simple iOS app with a single label
module hello_ios is
+ example
app_name "Hello iOS"
app_namespace "nit.app.hello_ios"
app_version(0, 5, git_revision)
# See the License for the specific language governing permissions and
# limitations under the License.
-module mpi_simple
+module mpi_simple is example
import mpi
# Hyper Text Coffee Pot Control Protocol
# A server that implements HTCPCP. At the moment there are no additions.
-module htcpcp_server
+module htcpcp_server is example
import nitcorn
# The main page, `index.html`, is served dynamicly with `MyAction`.
# The rest of the Web site fetches files from the local directory
# `www/hello_world/`.
-module nitcorn_hello_world
+module nitcorn_hello_world is example
import nitcorn
# limitations under the License.
# Minimal example using a `ProxyAction`
+module nitcorn_reverse_proxy is example
import nitcorn::proxy
# limitations under the License.
# Example for the `restful` annotation documented at `lib/nitcorn/restful.nit`
-module restful_annot
+module restful_annot is example
import nitcorn::restful
import nitcorn::pthreads
#
# To be safe, it is recommended to run this program with its own username:
# `sudo file_server -u nitcorn:www`
-module simple_file_server
+module simple_file_server is example
import nitcorn
import privileges
# See the License for the specific language governing permissions and
# limitations under the License.
+module test_restful_annot is example
+
import nitcorn::restful_annot
import pthreads
#Â Creates a converter and initializes it
#Â Finally checks for dictionaries
-import pnacl
+import pnacl is example
class Converter
super PnaclApp
# See the License for the specific language governing permissions and
# limitations under the License.
+# This is an example of how to use angular.js with popcorn
+module example_angular is example
+
import popcorn
import popcorn::pop_json
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_post_handler is example
+
import popcorn
import template
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_query_string is example
+
import popcorn
import template
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_hello is example
+
import popcorn
class HelloHandler
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_advanced_logger is example
+
import popcorn
import realtime
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_html_error_handler is example
+
import popcorn
import template
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_simple_logger is example
+
import popcorn
class SimpleLoggerHandler
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_mongodb is example
+
import popcorn
import mongodb
import template
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_glob_route is example
+
import popcorn
class UserItem
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_param_route is example
+
import popcorn
class UserHome
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_router is example
+
import popcorn
class AppHome
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_session is example
+
import popcorn
redef class Session
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_static is example
+
import popcorn
var app = new App
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_static_default is example
+
import popcorn
var app = new App
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_static_multiple is example
+
import popcorn
var app = new App
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_templates is example
+
import popcorn
import popcorn::pop_templates
# limitations under the License.
# Example using the privileges module to drop privileges from root
-module drop_privileges
+module drop_privileges is example
import privileges
#
# 20 threads share an array and a barrier. They each insert 1000 strings into
# the array and wait at a barrier before finishing.
-module concurrent_array_and_barrier
+module concurrent_array_and_barrier is example
import pthreads::concurrent_collections
# limitations under the License.
# Simple example of joinable task using threadpool
-module jointask_example
+module jointask_example is example
import threadpool
# limitations under the License.
# test for threaded annotation
-module threaded_example
+module threaded_example is example
import pthreads
# limitations under the License.
# Simple example using threadpool
-module threadpool_example
+module threadpool_example is example
import threadpool
# limitations under the License.
# An example to test and demonstrate the `sdl2` lib with `image` and `events`
-module minimal
+module minimal is example
import sdl2::all
#
# The advantage of the approach is that it is done programmatically so can be adapted to real complex use cases.
# Basically, this is half-way between the full automatic serialization and the full manual serialisation.
-module custom_serialization
+module custom_serialization is example
import serialization
import json::serialization_write
# See the License for the specific language governing permissions and
# limitations under the License.
+module tmpl_composer is example
+
import template
### Here, definition of the specific templates
# limitations under the License.
# Sample module for a minimal chat server using Websockets on port 8088
-module websocket_server
+module websocket_server is example
import websocket
"file": "test_location"
}
}, {
+ "name": "game_examples",
+ "class_name": "MModule",
+ "full_name": "test_prog::game_examples",
+ "mdoc": null,
+ "visibility": "public",
+ "modifiers": ["module"],
+ "location": {
+ "column_end": 3,
+ "column_start": 1,
+ "line_end": 32,
+ "line_start": 15,
+ "file": "test_location"
+ }
+ }, {
"name": "platform",
"class_name": "MModule",
"full_name": "test_prog::platform",
}
}],
"page": 1,
- "count": 106,
+ "count": 113,
"limit": 10,
- "max": 10
+ "max": 11
}
var cmd = new CmdModelEntities(test_view, kind = "modules")
var res = cmd.init_command
assert res isa CmdSuccess
- assert cmd.results.as(not null).length == 9
+ assert cmd.results.as(not null).length == 10
end
fun test_cmd_results_random is test do
var cmd = parser.parse("descendants: Object")
assert cmd isa CmdDescendants
assert parser.error == null
- assert cmd.results.as(not null).length == 19
+ assert cmd.results.as(not null).length == 20
end
fun test_cmd_parser_descendants_without_children is test do
var cmd = parser.parse("descendants: Object | children: false")
assert cmd isa CmdDescendants
assert parser.error == null
- print cmd.results.as(not null)
- assert cmd.results.as(not null).length == 7
+ assert cmd.results.as(not null).length == 8
end
# CmdSearch
# ~~~raw
# get_mclasses ../../lib core::Array Array care::Arrow Fail
# ~~~
-module get_mclasses
+module get_mclasses is example
import parser_util
import modelbuilder
# This is an example of a client of the frontend without command-line processing.
#
# It offers a simple nitcorn web server that offers a textarea and nitpick and nitlignt it.
-module nitlight_as_a_service
+module nitlight_as_a_service is example
import frontend
import htmlight
# limitations under the License.
# Crawler on the nitweb web API
-module nitwebcrawl
+module nitwebcrawl is example
import json::static
# Sample program that scan and load things.
#
# It shows the difference betwenn the various services of the `loader`.
-module test_loader
+module test_loader is example
import loader
light_ffi
platform
+
+test
+before
+before_all
+after
+after_all
+example
"""
# Efficient set build from `primtives_annotations_list`
--- /dev/null
+# 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.
+
+# Example parsing
+#
+# This module parses example from mentities annotated with `is example`.
+#
+# TODO rank examples
+module parse_examples
+
+import counter
+import typing
+import parse_annotations
+import doc_down
+import model::model_examples
+
+redef class ToolContext
+
+ # Examples parsing phase
+ var examples_phase: Phase = new ExamplesPhase(self,
+ [typing_phase, parse_annotations_phase])
+end
+
+# Parse examples from modules, classdefs and propdefs
+#
+# For each node annotated with `is example` we parse the example and associate
+# it with existing model entities.
+#
+# Association between examples and mentities is based on:
+# `MModule`: Used in `import`
+# `MClassDef`: Used in `super`, redefined class, init or other method called
+# `MPropDef`: Used in `super`, redefined property, called
+private class ExamplesPhase
+ super Phase
+
+ redef fun process_nmodule(nmodule) do
+ var mmodule = nmodule.mmodule
+ if mmodule == null then return
+
+ if not mmodule.has_annotation("example") then return
+
+ process_example(mmodule, nmodule)
+ end
+
+ redef fun process_nclassdef(nclassdef) do
+ var mclassdef = nclassdef.mclassdef
+ if mclassdef == null then return
+
+ if not mclassdef.has_annotation("example") and not mclassdef.mmodule.is_example then return
+
+ process_example(mclassdef, nclassdef)
+ end
+
+ redef fun process_npropdef(npropdef) do
+ var mpropdef = npropdef.mpropdef
+ if mpropdef == null then return
+
+ if not mpropdef.has_annotation("example") and not mpropdef.mclassdef.is_example then return
+
+ process_example(mpropdef, npropdef)
+ end
+
+ # Process an mentity as an MExample
+ #
+ # This method parses the mentity node and link the mentity to possible
+ # examplified entities.
+ fun process_example(example_mentity: MEntity, node: ANode) do
+ var visitor = new ExampleVisitor(toolcontext)
+ visitor.enter_visit(node)
+ var sorted = visitor.counter.sort.reversed
+
+ var example = new MExample(example_mentity)
+ example.node = node
+ for mentity in sorted do
+ example.example_for[mentity] = visitor.counter[mentity]
+ if not mentity.examples.has(example) then mentity.examples.add example
+ end
+ end
+end
+
+redef class MExample
+ # AST node containing the example code
+ var node: nullable ANode = null is writable
+end
+
+# Example parsing
+
+# Visit examples to find what they are an example for.
+private class ExampleVisitor
+ super Visitor
+
+ var counter = new Counter[MEntity]
+
+ # The toolcontext is our entree point to most services
+ var toolcontext: ToolContext
+
+ redef fun visit(node) do
+ node.accept_example_visitor(self)
+ end
+end
+
+redef class ANode
+ private fun accept_example_visitor(v: ExampleVisitor) do visit_all(v)
+end
+
+redef class ANewExpr
+ redef fun accept_example_visitor(v) do
+ var recvtype = self.recvtype
+ if recvtype != null then
+ v.counter.inc recvtype.mclass.intro
+ end
+ visit_all(v)
+ end
+end
+
+redef class AStdImport
+ redef fun accept_example_visitor(v) do
+ var mmodule = self.mmodule
+ if mmodule != null then
+ v.counter.inc mmodule
+
+ var mgroup = mmodule.mgroup
+ if mgroup != null then
+ v.counter.inc mgroup
+ v.counter.inc mgroup.mpackage
+ end
+ end
+ end
+end
+
+redef class AStdClassdef
+ redef fun accept_example_visitor(v) do
+ var mclassdef = self.mclassdef
+ if mclassdef == null then return
+
+ if not mclassdef.is_intro then
+ v.counter.inc mclassdef.mclass.intro
+ end
+ visit_all(v)
+ end
+end
+
+redef class APropdef
+ redef fun accept_example_visitor(v) do
+ var mpropdef = self.mpropdef
+ if mpropdef == null then return
+
+ if not mpropdef.is_intro then
+ v.counter.inc mpropdef.mproperty.intro.mclassdef.mclass
+ v.counter.inc mpropdef.mproperty.intro.mclassdef
+ v.counter.inc mpropdef.mproperty.intro
+ end
+ visit_all(v)
+ end
+end
+
+redef class ASuperPropdef
+ redef fun accept_example_visitor(v) do
+ var mtype = self.n_type.mtype
+ if mtype isa MClassType then
+ v.counter.inc mtype.mclass
+ v.counter.inc mtype.mclass.intro
+ end
+ end
+end
+
+redef class ASendExpr
+ redef fun accept_example_visitor(v) do
+ var callsite = self.callsite
+ if callsite == null then return
+ v.counter.inc callsite.mpropdef
+ v.counter.inc callsite.mpropdef.mproperty
+ v.counter.inc callsite.mpropdef.mclassdef
+ v.counter.inc callsite.mpropdef.mclassdef.mclass
+ end
+end
--- /dev/null
+# 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.
+
+module test_examples is test
+
+import frontend
+import parse_examples
+import model_views
+
+class TestExample
+ test
+
+ # The path to the testunit being executed
+ #
+ # Used to retrieve the path to sources to compile.
+ var test_path: String = "NIT_TESTING_PATH".environ.dirname is lazy
+
+ # Test program to compile
+ #
+ # Default is `$NIT_DIR/tests/test_prog`.
+ var test_src: String = test_path / "../../../tests/test_prog" is lazy
+
+ fun test_model_examples is test do
+ var toolcontext = new ToolContext
+
+ # build model
+ var model = new Model
+ var modelbuilder = new ModelBuilder(model, toolcontext)
+ var mmodules = modelbuilder.parse_full([test_src])
+
+ # process
+ modelbuilder.run_phases
+ toolcontext.run_global_phases(mmodules)
+ var mainmodule = toolcontext.make_main_module(mmodules)
+
+ var filters = new ModelFilter(accept_example = true)
+
+ var view = new ModelView(model, mainmodule, filters)
+
+ for mentity in view.mentities do
+ if not mentity.is_example then continue
+
+ var mexample = mentity.mexample
+ if mexample == null then continue
+
+ print "{mentity.full_name} provides example for:"
+ for oentity, score in mexample.example_for do
+ print " * {oentity.full_name} ({score})"
+ end
+ end
+ end
+end
--- /dev/null
+test_prog::game_examples provides example for:
+ * test_prog::Game (4)
+ * test_prog$Game (4)
+ * test_prog$List (2)
+ * test_prog$Game$stop_game (1)
+ * test_prog$Game$pause_game (1)
+ * test_prog$Game$start_game (1)
+ * test_prog::game (1)
+ * test_prog>game> (1)
+ * test_prog (1)
+test_prog$MyGame provides example for:
+ * test_prog::Game (4)
+ * test_prog$Game (4)
+ * test_prog$List (2)
+ * test_prog$Game$stop_game (1)
+ * test_prog$Game$pause_game (1)
+ * test_prog$Game$start_game (1)
+test_prog$MyGame$Game::start_game provides example for:
+ * test_prog$Game$start_game (1)
+ * test_prog$Game (1)
+ * test_prog::Game (1)
+test_prog$MyGame$Game::pause_game provides example for:
+ * test_prog$Game$pause_game (1)
+ * test_prog$Game (1)
+ * test_prog::Game (1)
+test_prog$MyGame$Game::stop_game provides example for:
+ * test_prog$Game$stop_game (1)
+ * test_prog$Game (1)
+ * test_prog::Game (1)
+test_prog$MyGame$_player_characters provides example for:
+ * test_prog$List (1)
+test_prog$MyGame$_computer_characters provides example for:
+ * test_prog$List (1)
# This method uses a flattened hierarchy containing all the mclassdefs.
redef fun collect_parents(view) do
var res = new HashSet[MENTITY]
+ if not view.mainmodule.flatten_mclass_hierarchy.has(self) then return res
for mclass in in_hierarchy(view.mainmodule).direct_greaters do
if mclass == self or not view.accept_mentity(mclass) then continue
res.add mclass
# This method uses a flattened hierarchy containing all the mclassdefs.
redef fun collect_children(view) do
var res = new HashSet[MENTITY]
+ if not view.mainmodule.flatten_mclass_hierarchy.has(self) then return res
for mclass in in_hierarchy(view.mainmodule).direct_smallers do
if mclass == self or not view.accept_mentity(mclass) then continue
res.add mclass
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2012 Jean Privat <jean@pryen.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.
+
+# Examples for Model entities
+#
+# This module introduce flags in all mentities so they can be tagged as example.
+# Flagged classes will be treated differently by the documentation tools.
+#
+# See `MEntity::is_example` and `MEntity::examples`.
+module model_examples
+
+import model
+
+# An example from a MEntity flagged with `is example`.
+class MExample
+
+ redef init do
+ super
+ mentity.mexample = self
+ end
+
+ # MEntity containing this example
+ var mentity: MEntity
+
+ # MEntities this example is for
+ #
+ # For each entity we provide a weight so examples can be ranked.
+ var example_for = new ArrayMap[MEntity, Int]
+
+ redef fun to_s do return mentity.full_name
+end
+
+redef class MEntity
+
+ # Is `self` existing for an example purpose?
+ #
+ # All mentities annotated with `is example` or located inside a mentity that
+ # is an example are considered as examples.
+ fun is_example: Bool do return mexample != null
+
+ # Return this entity as a MExample
+ var mexample: nullable MExample = null
+
+ # Examples found for `self`
+ var examples = new Array[MExample]
+end
+
+redef class MPackage
+ redef fun examples do
+ var res = super
+ for mgroup in mgroups do
+ for example in mgroup.examples do
+ if not res.has(example) then res.add example
+ end
+ end
+ return res
+ end
+end
+
+redef class MGroup
+ redef var is_example is lazy do
+ var parent = self.parent
+ if parent != null and parent.is_example then return true
+ return name == "examples"
+ end
+
+ redef fun examples do
+ var res = super
+ for mmodule in mmodules do
+ for example in mmodule.examples do
+ if not res.has(example) then res.add example
+ end
+ end
+ return res
+ end
+end
+
+redef class MClass
+ redef var is_example is lazy do return intro.is_example
+
+ redef fun examples do
+ var res = super
+ for mclassdef in mclassdefs do
+ for example in mclassdef.examples do
+ if not res.has(example) then res.add example
+ end
+ end
+ return res
+ end
+end
+
+redef class MProperty
+ redef var is_example is lazy do return intro.is_example
+
+ redef fun examples do
+ var res = super
+ for mpropdef in mpropdefs do
+ for example in mpropdef.examples do
+ if not res.has(example) then res.add example
+ end
+ end
+ return res
+ end
+end
module model_filters
-import model
+import model_examples
# A list of filters that can be applied on a MEntity
#
if not accept_mentity_test(mentity) then return false
if not accept_mentity_redef(mentity) then return false
if not accept_mentity_extern(mentity) then return false
+ if not accept_mentity_example(mentity) then return false
if not accept_mentity_attribute(mentity) then return false
if not accept_mentity_empty_doc(mentity) then return false
if not accept_mentity_inherited(mentity) then return false
return mentity.mdoc_or_fallback != null
end
+ # Accept examples?
+ #
+ # Default is `true`.
+ var accept_example = true is optional
+
+ # Accept only entities that are not example related
+ fun accept_mentity_example(mentity: MEntity): Bool do
+ if accept_example then return true
+ return not mentity.is_example
+ end
+
# If set, accept only entities local to `accept_inherited`
var accept_inherited: nullable MEntity = null is optional
min_visibility = protected_visibility,
accept_fictive = false,
accept_test = false,
+ accept_example = false,
accept_redef = true,
accept_extern = true,
accept_attribute = true,
"redef_mpropdefs": []
}
{
+ "name": "MyGame",
+ "class_name": "MClassDef",
+ "full_name": "test_prog$MyGame",
+ "mdoc": {
+ "content": "This is an example of how to implement the Game interface",
+ "location": {
+ "column_end": 0,
+ "column_start": 1,
+ "line_end": 20,
+ "line_start": 19,
+ "file": "test_location"
+ }
+ },
+ "visibility": "public",
+ "modifiers": ["class"],
+ "location": {
+ "column_end": 3,
+ "column_start": 1,
+ "line_end": 32,
+ "line_start": 19,
+ "file": "test_location"
+ },
+ "is_intro": true,
+ "mparameters": [],
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mclass": {
+ "full_name": "test_prog::MyGame"
+ },
+ "mpropdefs": [{
+ "full_name": "test_prog$MyGame$_computer_characters"
+ }, {
+ "full_name": "test_prog$MyGame$_player_characters"
+ }, {
+ "full_name": "test_prog$MyGame$Game::computer_characters"
+ }, {
+ "full_name": "test_prog$MyGame$computer_characters="
+ }, {
+ "full_name": "test_prog$MyGame$Game::pause_game"
+ }, {
+ "full_name": "test_prog$MyGame$Game::player_characters"
+ }, {
+ "full_name": "test_prog$MyGame$player_characters="
+ }, {
+ "full_name": "test_prog$MyGame$Game::start_game"
+ }, {
+ "full_name": "test_prog$MyGame$Game::stop_game"
+ }],
+ "intro_mproperties": [{
+ "full_name": "test_prog::game_examples::MyGame::_computer_characters"
+ }, {
+ "full_name": "test_prog::game_examples::MyGame::_player_characters"
+ }, {
+ "full_name": "test_prog::MyGame::computer_characters="
+ }, {
+ "full_name": "test_prog::MyGame::player_characters="
+ }],
+ "intro": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "intro_mpropdefs": [{
+ "full_name": "test_prog$MyGame$_computer_characters"
+ }, {
+ "full_name": "test_prog$MyGame$_player_characters"
+ }, {
+ "full_name": "test_prog$MyGame$computer_characters="
+ }, {
+ "full_name": "test_prog$MyGame$player_characters="
+ }],
+ "redef_mpropdefs": [{
+ "full_name": "test_prog$MyGame$Game::computer_characters"
+ }, {
+ "full_name": "test_prog$MyGame$Game::pause_game"
+ }, {
+ "full_name": "test_prog$MyGame$Game::player_characters"
+ }, {
+ "full_name": "test_prog$MyGame$Game::start_game"
+ }, {
+ "full_name": "test_prog$MyGame$Game::stop_game"
+ }]
+}
+{
"name": "Starter",
"class_name": "MClassDef",
"full_name": "test_prog$Starter",
}]
}
{
+ "name": "MyGame",
+ "class_name": "MClass",
+ "full_name": "test_prog::MyGame",
+ "mdoc": {
+ "content": "This is an example of how to implement the Game interface",
+ "location": {
+ "column_end": 0,
+ "column_start": 1,
+ "line_end": 20,
+ "line_start": 19,
+ "file": "test_location"
+ }
+ },
+ "visibility": "public",
+ "modifiers": ["class"],
+ "location": {
+ "column_end": 3,
+ "column_start": 1,
+ "line_end": 32,
+ "line_start": 19,
+ "file": "test_location"
+ },
+ "mparameters": [],
+ "intro": {
+ "full_name": "test_prog$MyGame"
+ },
+ "intro_mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "mclassdefs": [{
+ "full_name": "test_prog$MyGame"
+ }],
+ "all_mproperties": [{
+ "full_name": "test_prog::game_examples::MyGame::_computer_characters"
+ }, {
+ "full_name": "test_prog::game_examples::MyGame::_player_characters"
+ }, {
+ "full_name": "test_prog::Game::computer_characters"
+ }, {
+ "full_name": "test_prog::MyGame::computer_characters="
+ }, {
+ "full_name": "test_prog::Game::pause_game"
+ }, {
+ "full_name": "test_prog::Game::player_characters"
+ }, {
+ "full_name": "test_prog::MyGame::player_characters="
+ }, {
+ "full_name": "test_prog::Game::start_game"
+ }, {
+ "full_name": "test_prog::Game::stop_game"
+ }],
+ "intro_mproperties": [{
+ "full_name": "test_prog::game_examples::MyGame::_computer_characters"
+ }, {
+ "full_name": "test_prog::game_examples::MyGame::_player_characters"
+ }, {
+ "full_name": "test_prog::MyGame::computer_characters="
+ }, {
+ "full_name": "test_prog::MyGame::player_characters="
+ }],
+ "redef_mproperties": [{
+ "full_name": "test_prog::Game::computer_characters"
+ }, {
+ "full_name": "test_prog::Game::pause_game"
+ }, {
+ "full_name": "test_prog::Game::player_characters"
+ }, {
+ "full_name": "test_prog::Game::start_game"
+ }, {
+ "full_name": "test_prog::Game::stop_game"
+ }],
+ "parents": []
+}
+{
"name": "Starter",
"class_name": "MClass",
"full_name": "test_prog::Starter",
"full_name": "test_prog::test_prog"
}],
"mgroups": [{
+ "full_name": "test_prog>examples>"
+ }, {
"full_name": "test_prog>game>"
}, {
"full_name": "test_prog>platform>"
}]
}
{
+ "name": "examples",
+ "class_name": "MGroup",
+ "full_name": "test_prog>examples>",
+ "mdoc": null,
+ "visibility": "public",
+ "modifiers": ["group"],
+ "location": {
+ "column_end": 0,
+ "column_start": 0,
+ "line_end": 0,
+ "line_start": 0,
+ "file": "test_location"
+ },
+ "is_root": false,
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "default_mmodule": null,
+ "parent": {
+ "full_name": "test_prog>"
+ },
+ "mmodules": [{
+ "full_name": "test_prog::game_examples"
+ }],
+ "mgroups": []
+}
+{
"name": "game",
"class_name": "MGroup",
"full_name": "test_prog>game>",
{
+ "name": "game_examples",
+ "class_name": "MModule",
+ "full_name": "test_prog::game_examples",
+ "mdoc": null,
+ "visibility": "public",
+ "modifiers": ["module"],
+ "location": {
+ "column_end": 3,
+ "column_start": 1,
+ "line_end": 32,
+ "line_start": 15,
+ "file": "test_location"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "intro_mclasses": [{
+ "full_name": "test_prog::MyGame"
+ }],
+ "mclassdefs": [{
+ "full_name": "test_prog$MyGame"
+ }],
+ "intro_mclassdefs": [{
+ "full_name": "test_prog$MyGame"
+ }],
+ "redef_mclassdefs": [],
+ "imports": [{
+ "full_name": "test_prog::game"
+ }]
+}
+{
"name": "excluded",
"class_name": "MModule",
"full_name": "excluded::excluded",
"redef_mclassdefs": [],
"imports": [{
"full_name": "test_prog::test_prog"
+ }, {
+ "full_name": "test_prog::game_examples"
}]
}
"full_name": "test_prog>"
},
"mgroups": [{
+ "full_name": "test_prog>examples>"
+ }, {
"full_name": "test_prog>game>"
}, {
"full_name": "test_prog>platform>"
}
}
{
+ "name": "player_characters",
+ "class_name": "MMethodDef",
+ "full_name": "test_prog$MyGame$Game::player_characters",
+ "mdoc": {
+ "content": "Characters played by human players.",
+ "location": {
+ "column_end": 0,
+ "column_start": 2,
+ "line_end": 26,
+ "line_start": 25,
+ "file": "test_location"
+ }
+ },
+ "visibility": "public",
+ "modifiers": ["redef", "fun"],
+ "location": {
+ "column_end": 50,
+ "column_start": 2,
+ "line_end": 23,
+ "line_start": 23,
+ "file": "test_location"
+ },
+ "is_intro": false,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::Game::player_characters"
+ },
+ "intro": {
+ "full_name": "test_prog$Game$player_characters"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$Game"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "msignature": {
+ "arity": 0,
+ "mparams": [],
+ "return_mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ },
+ "vararg_rank": -1
+ }
+}
+{
"name": "computer_characters",
"class_name": "MMethodDef",
"full_name": "test_prog$Game$computer_characters",
}
}
{
+ "name": "computer_characters",
+ "class_name": "MMethodDef",
+ "full_name": "test_prog$MyGame$Game::computer_characters",
+ "mdoc": {
+ "content": "Characters players by computer.",
+ "location": {
+ "column_end": 0,
+ "column_start": 2,
+ "line_end": 29,
+ "line_start": 28,
+ "file": "test_location"
+ }
+ },
+ "visibility": "public",
+ "modifiers": ["redef", "fun"],
+ "location": {
+ "column_end": 52,
+ "column_start": 2,
+ "line_end": 25,
+ "line_start": 25,
+ "file": "test_location"
+ },
+ "is_intro": false,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::Game::computer_characters"
+ },
+ "intro": {
+ "full_name": "test_prog$Game$computer_characters"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$Game"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "msignature": {
+ "arity": 0,
+ "mparams": [],
+ "return_mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ },
+ "vararg_rank": -1
+ }
+}
+{
"name": "start_game",
"class_name": "MMethodDef",
"full_name": "test_prog$Game$start_game",
}
}
{
+ "name": "start_game",
+ "class_name": "MMethodDef",
+ "full_name": "test_prog$MyGame$Game::start_game",
+ "mdoc": {
+ "content": "Start the game.\n\nYou have to implement that method!",
+ "location": {
+ "column_end": 0,
+ "column_start": 2,
+ "line_end": 34,
+ "line_start": 31,
+ "file": "test_location"
+ }
+ },
+ "visibility": "public",
+ "modifiers": ["redef", "fun"],
+ "location": {
+ "column_end": 28,
+ "column_start": 2,
+ "line_end": 27,
+ "line_start": 27,
+ "file": "test_location"
+ },
+ "is_intro": false,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::Game::start_game"
+ },
+ "intro": {
+ "full_name": "test_prog$Game$start_game"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$Game"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "msignature": {
+ "arity": 0,
+ "mparams": [],
+ "return_mtype": null,
+ "vararg_rank": -1
+ }
+}
+{
"name": "pause_game",
"class_name": "MMethodDef",
"full_name": "test_prog$Game$pause_game",
}
}
{
+ "name": "pause_game",
+ "class_name": "MMethodDef",
+ "full_name": "test_prog$MyGame$Game::pause_game",
+ "mdoc": {
+ "content": "Pause the game.\n\nYou have to implement that method!",
+ "location": {
+ "column_end": 0,
+ "column_start": 2,
+ "line_end": 39,
+ "line_start": 36,
+ "file": "test_location"
+ }
+ },
+ "visibility": "public",
+ "modifiers": ["redef", "fun"],
+ "location": {
+ "column_end": 28,
+ "column_start": 2,
+ "line_end": 29,
+ "line_start": 29,
+ "file": "test_location"
+ },
+ "is_intro": false,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::Game::pause_game"
+ },
+ "intro": {
+ "full_name": "test_prog$Game$pause_game"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$Game"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "msignature": {
+ "arity": 0,
+ "mparams": [],
+ "return_mtype": null,
+ "vararg_rank": -1
+ }
+}
+{
"name": "stop_game",
"class_name": "MMethodDef",
"full_name": "test_prog$Game$stop_game",
}
}
{
+ "name": "stop_game",
+ "class_name": "MMethodDef",
+ "full_name": "test_prog$MyGame$Game::stop_game",
+ "mdoc": {
+ "content": "Stop the game.\n\nYou have to implement that method!",
+ "location": {
+ "column_end": 0,
+ "column_start": 2,
+ "line_end": 44,
+ "line_start": 41,
+ "file": "test_location"
+ }
+ },
+ "visibility": "public",
+ "modifiers": ["redef", "fun"],
+ "location": {
+ "column_end": 27,
+ "column_start": 2,
+ "line_end": 31,
+ "line_start": 31,
+ "file": "test_location"
+ },
+ "is_intro": false,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::Game::stop_game"
+ },
+ "intro": {
+ "full_name": "test_prog$Game$stop_game"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$Game"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "msignature": {
+ "arity": 0,
+ "mparams": [],
+ "return_mtype": null,
+ "vararg_rank": -1
+ }
+}
+{
+ "name": "_player_characters",
+ "class_name": "MAttributeDef",
+ "full_name": "test_prog$MyGame$_player_characters",
+ "mdoc": null,
+ "visibility": "private",
+ "modifiers": ["private", "var"],
+ "location": {
+ "column_end": 50,
+ "column_start": 2,
+ "line_end": 23,
+ "line_start": 23,
+ "file": "test_location"
+ },
+ "is_intro": true,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::game_examples::MyGame::_player_characters"
+ },
+ "intro": {
+ "full_name": "test_prog$MyGame$_player_characters"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "static_mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ }
+}
+{
+ "name": "player_characters=",
+ "class_name": "MMethodDef",
+ "full_name": "test_prog$MyGame$player_characters=",
+ "mdoc": null,
+ "visibility": "protected",
+ "modifiers": ["protected", "fun"],
+ "location": {
+ "column_end": 50,
+ "column_start": 2,
+ "line_end": 23,
+ "line_start": 23,
+ "file": "test_location"
+ },
+ "is_intro": true,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::MyGame::player_characters="
+ },
+ "intro": {
+ "full_name": "test_prog$MyGame$player_characters="
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "msignature": {
+ "arity": 1,
+ "mparams": [{
+ "is_vararg": false,
+ "name": "player_characters",
+ "mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ }
+ }],
+ "return_mtype": null,
+ "vararg_rank": -1
+ }
+}
+{
+ "name": "_computer_characters",
+ "class_name": "MAttributeDef",
+ "full_name": "test_prog$MyGame$_computer_characters",
+ "mdoc": null,
+ "visibility": "private",
+ "modifiers": ["private", "var"],
+ "location": {
+ "column_end": 52,
+ "column_start": 2,
+ "line_end": 25,
+ "line_start": 25,
+ "file": "test_location"
+ },
+ "is_intro": true,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::game_examples::MyGame::_computer_characters"
+ },
+ "intro": {
+ "full_name": "test_prog$MyGame$_computer_characters"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "static_mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ }
+}
+{
+ "name": "computer_characters=",
+ "class_name": "MMethodDef",
+ "full_name": "test_prog$MyGame$computer_characters=",
+ "mdoc": null,
+ "visibility": "protected",
+ "modifiers": ["protected", "fun"],
+ "location": {
+ "column_end": 52,
+ "column_start": 2,
+ "line_end": 25,
+ "line_start": 25,
+ "file": "test_location"
+ },
+ "is_intro": true,
+ "mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mproperty": {
+ "full_name": "test_prog::MyGame::computer_characters="
+ },
+ "intro": {
+ "full_name": "test_prog$MyGame$computer_characters="
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mmodule": {
+ "full_name": "test_prog::game_examples"
+ },
+ "mgroup": {
+ "full_name": "test_prog>examples>"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "msignature": {
+ "arity": 1,
+ "mparams": [{
+ "is_vararg": false,
+ "name": "computer_characters",
+ "mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ }
+ }],
+ "return_mtype": null,
+ "vararg_rank": -1
+ }
+}
+{
"name": "start",
"class_name": "MMethodDef",
"full_name": "test_prog$Starter$start",
},
"mpropdefs": [{
"full_name": "test_prog$Game$player_characters"
+ }, {
+ "full_name": "test_prog$MyGame$Game::player_characters"
}],
"intro_mclass": {
"full_name": "test_prog::Game"
},
"mpropdefs": [{
"full_name": "test_prog$Game$computer_characters"
+ }, {
+ "full_name": "test_prog$MyGame$Game::computer_characters"
}],
"intro_mclass": {
"full_name": "test_prog::Game"
},
"mpropdefs": [{
"full_name": "test_prog$Game$start_game"
+ }, {
+ "full_name": "test_prog$MyGame$Game::start_game"
}],
"intro_mclass": {
"full_name": "test_prog::Game"
},
"mpropdefs": [{
"full_name": "test_prog$Game$pause_game"
+ }, {
+ "full_name": "test_prog$MyGame$Game::pause_game"
}],
"intro_mclass": {
"full_name": "test_prog::Game"
},
"mpropdefs": [{
"full_name": "test_prog$Game$stop_game"
+ }, {
+ "full_name": "test_prog$MyGame$Game::stop_game"
}],
"intro_mclass": {
"full_name": "test_prog::Game"
}
}
{
+ "name": "_player_characters",
+ "class_name": "MAttribute",
+ "full_name": "test_prog::game_examples::MyGame::_player_characters",
+ "mdoc": null,
+ "visibility": "private",
+ "modifiers": ["private", "var"],
+ "location": {
+ "column_end": 50,
+ "column_start": 2,
+ "line_end": 23,
+ "line_start": 23,
+ "file": "test_location"
+ },
+ "intro": {
+ "full_name": "test_prog$MyGame$_player_characters"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mpropdefs": [{
+ "full_name": "test_prog$MyGame$_player_characters"
+ }],
+ "intro_mclass": {
+ "full_name": "test_prog::MyGame"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "static_mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ }
+}
+{
+ "name": "player_characters=",
+ "class_name": "MMethod",
+ "full_name": "test_prog::MyGame::player_characters=",
+ "mdoc": null,
+ "visibility": "protected",
+ "modifiers": ["protected", "fun"],
+ "location": {
+ "column_end": 50,
+ "column_start": 2,
+ "line_end": 23,
+ "line_start": 23,
+ "file": "test_location"
+ },
+ "intro": {
+ "full_name": "test_prog$MyGame$player_characters="
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mpropdefs": [{
+ "full_name": "test_prog$MyGame$player_characters="
+ }],
+ "intro_mclass": {
+ "full_name": "test_prog::MyGame"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "is_init": false,
+ "msignature": {
+ "arity": 1,
+ "mparams": [{
+ "is_vararg": false,
+ "name": "player_characters",
+ "mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ }
+ }],
+ "return_mtype": null,
+ "vararg_rank": -1
+ }
+}
+{
+ "name": "_computer_characters",
+ "class_name": "MAttribute",
+ "full_name": "test_prog::game_examples::MyGame::_computer_characters",
+ "mdoc": null,
+ "visibility": "private",
+ "modifiers": ["private", "var"],
+ "location": {
+ "column_end": 52,
+ "column_start": 2,
+ "line_end": 25,
+ "line_start": 25,
+ "file": "test_location"
+ },
+ "intro": {
+ "full_name": "test_prog$MyGame$_computer_characters"
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mpropdefs": [{
+ "full_name": "test_prog$MyGame$_computer_characters"
+ }],
+ "intro_mclass": {
+ "full_name": "test_prog::MyGame"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "static_mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ }
+}
+{
+ "name": "computer_characters=",
+ "class_name": "MMethod",
+ "full_name": "test_prog::MyGame::computer_characters=",
+ "mdoc": null,
+ "visibility": "protected",
+ "modifiers": ["protected", "fun"],
+ "location": {
+ "column_end": 52,
+ "column_start": 2,
+ "line_end": 25,
+ "line_start": 25,
+ "file": "test_location"
+ },
+ "intro": {
+ "full_name": "test_prog$MyGame$computer_characters="
+ },
+ "intro_mclassdef": {
+ "full_name": "test_prog$MyGame"
+ },
+ "mpropdefs": [{
+ "full_name": "test_prog$MyGame$computer_characters="
+ }],
+ "intro_mclass": {
+ "full_name": "test_prog::MyGame"
+ },
+ "mpackage": {
+ "full_name": "test_prog"
+ },
+ "is_init": false,
+ "msignature": {
+ "arity": 1,
+ "mparams": [{
+ "is_vararg": false,
+ "name": "computer_characters",
+ "mtype": {
+ "full_name": "test_prog::List[test_prog::Character]"
+ }
+ }],
+ "return_mtype": null,
+ "vararg_rank": -1
+ }
+}
+{
"name": "start",
"class_name": "MMethod",
"full_name": "test_prog::Starter::start",
"full_name": "test_prog"
}
{
- "full_name": "excluded::excluded"
+ "full_name": "test_prog::game_examples"
}
{
"full_name": "test_prog::Object"
<p><img src="../res/c94d8a73ccfe143ebde7599e88f5f5ce.png" alt="Tinks3D"/></p>
</div><h2>Content</h2><ul>
<li><strong>test_prog</strong>: <span class="synopsys nitdoc">Test program for model tools.</span> (test_prog)<ul>
+<li><strong>examples</strong> (test_prog/examples)<ul>
+<li><strong>game_examples</strong> (test_prog/examples/game_examples.nit)</li>
+</ul>
+</li>
<li><strong>game</strong>: <span class="synopsys nitdoc">Gaming group</span> (test_prog/game)<ul>
<li><strong>game</strong>: <span class="synopsys nitdoc">A game abstraction for RPG.</span> (test_prog/game/game.nit)</li>
</ul>
</ul>
<h3>Quality</h3>
<ul class="box">
-<li>28 warnings (63/kloc)</li>
-<li>95% documented</li>
+<li>28 warnings (59/kloc)</li>
+<li>82% documented</li>
</ul>
<h3>Tags</h3>
<a href="../index.html#tag_test">test</a>, <a href="../index.html#tag_game">game</a><h3>Requirements</h3>
none<h3>Contributors</h3>
<ul class="box"><li><a href="http://www.example.com/~jdoe"><img src="https://secure.gravatar.com/avatar/694ea0904ceaf766c6738166ed89bafb?size=20&default=retro"> John Doe</a></li><li><img src="https://secure.gravatar.com/avatar/db3f2909768694ad2bb6409b44627182?size=20&default=retro"> Riri</li><li>Fifi (http://www.example.com/~fifi)</li><li>Loulou</li></ul><h3>Stats</h3>
<ul class="box">
-<li>8 modules</li>
-<li>22 classes</li>
-<li>68 methods</li>
-<li>439 lines of code</li>
+<li>9 modules</li>
+<li>23 classes</li>
+<li>75 methods</li>
+<li>471 lines of code</li>
</ul>
</div>
</div> <!-- container-fluid -->
+Empty README for group `examples` (readme-warning)
Empty README for group `excluded` (readme-warning)
-Errors: 0. Warnings: 1.
+Errors: 0. Warnings: 2.
MGroupPage excluded
# excluded.section
## excluded.intro
ReadmePage test_prog
# mdarticle-0
+ReadmePage examples
+
ReadmePage game
# mdarticle-0
# main.section
## test_prog-__Sys__main.intro
+MGroupPage examples
+ # examples.section
+ ## test_prog__examples.intro
+ ## test_prog__examples.concerns
+ ## test_prog.concern
+ ## test_prog.concern
+ ## test_prog__examples.concern
+ ## test_prog__examples-.concern
+ ### test_prog__examples-.definition
+ #### test_prog__examples-.intros_redefs
+ ##### list.group
+ ###### test_prog__examples-.intros
+ ###### test_prog__examples-.redefs
+
+MModulePage game_examples
+ # game_examples.section
+ ## test_prog__examples-.intro
+ ## test_prog__examples-.importation
+ ### test_prog__examples-.graph
+ ### list.group
+ #### test_prog__examples-.imports
+ #### test_prog__examples-.clients
+ ## test_prog__examples-.concerns
+ ## test_prog.concern
+ ## test_prog.concern
+ ## test_prog__examples.concern
+ ## test_prog__examples-.concern
+ ### test_prog__examples-__MyGame.definition-list
+ #### test_prog__examples-__MyGame.definition
+ ##### test_prog__examples-__MyGame.intros_redefs
+ ###### list.group
+ ####### test_prog__examples-__MyGame.intros
+ ####### test_prog__examples-__MyGame.redefs
+
+MClassPage MyGame
+ # MyGame.section
+ ## test_prog__examples-__MyGame.intro
+ ## test_prog__examples-__MyGame.inheritance
+ ### test_prog__examples-__MyGame.graph
+ ### list.group
+ #### test_prog__examples-__MyGame.parents
+ #### test_prog__examples-__MyGame.ancestors
+ #### test_prog__examples-__MyGame.children
+ #### test_prog__examples-__MyGame.descendants
+ ## test_prog__examples-__MyGame.constructors
+ ### test_prog__platform-__Object__init.definition
+ ## test_prog__examples-__MyGame.concerns
+ ## test_prog.concern
+ ## test_prog.concern
+ ## test_prog__examples.concern
+ ## test_prog__examples-.concern
+ ### test_prog__examples-__MyGame__computer_characters.definition
+ #### test_prog__examples-__MyGame__computer_characters.lin
+ ### test_prog__examples-__MyGame__computer_characters_61d.definition
+ ### test_prog__examples-__MyGame__pause_game.definition
+ #### test_prog__examples-__MyGame__pause_game.lin
+ ### test_prog__examples-__MyGame__player_characters.definition
+ #### test_prog__examples-__MyGame__player_characters.lin
+ ### test_prog__examples-__MyGame__player_characters_61d.definition
+ ### test_prog__examples-__MyGame__start_game.definition
+ #### test_prog__examples-__MyGame__start_game.lin
+ ### test_prog__examples-__MyGame__stop_game.definition
+ #### test_prog__examples-__MyGame__stop_game.lin
+
+MPropertyPage computer_characters=
+ # computer_characters=.section
+ ## test_prog__examples-__MyGame__computer_characters_61d.intro
+
+MPropertyPage player_characters=
+ # player_characters=.section
+ ## test_prog__examples-__MyGame__player_characters_61d.intro
+
MGroupPage game
# game.section
## test_prog__game.intro
MPropertyPage computer_characters
# computer_characters.section
## test_prog__game-__Game__computer_characters.intro
+ ## test_prog__game-__Game__computer_characters.concerns
+ ## test_prog.concern
+ ## test_prog.concern
+ ## test_prog__examples.concern
+ ## test_prog__examples-.concern
+ ### test_prog__examples-__MyGame__computer_characters.definition
MPropertyPage pause_game
# pause_game.section
## test_prog__game-__Game__pause_game.intro
+ ## test_prog__game-__Game__pause_game.concerns
+ ## test_prog.concern
+ ## test_prog.concern
+ ## test_prog__examples.concern
+ ## test_prog__examples-.concern
+ ### test_prog__examples-__MyGame__pause_game.definition
MPropertyPage player_characters
# player_characters.section
## test_prog__game-__Game__player_characters.intro
+ ## test_prog__game-__Game__player_characters.concerns
+ ## test_prog.concern
+ ## test_prog.concern
+ ## test_prog__examples.concern
+ ## test_prog__examples-.concern
+ ### test_prog__examples-__MyGame__player_characters.definition
MPropertyPage start_game
# start_game.section
## test_prog__game-__Game__start_game.intro
+ ## test_prog__game-__Game__start_game.concerns
+ ## test_prog.concern
+ ## test_prog.concern
+ ## test_prog__examples.concern
+ ## test_prog__examples-.concern
+ ### test_prog__examples-__MyGame__start_game.definition
MPropertyPage stop_game
# stop_game.section
## test_prog__game-__Game__stop_game.intro
+ ## test_prog__game-__Game__stop_game.concerns
+ ## test_prog.concern
+ ## test_prog.concern
+ ## test_prog__examples.concern
+ ## test_prog__examples-.concern
+ ### test_prog__examples-__MyGame__stop_game.definition
MGroupPage platform
# platform.section
#### test_prog__rpg__rpg.imports
#### test_prog__rpg__rpg.clients
-Generated 99 pages
+Generated 105 pages
list:
- MPropertyPage: 58 (58.58%)
- MClassPage: 20 (20.20%)
- MModulePage: 9 (9.09%)
- ReadmePage: 5 (5.05%)
- MGroupPage: 5 (5.05%)
- SearchPage: 1 (1.01%)
- OverviewPage: 1 (1.01%)
-Found 185 mentities
+ MPropertyPage: 60 (57.14%)
+ MClassPage: 21 (20.00%)
+ MModulePage: 10 (9.52%)
+ ReadmePage: 6 (5.71%)
+ MGroupPage: 6 (5.71%)
+ SearchPage: 1 (0.95%)
+ OverviewPage: 1 (0.95%)
+Found 198 mentities
list:
- MMethodDef: 68 (36.75%)
- MMethod: 57 (30.81%)
- MClassDef: 22 (11.89%)
- MClass: 20 (10.81%)
- MModule: 9 (4.86%)
- MGroup: 5 (2.70%)
- MPackage: 2 (1.08%)
- MVirtualTypeDef: 1 (0.54%)
- MVirtualTypeProp: 1 (0.54%)
+ MMethodDef: 75 (37.87%)
+ MMethod: 59 (29.79%)
+ MClassDef: 23 (11.61%)
+ MClass: 21 (10.60%)
+ MModule: 10 (5.05%)
+ MGroup: 6 (3.03%)
+ MPackage: 2 (1.01%)
+ MVirtualTypeDef: 1 (0.50%)
+ MVirtualTypeProp: 1 (0.50%)
quicksearch-list.js
test_prog: Test program for model tools. (test_prog)
+|--examples (test_prog/examples)
+| `--\e[1mgame_examples\e[m (test_prog/examples/game_examples.nit)
|--game: Gaming group (test_prog/game)
| `--\e[1mgame\e[m: A game abstraction for RPG. (test_prog/game/game.nit)
|--platform: Fictive Crappy Platform. (test_prog/platform)
-total_strengh has 2 lines
-total_endurance has 2 lines
-total_intelligence has 2 lines
-Large class: 6 attributes and 18 methods (5.414A 7.161M Average)
+Large class: 6 attributes and 18 methods (4.581A 7.153M Average)
model: mpackages=1 mmodules=5
mb: identified modules=5; parsed modules=0
parse found 2 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=6
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=6
parse_full found 5 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=6
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=6
module test_prog::test_prog at test_prog/test_prog.nit
test_prog::test_prog: group?
nothing
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
test_prog/: module?
module test_prog::test_prog at test_prog/test_prog.nit
test_prog/: group?
group test_prog> at test_prog
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
-scan_full found 18 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
+scan_full found 20 modules
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
parse found 1 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=8
-parse_full found 8 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=8
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=8
+parse_full found 9 modules
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=9
module test_prog::races at test_prog/rpg/races.nit
test_prog::races: group?
nothing
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
test_prog::races:rpg: module?
Error: cannot find module `test_prog::races:rpg`. Did you mean test_prog::races?
test_prog::races:rpg: group?
nothing
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
test_prog::races::combat: module?
Error: cannot find module `test_prog::races::combat`. Did you mean test_prog::combat?
test_prog::races::combat: group?
nothing
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
scan_full found 1 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
parse found 1 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=2
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=2
parse_full found 1 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=2
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=2
Error: cannot find module `test_prog::fail::races`. Did you mean test_prog::races?
test_prog::fail::races: group?
nothing
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
test_prog::fail: module?
Error: cannot find module `test_prog::fail`. Did you mean test_prog::game?
test_prog::fail: group?
nothing
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
fail::fail: module?
nothing
fail::fail: group?
nothing
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
scan_full found 0 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
parse found 0 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
parse_full found 0 modules
- model: mpackages=2 mmodules=9
- mb: identified modules=9; parsed modules=0
+ model: mpackages=2 mmodules=10
+ mb: identified modules=10; parsed modules=0
# elfves
* 4: Elf (test_prog::Elf)
- * 5: Float (test_prog::Float)
- * 5: Race (test_prog::Race)
+ * 5: Sys (test_prog::Sys)
* 5: careers (test_prog::careers)
+ * 5: examples (test_prog>examples>)
* 5: excluded (excluded>)
* 5: excluded (excluded::excluded)
* 5: excluded (excluded)
- * 5: game (test_prog>game>)
* 5: game (test_prog::game)
+ * 5: game (test_prog>game>)
* 4: races (test_prog::races)
# Dwarves
- * 13: List (test_prog::List)
+ * 13: Int (test_prog::Int)
* 12: Sys (test_prog::Sys)
* 8: excluded (excluded>)
* 7: excluded (excluded)
# Obj
- * 3: * (test_prog::Float::*)
- * 3: / (test_prog::Int::/)
- * 3: == (test_prog::Object::==)
+ * 3: + (test_prog::Int::+)
+ * 3: - (test_prog::Int::-)
+ * 3: > (test_prog::Int::>)
* 3: Elf (test_prog::Elf)
* 3: Int (test_prog::Int)
* 1: Object (test_prog::Object)
* 3: Sys (test_prog::Sys)
* 3: age (test_prog::Character::age)
- * 3: rpg (test_prog>rpg>)
* 3: rpg (test_prog::rpg)
+ * 3: rpg (test_prog>rpg>)
* 8: excluded (excluded)
* 14: game (test_prog>game>)
* 14: game (test_prog::game)
- * 14: rpg (test_prog::rpg)
* 14: rpg (test_prog>rpg>)
+ * 14: rpg (test_prog::rpg)
* 10: test_prog (test_prog>)
* 9: test_prog (test_prog)
# Foo
* 3: != (test_prog::Object::!=)
- * 3: + (test_prog::Int::+)
+ * 3: == (test_prog::Object::==)
+ * 3: > (test_prog::Int::>)
* 2: Bool (test_prog::Bool)
* 3: Elf (test_prog::Elf)
* 3: Float (test_prog::Float)
* 3: Int (test_prog::Int)
* 3: Sys (test_prog::Sys)
- * 3: dps (test_prog::Weapon::dps)
* 3: rpg (test_prog::rpg)
* 3: rpg (test_prog>rpg>)
# e
- * 2: endurance_bonus (test_prog::Career::endurance_bonus)
- * 1: excluded (excluded>)
+ * 3: endurance_bonus (test_prog::Career::endurance_bonus)
+ * 2: examples (test_prog>examples>)
* 1: excluded (excluded::excluded)
+ * 1: excluded (excluded>)
* 1: excluded (excluded)
- * 3: endurance_bonus= (test_prog::Career::endurance_bonus=)
+ * 4: endurance_bonus= (test_prog::Career::endurance_bonus=)
# A
- * 1: * (test_prog::Int::*)
* 1: * (test_prog::Float::*)
+ * 1: * (test_prog::Int::*)
* 1: + (test_prog::Int::+)
* 1: + (test_prog::Float::+)
* 1: - (test_prog::Int::-)
# Foo
- * 3: * (test_prog::Int::*)
- * 3: / (test_prog::Int::/)
+ * 3: + (test_prog::Int::+)
+ * 3: + (test_prog::Float::+)
* 2: Bool (test_prog::Bool)
* 3: Elf (test_prog::Elf)
* 3: Float (test_prog::Float)
* 3: Int (test_prog::Int)
* 3: Sys (test_prog::Sys)
+ * 3: age (test_prog::Character::age)
* 3: rpg (test_prog::rpg)
* 3: rpg (test_prog>rpg>)
- * 3: sex (test_prog::Character::sex)
excluded test_prog
# mmodules:
-careers character combat excluded game platform races rpg test_prog
+careers character combat excluded game game_examples platform races rpg test_prog
------------------------------------
-careers character combat excluded game platform races rpg test_prog
+careers character combat excluded game game_examples platform races rpg test_prog
# mclasses:
Alcoholic Bool Career Character Combatable Dwarf Elf Float Game Human Int List Magician Object Race Starter String Sys Warrior Weapon
test_prog/
|--test_prog/README.md
+|--test_prog/examples
+| `--test_prog/examples/game_examples.nit
|--test_prog/game
| |--test_prog/game/README.md
| |--test_prog/game/excluded.nit
--- /dev/null
+# 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.
+
+module game_examples is example
+
+import game
+
+# This is an example of how to implement the Game interface
+class MyGame
+ super Game
+
+ redef var player_characters = new List[Character]
+
+ redef var computer_characters = new List[Character]
+
+ redef fun start_game do end
+
+ redef fun pause_game do end
+
+ redef fun stop_game do end
+end