From 79b26e43d1301574e26227a0e9042ccdee17b4ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Christophe=20Beaupr=C3=A9?= Date: Sat, 20 Dec 2014 22:44:08 -0500 Subject: [PATCH] neo_doxygen: Document modules. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Christophe Beaupré --- contrib/neo_doxygen/src/model/module_compound.nit | 15 +++++-- .../src/tests/neo_doxygen_doc_module_class.nit | 43 ++++++++++++++++++++ .../src/tests/neo_doxygen_file_compound.nit | 1 + tests/nitg-g.skip | 1 + tests/sav/neo_doxygen_dump_args4.res | 24 +++++------ tests/sav/neo_doxygen_dump_args5.res | 24 +++++------ tests/sav/neo_doxygen_dump_args6.res | 12 +++--- tests/sav/neo_doxygen_file_compound.res | 36 ++++++++-------- 8 files changed, 104 insertions(+), 52 deletions(-) create mode 100644 contrib/neo_doxygen/src/tests/neo_doxygen_doc_module_class.nit create mode 100644 tests/sav/neo_doxygen_doc_module_class.res diff --git a/contrib/neo_doxygen/src/model/module_compound.nit b/contrib/neo_doxygen/src/model/module_compound.nit index 95ce6cb..188d4c1 100644 --- a/contrib/neo_doxygen/src/model/module_compound.nit +++ b/contrib/neo_doxygen/src/model/module_compound.nit @@ -139,19 +139,19 @@ private class Module # declares it. fun update_name do name = file_compound.basename - redef fun put_in_graph do - super - end - redef fun put_edges do var ns_compound = namespace.seek_in(graph) var self_class = ns_compound.self_class + var class_count = 0 + var last_class: nullable ClassCompound = null graph.add_edge(ns_compound, "DECLARES", self) for c in file_compound.inner_classes do if graph.class_to_ns[c] != ns_compound then continue var class_compound = graph.by_id[c].as(ClassCompound) + last_class = class_compound + class_count += 1 graph.add_edge(self, "INTRODUCES", class_compound) graph.add_edge(self, "DEFINES", class_compound.class_def) end @@ -163,6 +163,13 @@ private class Module graph.add_edge(self, "INTRODUCES", self_class) graph.add_edge(self, "DEFINES", self_class.class_def) end + + if doc.is_empty and class_count == 1 then + doc = last_class.as(not null).doc + end + if doc.is_empty then doc = file_compound.doc + if doc.is_empty then doc = ns_compound.doc + if not doc.is_empty then set_mdoc end end diff --git a/contrib/neo_doxygen/src/tests/neo_doxygen_doc_module_class.nit b/contrib/neo_doxygen/src/tests/neo_doxygen_doc_module_class.nit new file mode 100644 index 0000000..308e94a --- /dev/null +++ b/contrib/neo_doxygen/src/tests/neo_doxygen_doc_module_class.nit @@ -0,0 +1,43 @@ +# 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. + +import tests +intrude import model::module_compound + +var graph = new ProjectGraph("foo") +var file = new FileCompound(graph) +var bar_class = new ClassCompound(graph) +var a_ns = new Namespace(graph) + +file.full_name = "Baz.java" +file.declare_class("classa_bar", "a::Bar", "public") +file.declare_namespace("namespacea", "a") +file.doc.add "A file." +file.put_in_graph + +a_ns.full_name = "a" +a_ns.model_id = "namespacea" +a_ns.declare_class("classa_bar", "a::Bar", "public") +a_ns.doc.add "A namespace." +a_ns.put_in_graph + +bar_class.model_id = "classa_bar" +bar_class.full_name = "a::Bar" +bar_class.doc.add "A class." +bar_class.put_in_graph + +graph.add_global_modules +graph.put_edges + +assert file.inner_namespaces[0]["mdoc"] == bar_class.doc diff --git a/contrib/neo_doxygen/src/tests/neo_doxygen_file_compound.nit b/contrib/neo_doxygen/src/tests/neo_doxygen_file_compound.nit index 73adc61..e1f59b2 100644 --- a/contrib/neo_doxygen/src/tests/neo_doxygen_file_compound.nit +++ b/contrib/neo_doxygen/src/tests/neo_doxygen_file_compound.nit @@ -36,6 +36,7 @@ file.location = location file.declare_class("classa_b_bar", "a::b::Bar", "package") file.declare_class("classbaz", "Baz", "") file.declare_namespace("", "a::b") +file.doc.add "The first file." file.put_in_graph file_2.name = "Bar.java" diff --git a/tests/nitg-g.skip b/tests/nitg-g.skip index d25129d..e24a345 100644 --- a/tests/nitg-g.skip +++ b/tests/nitg-g.skip @@ -1,6 +1,7 @@ nitc nitdoc nitlight +neo_doxygen_doc_module_class neo_doxygen_dump neo_doxygen_file_compound neo_doxygen_graph_empty_project diff --git a/tests/sav/neo_doxygen_doc_module_class.res b/tests/sav/neo_doxygen_doc_module_class.res new file mode 100644 index 0000000..e69de29 diff --git a/tests/sav/neo_doxygen_dump_args4.res b/tests/sav/neo_doxygen_dump_args4.res index 3a3c933..55f5dcb 100644 --- a/tests/sav/neo_doxygen_dump_args4.res +++ b/tests/sav/neo_doxygen_dump_args4.res @@ -242,8 +242,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C","mdoc":["An interface"]} Edge @@ -256,8 +256,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C","mdoc":["An interface"]} ---- =to=Entity#36:interfaceorg_1_1example_1_1foo_1_1_c =labels=Array(3): @@ -278,8 +278,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C","mdoc":["An interface"]} ---- =to=Entity#0: =labels=Array(3): @@ -308,8 +308,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass","mdoc":["This class is empty and is only visible in this package."]} Edge @@ -322,8 +322,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass","mdoc":["This class is empty and is only visible in this package."]} ---- =to=Entity#42:classorg_1_1example_1_1foo_1_1_empty_class =labels=Array(3): @@ -344,8 +344,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass","mdoc":["This class is empty and is only visible in this package."]} ---- =to=Entity#0: =labels=Array(3): diff --git a/tests/sav/neo_doxygen_dump_args5.res b/tests/sav/neo_doxygen_dump_args5.res index 95633f3..9f9a005 100644 --- a/tests/sav/neo_doxygen_dump_args5.res +++ b/tests/sav/neo_doxygen_dump_args5.res @@ -242,8 +242,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C","mdoc":["An interface"]} Edge @@ -256,8 +256,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C","mdoc":["An interface"]} ---- =to=Entity#36:interfaceorg_1_1example_1_1foo_1_1_c =labels=Array(3): @@ -278,8 +278,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/C.java:1,1--1,1","name":"C","mdoc":["An interface"]} ---- =to=Entity#0: =labels=Array(3): @@ -308,8 +308,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass","mdoc":["This class is empty and is only visible in this package."]} Edge @@ -322,8 +322,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass","mdoc":["This class is empty and is only visible in this package."]} ---- =to=Entity#42:classorg_1_1example_1_1foo_1_1_empty_class =labels=Array(3): @@ -344,8 +344,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/org\/example\/foo\/EmptyClass.java:1,1--1,1","name":"EmptyClass","mdoc":["This class is empty and is only visible in this package."]} ---- =to=Entity#0: =labels=Array(3): diff --git a/tests/sav/neo_doxygen_dump_args6.res b/tests/sav/neo_doxygen_dump_args6.res index 5436c24..69cf81f 100644 --- a/tests/sav/neo_doxygen_dump_args6.res +++ b/tests/sav/neo_doxygen_dump_args6.res @@ -157,8 +157,8 @@ Edge 14:root-namespace 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/Foo.java:1,1--1,1","name":"Foo"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/Foo.java:1,1--1,1","name":"Foo","mdoc":["A class in the root namespace"]} Edge @@ -171,8 +171,8 @@ Edge 14:root-namespace 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/Foo.java:1,1--1,1","name":"Foo"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/Foo.java:1,1--1,1","name":"Foo","mdoc":["A class in the root namespace"]} ---- =to=Entity#9:class_foo =labels=Array(3): @@ -193,8 +193,8 @@ Edge 14:root-namespace 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"%SOURCE_DIRECTORY%\/Foo.java:1,1--1,1","name":"Foo"} +=properties=JsonObject(3): +{"location":"%SOURCE_DIRECTORY%\/Foo.java:1,1--1,1","name":"Foo","mdoc":["A class in the root namespace"]} ---- =to=Entity#0: =labels=Array(3): diff --git a/tests/sav/neo_doxygen_file_compound.res b/tests/sav/neo_doxygen_file_compound.res index 9b16eb8..740393b 100644 --- a/tests/sav/neo_doxygen_file_compound.res +++ b/tests/sav/neo_doxygen_file_compound.res @@ -186,8 +186,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} Edge =type=10:INTRODUCES @@ -199,8 +199,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} ---- =to=Entity#12:classa_b_bar =labels=Array(3): @@ -220,8 +220,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} ---- =to=Entity#0: =labels=Array(3): @@ -762,8 +762,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} Edge =type=10:INTRODUCES @@ -775,8 +775,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} ---- =to=Entity#12:classa_b_bar =labels=Array(3): @@ -796,8 +796,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} ---- =to=Entity#0: =labels=Array(3): @@ -1167,8 +1167,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} Edge =type=10:INTRODUCES @@ -1180,8 +1180,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} ---- =to=Entity#8:classbaz =labels=Array(3): @@ -1201,8 +1201,8 @@ Edge 3:foo 7:MEntity 7:MModule -=properties=JsonObject(2): -{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar"} +=properties=JsonObject(3): +{"location":"a\/b\/Bar.java:1,1--1,1","name":"Bar","mdoc":["The first file."]} ---- =to=Entity#0: =labels=Array(3): -- 1.7.9.5