Merge: annotations: introduce `example` annotation
authorJean Privat <jean@pryen.org>
Mon, 4 Dec 2017 14:07:40 +0000 (09:07 -0500)
committerJean Privat <jean@pryen.org>
Mon, 4 Dec 2017 14:07:40 +0000 (09:07 -0500)
## Motivations

When looking at the nit libraries, it's not rare to find external files used only to store examples that cannot be expressed as docunit.

The `example` annotation aims at tag pieces of code that may be considered as examples and thus be:
1. ignored be the compilation tools
2. used by documentation tools (and testing tools)

## Why a new annotation?

Rather than the `examples/` folder convention?

1. Examples can now be included directly in the module code if needed
2. Makes it easier to separate real code example from helper code and example tests
3. More flexibility in project organization and namming
4. To be coherent with the `test` annotation

## How to use it?

Simply tag the MEntity with `example`:

~~~nit
module my_example_module is example
~~~

Can also be applied on classes and methods:

~~~nit
module my_module # is not example

# Abstract class A, we should provide an example of subclass...
# So let's see `ExampleA`.
abstract class A
end

# This class provides an example of how to sublass A.
class ExampleA is example
   super A
end

class C
    # This method provides an example of how to instantiate `A` sublcasses
    fun example_init_a is example do
        var a: A = new ExampleA
    end
end
~~~

## Incoming work

This PR only introduces the annotation and applies it to the existing source code.

