# 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
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
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+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
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"
nitc
nitdoc
nitlight
+neo_doxygen_doc_module_class
neo_doxygen_dump
neo_doxygen_file_compound
neo_doxygen_graph_empty_project
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
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):
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):
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
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):
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):
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
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):
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):
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
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):
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):
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
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):
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):
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
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):
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):
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
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):
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):
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
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):
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):