From: Jean Privat Date: Mon, 4 Dec 2017 14:07:40 +0000 (-0500) Subject: Merge: annotations: introduce `example` annotation X-Git-Url: http://nitlanguage.org?hp=67411050dfd1ce8039b7dc2afb4b26c1de7ec149 Merge: annotations: introduce `example` annotation ## 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é Reviewed-by: Jean Privat --- diff --git a/contrib/jwrapper/examples/java_api/api_user.nit b/contrib/jwrapper/examples/java_api/api_user.nit index a06bf95..f313c40 100644 --- a/contrib/jwrapper/examples/java_api/api_user.nit +++ b/contrib/jwrapper/examples/java_api/api_user.nit @@ -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) diff --git a/contrib/jwrapper/examples/queue/user_test.nit b/contrib/jwrapper/examples/queue/user_test.nit index 882a4d4..c963dc2 100644 --- a/contrib/jwrapper/examples/queue/user_test.nit +++ b/contrib/jwrapper/examples/queue/user_test.nit @@ -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 diff --git a/contrib/nitcc/examples/calc.nit b/contrib/nitcc/examples/calc.nit index d444f2c..924fab4 100644 --- a/contrib/nitcc/examples/calc.nit +++ b/contrib/nitcc/examples/calc.nit @@ -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 diff --git a/contrib/nitcc/examples/minilang.nit b/contrib/nitcc/examples/minilang.nit index 29ea62e..3d587b3 100644 --- a/contrib/nitcc/examples/minilang.nit +++ b/contrib/nitcc/examples/minilang.nit @@ -1,3 +1,5 @@ +module minilang is example + import minilang_test_parser # An naive recursive stack-based interpreter of the minilang language. diff --git a/contrib/shibuqam/examples/reloadgame.nit b/contrib/shibuqam/examples/reloadgame.nit index 24eecf5..6fc3169 100644 --- a/contrib/shibuqam/examples/reloadgame.nit +++ b/contrib/shibuqam/examples/reloadgame.nit @@ -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 diff --git a/contrib/shibuqam/examples/shibuqamoauth.nit b/contrib/shibuqam/examples/shibuqamoauth.nit index 326f0bf..ae971c3 100644 --- a/contrib/shibuqam/examples/shibuqamoauth.nit +++ b/contrib/shibuqam/examples/shibuqamoauth.nit @@ -168,7 +168,7 @@ # * 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 diff --git a/contrib/wiringPi/examples/blink.nit b/contrib/wiringPi/examples/blink.nit index b14ded6..399f4f6 100644 --- a/contrib/wiringPi/examples/blink.nit +++ b/contrib/wiringPi/examples/blink.nit @@ -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 diff --git a/contrib/wiringPi/examples/read.nit b/contrib/wiringPi/examples/read.nit index 1ea366f..568b2fb 100644 --- a/contrib/wiringPi/examples/read.nit +++ b/contrib/wiringPi/examples/read.nit @@ -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 diff --git a/contrib/wiringPi/examples/shift.nit b/contrib/wiringPi/examples/shift.nit index 4038d28..abb474f 100644 --- a/contrib/wiringPi/examples/shift.nit +++ b/contrib/wiringPi/examples/shift.nit @@ -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 diff --git a/examples/circular_list.nit b/examples/circular_list.nit index 2d1df4a..41d2e05 100644 --- a/examples/circular_list.nit +++ b/examples/circular_list.nit @@ -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] diff --git a/examples/fibonacci.nit b/examples/fibonacci.nit index 66cbfb0..50b93be 100644 --- a/examples/fibonacci.nit +++ b/examples/fibonacci.nit @@ -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. diff --git a/examples/int_stack.nit b/examples/int_stack.nit index eb2d9b3..1de6752 100644 --- a/examples/int_stack.nit +++ b/examples/int_stack.nit @@ -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 diff --git a/examples/procedural_array.nit b/examples/procedural_array.nit index 5f88218..e7f9ce3 100644 --- a/examples/procedural_array.nit +++ b/examples/procedural_array.nit @@ -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. diff --git a/lib/actors/examples/agent_simulation/agent_simulation.nit b/lib/actors/examples/agent_simulation/agent_simulation.nit index 35fe57c..e4e08cb 100644 --- a/lib/actors/examples/agent_simulation/agent_simulation.nit +++ b/lib/actors/examples/agent_simulation/agent_simulation.nit @@ -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 diff --git a/lib/actors/examples/agent_simulation/simple_simulation.nit b/lib/actors/examples/agent_simulation/simple_simulation.nit index d8be6c6..ea08535 100644 --- a/lib/actors/examples/agent_simulation/simple_simulation.nit +++ b/lib/actors/examples/agent_simulation/simple_simulation.nit @@ -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 diff --git a/lib/actors/examples/chameneos-redux/chameneosredux.nit b/lib/actors/examples/chameneos-redux/chameneosredux.nit index 60361a8..4b8ba9f 100644 --- a/lib/actors/examples/chameneos-redux/chameneosredux.nit +++ b/lib/actors/examples/chameneos-redux/chameneosredux.nit @@ -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 diff --git a/lib/actors/examples/fannkuchredux/fannkuchredux.nit b/lib/actors/examples/fannkuchredux/fannkuchredux.nit index 3b24800..42c251c 100644 --- a/lib/actors/examples/fannkuchredux/fannkuchredux.nit +++ b/lib/actors/examples/fannkuchredux/fannkuchredux.nit @@ -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 diff --git a/lib/actors/examples/mandelbrot/mandelbrot.nit b/lib/actors/examples/mandelbrot/mandelbrot.nit index e04d4ec..f756970 100644 --- a/lib/actors/examples/mandelbrot/mandelbrot.nit +++ b/lib/actors/examples/mandelbrot/mandelbrot.nit @@ -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 diff --git a/lib/actors/examples/simple/simple.nit b/lib/actors/examples/simple/simple.nit index 8c98b40..7788240 100644 --- a/lib/actors/examples/simple/simple.nit +++ b/lib/actors/examples/simple/simple.nit @@ -13,7 +13,7 @@ # limitations under the License. # A very simple example of the actor model -module simple +module simple is example import actors diff --git a/lib/actors/examples/thread-ring/thread_ring.nit b/lib/actors/examples/thread-ring/thread_ring.nit index 18da93a..3c227b4 100644 --- a/lib/actors/examples/thread-ring/thread_ring.nit +++ b/lib/actors/examples/thread-ring/thread_ring.nit @@ -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 diff --git a/lib/ai/examples/puzzle.nit b/lib/ai/examples/puzzle.nit index 0583035..dd85629 100644 --- a/lib/ai/examples/puzzle.nit +++ b/lib/ai/examples/puzzle.nit @@ -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. diff --git a/lib/ai/examples/queens.nit b/lib/ai/examples/queens.nit index 0e86903..2e33ff6 100644 --- a/lib/ai/examples/queens.nit +++ b/lib/ai/examples/queens.nit @@ -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 diff --git a/lib/android/examples/src/ui_test.nit b/lib/android/examples/src/ui_test.nit index 4f63a92..c6316ad 100644 --- a/lib/android/examples/src/ui_test.nit +++ b/lib/android/examples/src/ui_test.nit @@ -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" diff --git a/lib/app/examples/http_request_example.nit b/lib/app/examples/http_request_example.nit index 3c61498..a121f6c 100644 --- a/lib/app/examples/http_request_example.nit +++ b/lib/app/examples/http_request_example.nit @@ -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 diff --git a/lib/app/examples/ui_example.nit b/lib/app/examples/ui_example.nit index 5d01592..8f4f8f1 100644 --- a/lib/app/examples/ui_example.nit +++ b/lib/app/examples/ui_example.nit @@ -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 diff --git a/lib/bcm2835/examples/blink.nit b/lib/bcm2835/examples/blink.nit index 60a59aa..3d3bd82 100644 --- a/lib/bcm2835/examples/blink.nit +++ b/lib/bcm2835/examples/blink.nit @@ -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 diff --git a/lib/bcm2835/examples/input.nit b/lib/bcm2835/examples/input.nit index 8acff6b..889ba51 100644 --- a/lib/bcm2835/examples/input.nit +++ b/lib/bcm2835/examples/input.nit @@ -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 diff --git a/lib/cocoa/examples/cocoa_extern_types.nit b/lib/cocoa/examples/cocoa_extern_types.nit index 775e6e4..e99f43f 100644 --- a/lib/cocoa/examples/cocoa_extern_types.nit +++ b/lib/cocoa/examples/cocoa_extern_types.nit @@ -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 diff --git a/lib/cocoa/examples/cocoa_message_box.nit b/lib/cocoa/examples/cocoa_message_box.nit index 4e96768..0f43d9e 100644 --- a/lib/cocoa/examples/cocoa_message_box.nit +++ b/lib/cocoa/examples/cocoa_message_box.nit @@ -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 diff --git a/lib/cocoa/examples/hello_cocoa.nit b/lib/cocoa/examples/hello_cocoa.nit index 960b001..56fc059 100644 --- a/lib/cocoa/examples/hello_cocoa.nit +++ b/lib/cocoa/examples/hello_cocoa.nit @@ -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 diff --git a/lib/core/core.nit b/lib/core/core.nit index 6eaff6e..97a4271 100644 --- a/lib/core/core.nit +++ b/lib/core/core.nit @@ -13,13 +13,7 @@ # 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 diff --git a/lib/crapto/examples/repeating_key_xor_solve.nit b/lib/crapto/examples/repeating_key_xor_solve.nit index f88e2d9..82d5652 100644 --- a/lib/crapto/examples/repeating_key_xor_solve.nit +++ b/lib/crapto/examples/repeating_key_xor_solve.nit @@ -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 diff --git a/lib/curl/examples/curl_http.nit b/lib/curl/examples/curl_http.nit index 9eed5b8..e4fdf79 100644 --- a/lib/curl/examples/curl_http.nit +++ b/lib/curl/examples/curl_http.nit @@ -15,7 +15,7 @@ # limitations under the License. # Example use of the Curl module -module curl_http +module curl_http is example import curl diff --git a/lib/dom/examples/checker.nit b/lib/dom/examples/checker.nit index cc3b341..31fc682 100644 --- a/lib/dom/examples/checker.nit +++ b/lib/dom/examples/checker.nit @@ -9,7 +9,7 @@ # another product. # Simple XML validity checker using the `dom` module -module checker +module checker is example import dom diff --git a/lib/dot/examples/clusters.nit b/lib/dot/examples/clusters.nit index 2361e0d..306ec52 100644 --- a/lib/dot/examples/clusters.nit +++ b/lib/dot/examples/clusters.nit @@ -13,6 +13,7 @@ # limitations under the License. # Example from http://www.graphviz.org/content/cluster +module clusters is example import dot diff --git a/lib/dot/examples/hello.nit b/lib/dot/examples/hello.nit index 645620e..d4cbfcf 100644 --- a/lib/dot/examples/hello.nit +++ b/lib/dot/examples/hello.nit @@ -13,6 +13,7 @@ # limitations under the License. # Example from http://www.graphviz.org/content/hello +module hello is example import dot diff --git a/lib/dot/examples/undirected_clusters.nit b/lib/dot/examples/undirected_clusters.nit index 4b42567..9ef6e53 100644 --- a/lib/dot/examples/undirected_clusters.nit +++ b/lib/dot/examples/undirected_clusters.nit @@ -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 diff --git a/lib/gamnit/examples/fonts_showcase/src/fonts_showcase.nit b/lib/gamnit/examples/fonts_showcase/src/fonts_showcase.nit index 10ba0b4..91f3073 100644 --- a/lib/gamnit/examples/fonts_showcase/src/fonts_showcase.nit +++ b/lib/gamnit/examples/fonts_showcase/src/fonts_showcase.nit @@ -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) diff --git a/lib/gamnit/examples/template/src/template.nit b/lib/gamnit/examples/template/src/template.nit index 8bd28fd..29b9618 100644 --- a/lib/gamnit/examples/template/src/template.nit +++ b/lib/gamnit/examples/template/src/template.nit @@ -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) diff --git a/lib/gamnit/examples/triangle/src/portable_triangle.nit b/lib/gamnit/examples/triangle/src/portable_triangle.nit index 21492ad..5c276b3 100644 --- a/lib/gamnit/examples/triangle/src/portable_triangle.nit +++ b/lib/gamnit/examples/triangle/src/portable_triangle.nit @@ -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) diff --git a/lib/gamnit/examples/triangle/src/standalone_triangle.nit b/lib/gamnit/examples/triangle/src/standalone_triangle.nit index 9817d09..a766fb2 100644 --- a/lib/gamnit/examples/triangle/src/standalone_triangle.nit +++ b/lib/gamnit/examples/triangle/src/standalone_triangle.nit @@ -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 diff --git a/lib/gettext/examples/langannot.nit b/lib/gettext/examples/langannot.nit index d278893..07cca24 100644 --- a/lib/gettext/examples/langannot.nit +++ b/lib/gettext/examples/langannot.nit @@ -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 diff --git a/lib/glesv2/examples/opengles2_hello_triangle.nit b/lib/glesv2/examples/opengles2_hello_triangle.nit index da367cf..f85a1fa 100644 --- a/lib/glesv2/examples/opengles2_hello_triangle.nit +++ b/lib/glesv2/examples/opengles2_hello_triangle.nit @@ -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 diff --git a/lib/html/examples/html_page.nit b/lib/html/examples/html_page.nit index cf76665..a53f56e 100644 --- a/lib/html/examples/html_page.nit +++ b/lib/html/examples/html_page.nit @@ -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 diff --git a/lib/ios/examples/hello_ios.nit b/lib/ios/examples/hello_ios.nit index c5d6c8a..c06748e 100644 --- a/lib/ios/examples/hello_ios.nit +++ b/lib/ios/examples/hello_ios.nit @@ -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) diff --git a/lib/mpi/examples/src/mpi_simple.nit b/lib/mpi/examples/src/mpi_simple.nit index abe289d..cc61f94 100644 --- a/lib/mpi/examples/src/mpi_simple.nit +++ b/lib/mpi/examples/src/mpi_simple.nit @@ -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 diff --git a/lib/nitcorn/examples/src/htcpcp_server.nit b/lib/nitcorn/examples/src/htcpcp_server.nit index 73177a1..d58dcca 100644 --- a/lib/nitcorn/examples/src/htcpcp_server.nit +++ b/lib/nitcorn/examples/src/htcpcp_server.nit @@ -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 diff --git a/lib/nitcorn/examples/src/nitcorn_hello_world.nit b/lib/nitcorn/examples/src/nitcorn_hello_world.nit index 9eb1662..adcebd2 100644 --- a/lib/nitcorn/examples/src/nitcorn_hello_world.nit +++ b/lib/nitcorn/examples/src/nitcorn_hello_world.nit @@ -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 diff --git a/lib/nitcorn/examples/src/nitcorn_reverse_proxy.nit b/lib/nitcorn/examples/src/nitcorn_reverse_proxy.nit index 19e02fb..25e1819 100644 --- a/lib/nitcorn/examples/src/nitcorn_reverse_proxy.nit +++ b/lib/nitcorn/examples/src/nitcorn_reverse_proxy.nit @@ -15,6 +15,7 @@ # limitations under the License. # Minimal example using a `ProxyAction` +module nitcorn_reverse_proxy is example import nitcorn::proxy diff --git a/lib/nitcorn/examples/src/restful_annot.nit b/lib/nitcorn/examples/src/restful_annot.nit index 7b8a407..8a7a225 100644 --- a/lib/nitcorn/examples/src/restful_annot.nit +++ b/lib/nitcorn/examples/src/restful_annot.nit @@ -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 diff --git a/lib/nitcorn/examples/src/simple_file_server.nit b/lib/nitcorn/examples/src/simple_file_server.nit index 6613349..b0753fe 100644 --- a/lib/nitcorn/examples/src/simple_file_server.nit +++ b/lib/nitcorn/examples/src/simple_file_server.nit @@ -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 diff --git a/lib/nitcorn/examples/src/test_restful_annot.nit b/lib/nitcorn/examples/src/test_restful_annot.nit index 8828162..850cce5 100644 --- a/lib/nitcorn/examples/src/test_restful_annot.nit +++ b/lib/nitcorn/examples/src/test_restful_annot.nit @@ -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 diff --git a/lib/pnacl/examples/converter/converter.nit b/lib/pnacl/examples/converter/converter.nit index 69966bd..cda360e 100644 --- a/lib/pnacl/examples/converter/converter.nit +++ b/lib/pnacl/examples/converter/converter.nit @@ -21,7 +21,7 @@ # Creates a converter and initializes it # Finally checks for dictionaries -import pnacl +import pnacl is example class Converter super PnaclApp diff --git a/lib/popcorn/examples/angular/example_angular.nit b/lib/popcorn/examples/angular/example_angular.nit index e229a8c..0da9194 100644 --- a/lib/popcorn/examples/angular/example_angular.nit +++ b/lib/popcorn/examples/angular/example_angular.nit @@ -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 diff --git a/lib/popcorn/examples/handlers/example_post_handler.nit b/lib/popcorn/examples/handlers/example_post_handler.nit index 826c165..d2eb6d3 100644 --- a/lib/popcorn/examples/handlers/example_post_handler.nit +++ b/lib/popcorn/examples/handlers/example_post_handler.nit @@ -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 diff --git a/lib/popcorn/examples/handlers/example_query_string.nit b/lib/popcorn/examples/handlers/example_query_string.nit index e8c6187..0af793c 100644 --- a/lib/popcorn/examples/handlers/example_query_string.nit +++ b/lib/popcorn/examples/handlers/example_query_string.nit @@ -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 diff --git a/lib/popcorn/examples/hello_world/example_hello.nit b/lib/popcorn/examples/hello_world/example_hello.nit index fc9f3e5..46120bf 100644 --- a/lib/popcorn/examples/hello_world/example_hello.nit +++ b/lib/popcorn/examples/hello_world/example_hello.nit @@ -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 diff --git a/lib/popcorn/examples/middlewares/example_advanced_logger.nit b/lib/popcorn/examples/middlewares/example_advanced_logger.nit index a8ad514..d77725f 100644 --- a/lib/popcorn/examples/middlewares/example_advanced_logger.nit +++ b/lib/popcorn/examples/middlewares/example_advanced_logger.nit @@ -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 diff --git a/lib/popcorn/examples/middlewares/example_html_error_handler.nit b/lib/popcorn/examples/middlewares/example_html_error_handler.nit index 5bd399c..d220075 100644 --- a/lib/popcorn/examples/middlewares/example_html_error_handler.nit +++ b/lib/popcorn/examples/middlewares/example_html_error_handler.nit @@ -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 diff --git a/lib/popcorn/examples/middlewares/example_simple_logger.nit b/lib/popcorn/examples/middlewares/example_simple_logger.nit index 73aff4f..354a992 100644 --- a/lib/popcorn/examples/middlewares/example_simple_logger.nit +++ b/lib/popcorn/examples/middlewares/example_simple_logger.nit @@ -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 diff --git a/lib/popcorn/examples/mongodb/example_mongodb.nit b/lib/popcorn/examples/mongodb/example_mongodb.nit index 4f89f5b..b7de4fe 100644 --- a/lib/popcorn/examples/mongodb/example_mongodb.nit +++ b/lib/popcorn/examples/mongodb/example_mongodb.nit @@ -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 diff --git a/lib/popcorn/examples/routing/example_glob_route.nit b/lib/popcorn/examples/routing/example_glob_route.nit index b33caec..2704358 100644 --- a/lib/popcorn/examples/routing/example_glob_route.nit +++ b/lib/popcorn/examples/routing/example_glob_route.nit @@ -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 diff --git a/lib/popcorn/examples/routing/example_param_route.nit b/lib/popcorn/examples/routing/example_param_route.nit index f536771..c4b4b3e 100644 --- a/lib/popcorn/examples/routing/example_param_route.nit +++ b/lib/popcorn/examples/routing/example_param_route.nit @@ -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 diff --git a/lib/popcorn/examples/routing/example_router.nit b/lib/popcorn/examples/routing/example_router.nit index facce99..4027c39 100644 --- a/lib/popcorn/examples/routing/example_router.nit +++ b/lib/popcorn/examples/routing/example_router.nit @@ -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 diff --git a/lib/popcorn/examples/sessions/example_session.nit b/lib/popcorn/examples/sessions/example_session.nit index be79fb1..7bf0a82 100644 --- a/lib/popcorn/examples/sessions/example_session.nit +++ b/lib/popcorn/examples/sessions/example_session.nit @@ -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 diff --git a/lib/popcorn/examples/static_files/example_static.nit b/lib/popcorn/examples/static_files/example_static.nit index c3da6d0..f44a4c0 100644 --- a/lib/popcorn/examples/static_files/example_static.nit +++ b/lib/popcorn/examples/static_files/example_static.nit @@ -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 diff --git a/lib/popcorn/examples/static_files/example_static_default.nit b/lib/popcorn/examples/static_files/example_static_default.nit index 6aa5b34..8a7af54 100644 --- a/lib/popcorn/examples/static_files/example_static_default.nit +++ b/lib/popcorn/examples/static_files/example_static_default.nit @@ -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 diff --git a/lib/popcorn/examples/static_files/example_static_multiple.nit b/lib/popcorn/examples/static_files/example_static_multiple.nit index 1c730c6..6f925e1 100644 --- a/lib/popcorn/examples/static_files/example_static_multiple.nit +++ b/lib/popcorn/examples/static_files/example_static_multiple.nit @@ -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 diff --git a/lib/popcorn/examples/templates/example_templates.nit b/lib/popcorn/examples/templates/example_templates.nit index bddd3ed..194019a 100644 --- a/lib/popcorn/examples/templates/example_templates.nit +++ b/lib/popcorn/examples/templates/example_templates.nit @@ -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 diff --git a/lib/privileges/examples/drop_privileges.nit b/lib/privileges/examples/drop_privileges.nit index a35ca17..016b8da 100644 --- a/lib/privileges/examples/drop_privileges.nit +++ b/lib/privileges/examples/drop_privileges.nit @@ -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 diff --git a/lib/pthreads/examples/concurrent_array_and_barrier.nit b/lib/pthreads/examples/concurrent_array_and_barrier.nit index 750f976..f32e6c1 100644 --- a/lib/pthreads/examples/concurrent_array_and_barrier.nit +++ b/lib/pthreads/examples/concurrent_array_and_barrier.nit @@ -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 diff --git a/lib/pthreads/examples/jointask_example.nit b/lib/pthreads/examples/jointask_example.nit index 3d12f6f..b2dd369 100644 --- a/lib/pthreads/examples/jointask_example.nit +++ b/lib/pthreads/examples/jointask_example.nit @@ -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 diff --git a/lib/pthreads/examples/threaded_example.nit b/lib/pthreads/examples/threaded_example.nit index fb0609b..66b2076 100644 --- a/lib/pthreads/examples/threaded_example.nit +++ b/lib/pthreads/examples/threaded_example.nit @@ -15,7 +15,7 @@ # limitations under the License. # test for threaded annotation -module threaded_example +module threaded_example is example import pthreads diff --git a/lib/pthreads/examples/threadpool_example.nit b/lib/pthreads/examples/threadpool_example.nit index fec1ae2..6647386 100644 --- a/lib/pthreads/examples/threadpool_example.nit +++ b/lib/pthreads/examples/threadpool_example.nit @@ -13,7 +13,7 @@ # limitations under the License. # Simple example using threadpool -module threadpool_example +module threadpool_example is example import threadpool diff --git a/lib/sdl2/examples/minimal/src/minimal.nit b/lib/sdl2/examples/minimal/src/minimal.nit index 7666c10..534f86a 100644 --- a/lib/sdl2/examples/minimal/src/minimal.nit +++ b/lib/sdl2/examples/minimal/src/minimal.nit @@ -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 diff --git a/lib/serialization/examples/custom_serialization.nit b/lib/serialization/examples/custom_serialization.nit index 083bcfb..ef95f91 100644 --- a/lib/serialization/examples/custom_serialization.nit +++ b/lib/serialization/examples/custom_serialization.nit @@ -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 diff --git a/lib/template/examples/tmpl_composer.nit b/lib/template/examples/tmpl_composer.nit index 3150c5f..c95fc62 100644 --- a/lib/template/examples/tmpl_composer.nit +++ b/lib/template/examples/tmpl_composer.nit @@ -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 index 0000000..4faa9eb Binary files /dev/null and b/lib/vsm/.vsm.nit.swn differ diff --git a/lib/websocket/examples/websocket_server.nit b/lib/websocket/examples/websocket_server.nit index 8b4584c..6b9e3b8 100644 --- a/lib/websocket/examples/websocket_server.nit +++ b/lib/websocket/examples/websocket_server.nit @@ -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 diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res index 6a09f6b..866e31f 100644 --- a/src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res +++ b/src/doc/commands/tests/test_commands_json.sav/test_cmd_mentities.res @@ -106,6 +106,20 @@ "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", diff --git a/src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res b/src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res index 95bf855..d84a73b 100644 --- a/src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res +++ b/src/doc/commands/tests/test_commands_json.sav/test_cmd_search.res @@ -235,7 +235,7 @@ } }], "page": 1, - "count": 106, + "count": 113, "limit": 10, - "max": 10 + "max": 11 } diff --git a/src/doc/commands/tests/test_commands_model.nit b/src/doc/commands/tests/test_commands_model.nit index 9cdfc96..246d882 100644 --- a/src/doc/commands/tests/test_commands_model.nit +++ b/src/doc/commands/tests/test_commands_model.nit @@ -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 diff --git a/src/doc/commands/tests/test_commands_parser.nit b/src/doc/commands/tests/test_commands_parser.nit index e58a157..1a18188 100644 --- a/src/doc/commands/tests/test_commands_parser.nit +++ b/src/doc/commands/tests/test_commands_parser.nit @@ -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 diff --git a/src/examples/get_mclasses.nit b/src/examples/get_mclasses.nit index 79e22ba..d1887ba 100644 --- a/src/examples/get_mclasses.nit +++ b/src/examples/get_mclasses.nit @@ -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 diff --git a/src/examples/nitlight_as_a_service.nit b/src/examples/nitlight_as_a_service.nit index 85f6c7e..da179be 100644 --- a/src/examples/nitlight_as_a_service.nit +++ b/src/examples/nitlight_as_a_service.nit @@ -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 diff --git a/src/examples/nitwebcrawl.nit b/src/examples/nitwebcrawl.nit index 8199c16..767e64c 100644 --- a/src/examples/nitwebcrawl.nit +++ b/src/examples/nitwebcrawl.nit @@ -13,7 +13,7 @@ # limitations under the License. # Crawler on the nitweb web API -module nitwebcrawl +module nitwebcrawl is example import json::static diff --git a/src/examples/test_loader.nit b/src/examples/test_loader.nit index e81a0af..2f7e3cf 100644 --- a/src/examples/test_loader.nit +++ b/src/examples/test_loader.nit @@ -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 diff --git a/src/frontend/check_annotation.nit b/src/frontend/check_annotation.nit index 3dd8042..b002d16 100644 --- a/src/frontend/check_annotation.nit +++ b/src/frontend/check_annotation.nit @@ -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 index 0000000..95d4830 --- /dev/null +++ b/src/frontend/parse_examples.nit @@ -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 index 0000000..fbd4803 --- /dev/null +++ b/src/frontend/tests/test_examples.nit @@ -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 index 0000000..de733c8 --- /dev/null +++ b/src/frontend/tests/test_examples.sav/test_model_examples.res @@ -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) diff --git a/src/model/model_collect.nit b/src/model/model_collect.nit index 61d03a0..8da799a 100644 --- a/src/model/model_collect.nit +++ b/src/model/model_collect.nit @@ -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 index 0000000..b0908ed --- /dev/null +++ b/src/model/model_examples.nit @@ -0,0 +1,117 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2012 Jean Privat +# +# 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 diff --git a/src/model/model_filters.nit b/src/model/model_filters.nit index 4cceddd..740a17a 100644 --- a/src/model/model_filters.nit +++ b/src/model/model_filters.nit @@ -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 diff --git a/src/model/model_visitor.nit b/src/model/model_visitor.nit index e5a7409..d733912 100644 --- a/src/model/model_visitor.nit +++ b/src/model/model_visitor.nit @@ -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, diff --git a/src/model/test_model_json.sav/test_classdefs_to_full_json.res b/src/model/test_model_json.sav/test_classdefs_to_full_json.res index 96d1691..6a4e795 100644 --- a/src/model/test_model_json.sav/test_classdefs_to_full_json.res +++ b/src/model/test_model_json.sav/test_classdefs_to_full_json.res @@ -1297,6 +1297,92 @@ "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", diff --git a/src/model/test_model_json.sav/test_classes_to_full_json.res b/src/model/test_model_json.sav/test_classes_to_full_json.res index 19495e1..79c488c 100644 --- a/src/model/test_model_json.sav/test_classes_to_full_json.res +++ b/src/model/test_model_json.sav/test_classes_to_full_json.res @@ -1333,6 +1333,83 @@ }] } { + "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", diff --git a/src/model/test_model_json.sav/test_groups_to_full_json.res b/src/model/test_model_json.sav/test_groups_to_full_json.res index 3e9fd9f..ee5e331 100644 --- a/src/model/test_model_json.sav/test_groups_to_full_json.res +++ b/src/model/test_model_json.sav/test_groups_to_full_json.res @@ -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>" @@ -41,6 +43,33 @@ }] } { + "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>", diff --git a/src/model/test_model_json.sav/test_modules_to_full_json.res b/src/model/test_model_json.sav/test_modules_to_full_json.res index e0c653a..d117c08 100644 --- a/src/model/test_model_json.sav/test_modules_to_full_json.res +++ b/src/model/test_model_json.sav/test_modules_to_full_json.res @@ -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", @@ -470,5 +504,7 @@ "redef_mclassdefs": [], "imports": [{ "full_name": "test_prog::test_prog" + }, { + "full_name": "test_prog::game_examples" }] } diff --git a/src/model/test_model_json.sav/test_packages_to_full_json.res b/src/model/test_model_json.sav/test_packages_to_full_json.res index ef7ced3..ca0a550 100644 --- a/src/model/test_model_json.sav/test_packages_to_full_json.res +++ b/src/model/test_model_json.sav/test_packages_to_full_json.res @@ -25,6 +25,8 @@ "full_name": "test_prog>" }, "mgroups": [{ + "full_name": "test_prog>examples>" + }, { "full_name": "test_prog>game>" }, { "full_name": "test_prog>platform>" diff --git a/src/model/test_model_json.sav/test_propdefs_to_full_json.res b/src/model/test_model_json.sav/test_propdefs_to_full_json.res index 426bc6c..e4b178a 100644 --- a/src/model/test_model_json.sav/test_propdefs_to_full_json.res +++ b/src/model/test_model_json.sav/test_propdefs_to_full_json.res @@ -3735,6 +3735,60 @@ } } { + "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", @@ -3789,6 +3843,60 @@ } } { + "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", @@ -3841,6 +3949,58 @@ } } { + "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", @@ -3893,6 +4053,58 @@ } } { + "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", @@ -3945,6 +4157,236 @@ } } { + "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", diff --git a/src/model/test_model_json.sav/test_props_to_full_json.res b/src/model/test_model_json.sav/test_props_to_full_json.res index 6757986..f2b22b3 100644 --- a/src/model/test_model_json.sav/test_props_to_full_json.res +++ b/src/model/test_model_json.sav/test_props_to_full_json.res @@ -2849,6 +2849,8 @@ }, "mpropdefs": [{ "full_name": "test_prog$Game$player_characters" + }, { + "full_name": "test_prog$MyGame$Game::player_characters" }], "intro_mclass": { "full_name": "test_prog::Game" @@ -2897,6 +2899,8 @@ }, "mpropdefs": [{ "full_name": "test_prog$Game$computer_characters" + }, { + "full_name": "test_prog$MyGame$Game::computer_characters" }], "intro_mclass": { "full_name": "test_prog::Game" @@ -2945,6 +2949,8 @@ }, "mpropdefs": [{ "full_name": "test_prog$Game$start_game" + }, { + "full_name": "test_prog$MyGame$Game::start_game" }], "intro_mclass": { "full_name": "test_prog::Game" @@ -2991,6 +2997,8 @@ }, "mpropdefs": [{ "full_name": "test_prog$Game$pause_game" + }, { + "full_name": "test_prog$MyGame$Game::pause_game" }], "intro_mclass": { "full_name": "test_prog::Game" @@ -3037,6 +3045,8 @@ }, "mpropdefs": [{ "full_name": "test_prog$Game$stop_game" + }, { + "full_name": "test_prog$MyGame$Game::stop_game" }], "intro_mclass": { "full_name": "test_prog::Game" @@ -3053,6 +3063,158 @@ } } { + "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", diff --git a/src/model/test_model_json.sav/test_refs_to_full_json.res b/src/model/test_model_json.sav/test_refs_to_full_json.res index 60e70df..b5e00b5 100644 --- a/src/model/test_model_json.sav/test_refs_to_full_json.res +++ b/src/model/test_model_json.sav/test_refs_to_full_json.res @@ -2,7 +2,7 @@ "full_name": "test_prog" } { - "full_name": "excluded::excluded" + "full_name": "test_prog::game_examples" } { "full_name": "test_prog::Object" diff --git a/tests/sav/nitcatalog_args1.res b/tests/sav/nitcatalog_args1.res index dfc03c1..8524fc6 100644 --- a/tests/sav/nitcatalog_args1.res +++ b/tests/sav/nitcatalog_args1.res @@ -41,6 +41,10 @@