Next PR will make tools like nitweb, nitdoc and nitx use it (via commands #2580).

Pull-Request: #2581
Reviewed-by: Alexandre Blondin Massé <alexandre.blondin.masse@gmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>

122 files changed:
contrib/jwrapper/examples/java_api/api_user.nit
contrib/jwrapper/examples/queue/user_test.nit
contrib/nitcc/examples/calc.nit
contrib/nitcc/examples/minilang.nit
contrib/shibuqam/examples/reloadgame.nit
contrib/shibuqam/examples/shibuqamoauth.nit
contrib/wiringPi/examples/blink.nit
contrib/wiringPi/examples/read.nit
contrib/wiringPi/examples/shift.nit
examples/circular_list.nit
examples/fibonacci.nit
examples/int_stack.nit
examples/procedural_array.nit
lib/actors/examples/agent_simulation/agent_simulation.nit
lib/actors/examples/agent_simulation/simple_simulation.nit
lib/actors/examples/chameneos-redux/chameneosredux.nit
lib/actors/examples/fannkuchredux/fannkuchredux.nit
lib/actors/examples/mandelbrot/mandelbrot.nit
lib/actors/examples/simple/simple.nit
lib/actors/examples/thread-ring/thread_ring.nit
lib/ai/examples/puzzle.nit
lib/ai/examples/queens.nit
lib/android/examples/src/ui_test.nit
lib/app/examples/http_request_example.nit
lib/app/examples/ui_example.nit
lib/bcm2835/examples/blink.nit
lib/bcm2835/examples/input.nit
lib/cocoa/examples/cocoa_extern_types.nit
lib/cocoa/examples/cocoa_message_box.nit
lib/cocoa/examples/hello_cocoa.nit
lib/core/core.nit
lib/crapto/examples/repeating_key_xor_solve.nit
lib/curl/examples/curl_http.nit
lib/dom/examples/checker.nit
lib/dot/examples/clusters.nit
lib/dot/examples/hello.nit
lib/dot/examples/undirected_clusters.nit
lib/gamnit/examples/fonts_showcase/src/fonts_showcase.nit
lib/gamnit/examples/template/src/template.nit
lib/gamnit/examples/triangle/src/portable_triangle.nit
lib/gamnit/examples/triangle/src/standalone_triangle.nit
lib/gettext/examples/langannot.nit
lib/glesv2/examples/opengles2_hello_triangle.nit
lib/html/examples/html_page.nit
lib/ios/examples/hello_ios.nit
lib/mpi/examples/src/mpi_simple.nit
lib/nitcorn/examples/src/htcpcp_server.nit
lib/nitcorn/examples/src/nitcorn_hello_world.nit
lib/nitcorn/examples/src/nitcorn_reverse_proxy.nit
lib/nitcorn/examples/src/restful_annot.nit
lib/nitcorn/examples/src/simple_file_server.nit
lib/nitcorn/examples/src/test_restful_annot.nit
lib/pnacl/examples/converter/converter.nit
lib/popcorn/examples/angular/example_angular.nit
lib/popcorn/examples/handlers/example_post_handler.nit
lib/popcorn/examples/handlers/example_query_string.nit
lib/popcorn/examples/hello_world/example_hello.nit
lib/popcorn/examples/middlewares/example_advanced_logger.nit
lib/popcorn/examples/middlewares/example_html_error_handler.nit
lib/popcorn/examples/middlewares/example_simple_logger.nit
lib/popcorn/examples/mongodb/example_mongodb.nit
lib/popcorn/examples/routing/example_glob_route.nit
lib/popcorn/examples/routing/example_param_route.nit
lib/popcorn/examples/routing/example_router.nit
lib/popcorn/examples/sessions/example_session.nit
lib/popcorn/examples/static_files/example_static.nit
lib/popcorn/examples/static_files/example_static_default.nit
lib/popcorn/examples/static_files/example_static_multiple.nit
lib/popcorn/examples/templates/example_templates.nit
lib/privileges/examples/drop_privileges.nit
lib/pthreads/examples/concurrent_array_and_barrier.nit
lib/pthreads/examples/jointask_example.nit
lib/pthreads/examples/threaded_example.nit
lib/pthreads/examples/threadpool_example.nit
lib/sdl2/examples/minimal/src/minimal.nit
lib/serialization/examples/custom_serialization.nit
lib/template/examples/tmpl_composer.nit
lib/vsm/.vsm.nit.swn [new file with mode: 0644]
lib/websocket/examples/websocket_server.nit
src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res
src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res
src/doc/commands/tests/test_commands_model.nit
src/doc/commands/tests/test_commands_parser.nit
src/examples/get_mclasses.nit
src/examples/nitlight_as_a_service.nit
src/examples/nitwebcrawl.nit
src/examples/test_loader.nit
src/frontend/check_annotation.nit
src/frontend/parse_examples.nit [new file with mode: 0644]
src/frontend/tests/test_examples.nit [new file with mode: 0644]
src/frontend/tests/test_examples.sav/test_model_examples.res [new file with mode: 0644]
src/model/model_collect.nit
src/model/model_examples.nit [new file with mode: 0644]
src/model/model_filters.nit
src/model/model_visitor.nit
src/model/test_model_json.sav/test_classdefs_to_full_json.res
src/model/test_model_json.sav/test_classes_to_full_json.res
src/model/test_model_json.sav/test_groups_to_full_json.res
src/model/test_model_json.sav/test_modules_to_full_json.res
src/model/test_model_json.sav/test_packages_to_full_json.res
src/model/test_model_json.sav/test_propdefs_to_full_json.res
src/model/test_model_json.sav/test_props_to_full_json.res
src/model/test_model_json.sav/test_refs_to_full_json.res
tests/sav/nitcatalog_args1.res
tests/sav/nitdoc_args4.res
tests/sav/nitls_args7.res
tests/sav/nitsmells_args1.res
tests/sav/test_loader_args1.res
tests/sav/test_loader_args2.res
tests/sav/test_loader_args3.res
tests/sav/test_loader_args4.res
tests/sav/test_model_index_args10.res
tests/sav/test_model_index_args11.res
tests/sav/test_model_index_args13.res
tests/sav/test_model_index_args16.res
tests/sav/test_model_index_args20.res
tests/sav/test_model_index_args3.res
tests/sav/test_model_index_args8.res
tests/sav/test_model_index_args9.res
tests/sav/test_neo_args1.res
tests/sav/test_sort_perf_args1.res
tests/test_prog/examples/game_examples.nit [new file with mode: 0644]

index a06bf95..f313c40 100644 (file)
@@ -12,7 +12,7 @@
 # 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)
index 882a4d4..c963dc2 100644 (file)
@@ -12,6 +12,8 @@
 # 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
index d444f2c..924fab4 100644 (file)
@@ -14,7 +14,7 @@
 
 # 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
index 29ea62e..3d587b3 100644 (file)
@@ -1,3 +1,5 @@
+module minilang is example
+
 import minilang_test_parser
 
 # An naive recursive stack-based interpreter of the minilang language.
index 24eecf5..6fc3169 100644 (file)
@@ -13,7 +13,7 @@
 # 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
index 326f0bf..ae971c3 100644 (file)
 # * 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
index b14ded6..399f4f6 100644 (file)
@@ -13,6 +13,9 @@
 # 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
index 1ea366f..568b2fb 100644 (file)
@@ -13,6 +13,9 @@
 # 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
index 4038d28..abb474f 100644 (file)
@@ -13,6 +13,9 @@
 # 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
index 2d1df4a..41d2e05 100644 (file)
@@ -14,7 +14,7 @@
 
 # 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]
index 66cbfb0..50b93be 100644 (file)
@@ -15,7 +15,7 @@
 # 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.
index eb2d9b3..1de6752 100644 (file)
@@ -15,7 +15,7 @@
 # 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
index 5f88218..e7f9ce3 100644 (file)
@@ -16,7 +16,7 @@
 
 # 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.
index 35fe57c..e4e08cb 100644 (file)
@@ -13,7 +13,7 @@
 # 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
 
index d8be6c6..ea08535 100644 (file)
@@ -17,7 +17,7 @@
 # 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
 
index 60361a8..4b8ba9f 100644 (file)
@@ -17,7 +17,7 @@
 #
 # 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
 
index 3b24800..42c251c 100644 (file)
@@ -17,7 +17,7 @@
 #
 # 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
 
index e04d4ec..f756970 100644 (file)
@@ -17,7 +17,7 @@
 #
 # 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
 
index 8c98b40..7788240 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # A very simple example of the actor model
-module simple
+module simple is example
 
 import actors
 
index 18da93a..3c227b4 100644 (file)
@@ -17,7 +17,7 @@
 #
 # 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
 
index 0583035..dd85629 100644 (file)
@@ -25,7 +25,7 @@
 #
 # The argument "abcd.fgeh" is the grid
 #
-# ~~~
+# ~~~raw
 # abc
 # d.f
 # geh
@@ -33,7 +33,7 @@
 #
 # The goal is:
 #
-# ~~~
+# ~~~raw
 # abc
 # def
 # gh.
@@ -41,6 +41,8 @@
 #
 # 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.
index 0e86903..2e33ff6 100644 (file)
@@ -28,7 +28,7 @@
 #
 # 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
 
index 4f63a92..c6316ad 100644 (file)
@@ -16,6 +16,7 @@
 
 # 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"
index 3c61498..a121f6c 100644 (file)
@@ -14,6 +14,7 @@
 
 # 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
index 5d01592..8f4f8f1 100644 (file)
@@ -14,6 +14,7 @@
 
 # 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
index 60a59aa..3d3bd82 100644 (file)
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-module blink
+module blink is example
 
 import bcm2835
 
index 8acff6b..889ba51 100644 (file)
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-module input
+module input is example
 
 import bcm2835
 
index 775e6e4..e99f43f 100644 (file)
@@ -15,7 +15,7 @@
 # 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
 
index 4e96768..0f43d9e 100644 (file)
@@ -15,7 +15,7 @@
 # limitations under the License.
 
 # Simple message box using the Cocoa framework
-module cocoa_message_box
+module cocoa_message_box is example
 
 import cocoa
 
index 960b001..56fc059 100644 (file)
@@ -15,7 +15,7 @@
 # limitations under the License.
 
 # Hello world using the Cocoa framework
-module hello_cocoa
+module hello_cocoa is example
 
 import cocoa::foundation
 
index 6eaff6e..97a4271 100644 (file)
 
 # 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
index f88e2d9..82d5652 100644 (file)
@@ -12,6 +12,8 @@
 # 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
 
index 9eed5b8..e4fdf79 100644 (file)
@@ -15,7 +15,7 @@
 # limitations under the License.
 
 # Example use of the Curl module
-module curl_http
+module curl_http is example
 
 import curl
 
index cc3b341..31fc682 100644 (file)
@@ -9,7 +9,7 @@
 # another product.
 
 # Simple XML validity checker using the `dom` module
-module checker
+module checker is example
 
 import dom
 
index 2361e0d..306ec52 100644 (file)
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 # Example from http://www.graphviz.org/content/cluster
+module clusters is example
 
 import dot
 
index 645620e..d4cbfcf 100644 (file)
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 # Example from http://www.graphviz.org/content/hello
+module hello is example
 
 import dot
 
index 4b42567..9ef6e53 100644 (file)
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 # Example from http://www.graphviz.org/Gallery/undirected/fdpclust.html
+module undirected_clusters is example
 
 import dot
 
index 10ba0b4..91f3073 100644 (file)
@@ -7,6 +7,7 @@
 
 # Font support showcase
 module fonts_showcase is
+       example
        app_name "gamnit fonts"
        app_namespace "org.gamnit.fonts_showcase"
        app_version(1, 0, git_revision)
index 8bd28fd..29b9618 100644 (file)
@@ -7,6 +7,7 @@
 
 # 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)
index 21492ad..5c276b3 100644 (file)
@@ -18,6 +18,7 @@
 # * 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)
index 9817d09..a766fb2 100644 (file)
@@ -19,7 +19,7 @@
 # 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
index d278893..07cca24 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # Sample module showing the use of the i18n annotation
-module langannot is i18n
+module langannot is example, i18n
 
 import gettext
 
index da367cf..f85a1fa 100644 (file)
@@ -18,7 +18,7 @@
 #
 # 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
index cf76665..a53f56e 100644 (file)
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module html_page is example
+
 import html
 
 class NitHomepage
index c5d6c8a..c06748e 100644 (file)
@@ -14,6 +14,7 @@
 
 # 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)
index abe289d..cc61f94 100644 (file)
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-module mpi_simple
+module mpi_simple is example
 
 import mpi
 
index 73177a1..d58dcca 100644 (file)
@@ -17,7 +17,7 @@
 # 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
 
index 9eb1662..adcebd2 100644 (file)
@@ -19,7 +19,7 @@
 # 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
 
index 19e02fb..25e1819 100644 (file)
@@ -15,6 +15,7 @@
 # limitations under the License.
 
 # Minimal example using a `ProxyAction`
+module nitcorn_reverse_proxy is example
 
 import nitcorn::proxy
 
index 7b8a407..8a7a225 100644 (file)
@@ -13,7 +13,7 @@
 # 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
index 6613349..b0753fe 100644 (file)
@@ -18,7 +18,7 @@
 #
 # 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
index 8828162..850cce5 100644 (file)
@@ -12,6 +12,8 @@
 # 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
index 69966bd..cda360e 100644 (file)
@@ -21,7 +21,7 @@
 # Creates a converter and initializes it
 # Finally checks for dictionaries
 
-import pnacl
+import pnacl is example
 
 class Converter
        super PnaclApp
index e229a8c..0da9194 100644 (file)
@@ -14,6 +14,9 @@
 # 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
 
index 826c165..d2eb6d3 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_post_handler is example
+
 import popcorn
 import template
 
index e8c6187..0af793c 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_query_string is example
+
 import popcorn
 import template
 
index fc9f3e5..46120bf 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_hello is example
+
 import popcorn
 
 class HelloHandler
index a8ad514..d77725f 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_advanced_logger is example
+
 import popcorn
 import realtime
 
index 5bd399c..d220075 100644 (file)
@@ -14,6 +14,8 @@
 # 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
 
index 73aff4f..354a992 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_simple_logger is example
+
 import popcorn
 
 class SimpleLoggerHandler
index 4f89f5b..b7de4fe 100644 (file)
@@ -14,6 +14,8 @@
 # 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
index b33caec..2704358 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_glob_route is example
+
 import popcorn
 
 class UserItem
index f536771..c4b4b3e 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_param_route is example
+
 import popcorn
 
 class UserHome
index facce99..4027c39 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_router is example
+
 import popcorn
 
 class AppHome
index be79fb1..7bf0a82 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+module example_session is example
+
 import popcorn
 
 redef class Session
index c3da6d0..f44a4c0 100644 (file)
@@ -14,6 +14,8 @@
 # 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
index 6aa5b34..8a7af54 100644 (file)
@@ -14,6 +14,8 @@
 # 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
index 1c730c6..6f925e1 100644 (file)
@@ -14,6 +14,8 @@
 # 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
index bddd3ed..194019a 100644 (file)
@@ -14,6 +14,8 @@
 # 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
 
index a35ca17..016b8da 100644 (file)
@@ -15,7 +15,7 @@
 # limitations under the License.
 
 # Example using the privileges module to drop privileges from root
-module drop_privileges
+module drop_privileges is example
 
 import privileges
 
index 750f976..f32e6c1 100644 (file)
@@ -18,7 +18,7 @@
 #
 # 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
 
index 3d12f6f..b2dd369 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # Simple example of joinable task using threadpool
-module jointask_example
+module jointask_example is example
 
 import threadpool
 
index fb0609b..66b2076 100644 (file)
@@ -15,7 +15,7 @@
 # limitations under the License.
 
 # test for threaded annotation
-module threaded_example
+module threaded_example is example
 
 import pthreads
 
index fec1ae2..6647386 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # Simple example using threadpool
-module threadpool_example
+module threadpool_example is example
 
 import threadpool
 
index 7666c10..534f86a 100644 (file)
@@ -15,7 +15,7 @@
 # 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
 
index 083bcfb..ef95f91 100644 (file)
@@ -29,7 +29,7 @@
 #
 # 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
index 3150c5f..c95fc62 100644 (file)
@@ -12,6 +12,8 @@
 # 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
diff --git a/lib/vsm/.vsm.nit.swn b/lib/vsm/.vsm.nit.swn
new file mode 100644 (file)
index 0000000..4faa9eb
Binary files /dev/null and b/lib/vsm/.vsm.nit.swn differ
index 8b4584c..6b9e3b8 100644 (file)
@@ -15,7 +15,7 @@
 # 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
 
index 6a09f6b..866e31f 100644 (file)
                        "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",
index 95bf855..d84a73b 100644 (file)
                }
        }],
        "page": 1,
-       "count": 106,
+       "count": 113,
        "limit": 10,
-       "max": 10
+       "max": 11
 }
index 9cdfc96..246d882 100644 (file)
@@ -169,7 +169,7 @@ class TestCommandsModel
                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
index e58a157..1a18188 100644 (file)
@@ -71,7 +71,7 @@ class TestCommandsParser
                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
@@ -79,8 +79,7 @@ class TestCommandsParser
                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
index 79e22ba..d1887ba 100644 (file)
@@ -19,7 +19,7 @@
 # ~~~raw
 # get_mclasses ../../lib core::Array Array care::Arrow Fail
 # ~~~
-module get_mclasses
+module get_mclasses is example
 
 import parser_util
 import modelbuilder
index 85f6c7e..da179be 100644 (file)
@@ -15,7 +15,7 @@
 # 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
index 8199c16..767e64c 100644 (file)
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # Crawler on the nitweb web API
-module nitwebcrawl
+module nitwebcrawl is example
 
 import json::static
 
index e81a0af..2f7e3cf 100644 (file)
@@ -15,7 +15,7 @@
 # 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
 
index 3dd8042..b002d16 100644 (file)
@@ -104,6 +104,13 @@ ldflags
 light_ffi
 
 platform
+
+test
+before
+before_all
+after
+after_all
+example
 """
 
        # Efficient set build from `primtives_annotations_list`
diff --git a/src/frontend/parse_examples.nit b/src/frontend/parse_examples.nit
new file mode 100644 (file)
index 0000000..95d4830
--- /dev/null
@@ -0,0 +1,187 @@
+# 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
diff --git a/src/frontend/tests/test_examples.nit b/src/frontend/tests/test_examples.nit
new file mode 100644 (file)
index 0000000..fbd4803
--- /dev/null
@@ -0,0 +1,63 @@
+# 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
diff --git a/src/frontend/tests/test_examples.sav/test_model_examples.res b/src/frontend/tests/test_examples.sav/test_model_examples.res
new file mode 100644 (file)
index 0000000..de733c8
--- /dev/null
@@ -0,0 +1,33 @@
+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)
index 61d03a0..8da799a 100644 (file)
@@ -568,6 +568,7 @@ redef class MClass
        # 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
@@ -580,6 +581,7 @@ redef class 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
diff --git a/src/model/model_examples.nit b/src/model/model_examples.nit
new file mode 100644 (file)
index 0000000..b0908ed
--- /dev/null
@@ -0,0 +1,117 @@
+# 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
index 4cceddd..740a17a 100644 (file)
@@ -14,7 +14,7 @@
 
 module model_filters
 
-import model
+import model_examples
 
 # A list of filters that can be applied on a MEntity
 #
@@ -49,6 +49,7 @@ class ModelFilter
                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
@@ -155,6 +156,17 @@ class ModelFilter
                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
 
index e5a7409..d733912 100644 (file)
@@ -77,6 +77,7 @@ abstract class ModelVisitor
                        min_visibility = protected_visibility,
                        accept_fictive = false,
                        accept_test = false,
+                       accept_example = false,
                        accept_redef = true,
                        accept_extern = true,
                        accept_attribute = true,
index 96d1691..6a4e795 100644 (file)
        "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",
index 19495e1..79c488c 100644 (file)
        }]
 }
 {
+       "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",
index 3e9fd9f..ee5e331 100644 (file)
@@ -33,6 +33,8 @@
                "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>",
index e0c653a..d117c08 100644 (file)
@@ -1,4 +1,38 @@
 {
+       "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"
        }]
 }
index ef7ced3..ca0a550 100644 (file)
@@ -25,6 +25,8 @@
                "full_name": "test_prog>"
        },
        "mgroups": [{
+               "full_name": "test_prog>examples>"
+       }, {
                "full_name": "test_prog>game>"
        }, {
                "full_name": "test_prog>platform>"
index 426bc6c..e4b178a 100644 (file)
        }
 }
 {
+       "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",
index 6757986..f2b22b3 100644 (file)
        },
        "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",
index 60e70df..b5e00b5 100644 (file)
@@ -2,7 +2,7 @@
        "full_name": "test_prog"
 }
 {
-       "full_name": "excluded::excluded"
+       "full_name": "test_prog::game_examples"
 }
 {
        "full_name": "test_prog::Object"
index dfc03c1..8524fc6 100644 (file)
 <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>
@@ -76,8 +80,8 @@
 </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>
@@ -85,10 +89,10 @@ none<h3>Clients</h3>
 none<h3>Contributors</h3>
 <ul class="box"><li><a href="http:&#47;&#47;www.example.com&#47;~jdoe"><img src="https://secure.gravatar.com/avatar/694ea0904ceaf766c6738166ed89bafb?size=20&amp;default=retro">&nbsp;John Doe</a></li><li><img src="https://secure.gravatar.com/avatar/db3f2909768694ad2bb6409b44627182?size=20&amp;default=retro">&nbsp;Riri</li><li>Fifi (http:&#47;&#47;www.example.com&#47;~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 -->
index 9238b51..9fdb265 100644 (file)
@@ -1,5 +1,6 @@
+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
@@ -33,6 +34,8 @@ ReadmePage excluded
 ReadmePage test_prog
        # mdarticle-0
 
+ReadmePage examples
+
 ReadmePage game
        # mdarticle-0
 
@@ -126,6 +129,78 @@ MPropertyPage main
        # 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
@@ -186,22 +261,52 @@ MClassPage Game
 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
@@ -1034,24 +1139,24 @@ MModulePage rpg
                                #### 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
index a0a686e..9a0889d 100644 (file)
@@ -1,4 +1,6 @@
 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)
index 439a213..109e74a 100644 (file)
@@ -7,4 +7,4 @@ Long method:  Average 1 lines
                -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)
index 1b169e2..c237e27 100644 (file)
@@ -14,8 +14,8 @@ scan_full found 6 modules
   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
index 5b3c4f0..4650fe7 100644 (file)
@@ -22,20 +22,20 @@ test_prog::test_prog: module?
        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
index 940b6bf..fea9069 100644 (file)
@@ -6,26 +6,26 @@ test_prog::races: module?
        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
index 74dfacb..4c9789a 100644 (file)
@@ -8,26 +8,26 @@ test_prog::fail::races: module?
        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
index 982c125..cfee574 100644 (file)
@@ -1,12 +1,12 @@
 # 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)
index 510eaba..f969724 100644 (file)
@@ -1,6 +1,6 @@
 # Dwarves
 
- * 13: List (test_prog::List)
+ * 13: Int (test_prog::Int)
  * 12: Sys (test_prog::Sys)
  * 8: excluded (excluded>)
  * 7: excluded (excluded)
index cb5e115..000025b 100644 (file)
@@ -1,12 +1,12 @@
 # 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>)
index 998a270..fc68d39 100644 (file)
@@ -6,7 +6,7 @@
  * 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)
index 1e858ea..dd17043 100644 (file)
@@ -1,12 +1,12 @@
 # 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>)
index c3ac095..758d8df 100644 (file)
@@ -1,7 +1,8 @@
 # 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=)
index fc9d8e2..191fd72 100644 (file)
@@ -1,7 +1,7 @@
 # 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::-)
index bb6e9e1..a4c370f 100644 (file)
@@ -1,12 +1,12 @@
 # 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)
index fdc3be7..e907ec7 100644 (file)
@@ -4,9 +4,9 @@ excluded test_prog
 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
index b1fe714..ab1d9c6 100644 (file)
@@ -1,5 +1,7 @@
 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
diff --git a/tests/test_prog/examples/game_examples.nit b/tests/test_prog/examples/game_examples.nit
new file mode 100644 (file)
index 0000000..68b16de
--- /dev/null
@@ -0,0 +1,32 @@
+# 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