Tinks3D

Content

  • test_prog: Test program for model tools. (test_prog)
      +
    • examples (test_prog/examples)
        +
      • game_examples (test_prog/examples/game_examples.nit)
      • +
      +
    • game: Gaming group (test_prog/game)
      • game: A game abstraction for RPG. (test_prog/game/game.nit)
      @@ -76,8 +80,8 @@

    Quality

      -
    • 28 warnings (63/kloc)
    • -
    • 95% documented
    • +
    • 28 warnings (59/kloc)
    • +
    • 82% documented

    Tags

    test, game

    Requirements

    @@ -85,10 +89,10 @@ none

    Clients

    none

    Contributors

    •  John Doe
    •  Riri
    • Fifi (http://www.example.com/~fifi)
    • Loulou

    Stats

      -
    • 8 modules
    • -
    • 22 classes
    • -
    • 68 methods
    • -
    • 439 lines of code
    • +
    • 9 modules
    • +
    • 23 classes
    • +
    • 75 methods
    • +
    • 471 lines of code
    diff --git a/tests/sav/nitdoc_args4.res b/tests/sav/nitdoc_args4.res index 9238b51..9fdb265 100644 --- a/tests/sav/nitdoc_args4.res +++ b/tests/sav/nitdoc_args4.res @@ -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 diff --git a/tests/sav/nitls_args7.res b/tests/sav/nitls_args7.res index a0a686e..9a0889d 100644 --- a/tests/sav/nitls_args7.res +++ b/tests/sav/nitls_args7.res @@ -1,4 +1,6 @@ test_prog: Test program for model tools. (test_prog) +|--examples (test_prog/examples) +| `--game_examples (test_prog/examples/game_examples.nit) |--game: Gaming group (test_prog/game) | `--game: A game abstraction for RPG. (test_prog/game/game.nit) |--platform: Fictive Crappy Platform. (test_prog/platform) diff --git a/tests/sav/nitsmells_args1.res b/tests/sav/nitsmells_args1.res index 439a213..109e74a 100644 --- a/tests/sav/nitsmells_args1.res +++ b/tests/sav/nitsmells_args1.res @@ -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) diff --git a/tests/sav/test_loader_args1.res b/tests/sav/test_loader_args1.res index 1b169e2..c237e27 100644 --- a/tests/sav/test_loader_args1.res +++ b/tests/sav/test_loader_args1.res @@ -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 diff --git a/tests/sav/test_loader_args2.res b/tests/sav/test_loader_args2.res index 5b3c4f0..4650fe7 100644 --- a/tests/sav/test_loader_args2.res +++ b/tests/sav/test_loader_args2.res @@ -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 diff --git a/tests/sav/test_loader_args3.res b/tests/sav/test_loader_args3.res index 940b6bf..fea9069 100644 --- a/tests/sav/test_loader_args3.res +++ b/tests/sav/test_loader_args3.res @@ -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 diff --git a/tests/sav/test_loader_args4.res b/tests/sav/test_loader_args4.res index 74dfacb..4c9789a 100644 --- a/tests/sav/test_loader_args4.res +++ b/tests/sav/test_loader_args4.res @@ -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 diff --git a/tests/sav/test_model_index_args10.res b/tests/sav/test_model_index_args10.res index 982c125..cfee574 100644 --- a/tests/sav/test_model_index_args10.res +++ b/tests/sav/test_model_index_args10.res @@ -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) diff --git a/tests/sav/test_model_index_args11.res b/tests/sav/test_model_index_args11.res index 510eaba..f969724 100644 --- a/tests/sav/test_model_index_args11.res +++ b/tests/sav/test_model_index_args11.res @@ -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) diff --git a/tests/sav/test_model_index_args13.res b/tests/sav/test_model_index_args13.res index cb5e115..000025b 100644 --- a/tests/sav/test_model_index_args13.res +++ b/tests/sav/test_model_index_args13.res @@ -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>) diff --git a/tests/sav/test_model_index_args16.res b/tests/sav/test_model_index_args16.res index 998a270..fc68d39 100644 --- a/tests/sav/test_model_index_args16.res +++ b/tests/sav/test_model_index_args16.res @@ -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) diff --git a/tests/sav/test_model_index_args20.res b/tests/sav/test_model_index_args20.res index 1e858ea..dd17043 100644 --- a/tests/sav/test_model_index_args20.res +++ b/tests/sav/test_model_index_args20.res @@ -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>) diff --git a/tests/sav/test_model_index_args3.res b/tests/sav/test_model_index_args3.res index c3ac095..758d8df 100644 --- a/tests/sav/test_model_index_args3.res +++ b/tests/sav/test_model_index_args3.res @@ -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=) diff --git a/tests/sav/test_model_index_args8.res b/tests/sav/test_model_index_args8.res index fc9d8e2..191fd72 100644 --- a/tests/sav/test_model_index_args8.res +++ b/tests/sav/test_model_index_args8.res @@ -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::-) diff --git a/tests/sav/test_model_index_args9.res b/tests/sav/test_model_index_args9.res index bb6e9e1..a4c370f 100644 --- a/tests/sav/test_model_index_args9.res +++ b/tests/sav/test_model_index_args9.res @@ -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) diff --git a/tests/sav/test_neo_args1.res b/tests/sav/test_neo_args1.res index fdc3be7..e907ec7 100644 --- a/tests/sav/test_neo_args1.res +++ b/tests/sav/test_neo_args1.res @@ -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 diff --git a/tests/sav/test_sort_perf_args1.res b/tests/sav/test_sort_perf_args1.res index b1fe714..ab1d9c6 100644 --- a/tests/sav/test_sort_perf_args1.res +++ b/tests/sav/test_sort_perf_args1.res @@ -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 index 0000000..68b16de --- /dev/null +++ b/tests/test_prog/examples/game_examples.nit @@ -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