neo_doxygen: Document implicit classes.
[nit.git] / contrib / neo_doxygen / src / model / namespace_members.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Add support for namespace’s members.
16 module model::namespace_members
17
18 import class_compound
19 import member
20
21 redef class Namespace
22 # The class that contains the namespace’s direct members.
23 #
24 # Left `null` for the root namespace and for any namespace with no direct
25 # member. Automatically put in the graph with the namespace.
26 #
27 # Note: In the graph, the `self_class` not linked directly to the namespace.
28 # This is the role of the modules implicitly created by `FileCompound`s to
29 # link a namespace to its `self_class`.
30 #
31 # SEE: `declare_member`
32 var self_class: nullable SelfClass = null
33
34 # Add the specified member as a direct children of the namespace.
35 redef fun declare_member(member) do
36 if self_class == null then self_class = new SelfClass(graph, self)
37 self_class.as(not null).declare_member(member)
38 end
39
40 redef fun put_in_graph do
41 super
42 var self_class = self.self_class
43 if self_class isa SelfClass then self_class.put_in_graph
44 end
45 end
46
47 redef class RootNamespace
48 redef fun declare_member(member) do
49 assert false else
50 # TODO Check how Doxygen modelize member of the root namespace.
51 # Note: Doxygen does not modelize the root namespace.
52 sys.stderr.write "The addition of a member to the root namespace is not supported yet."
53 end
54 end
55 end
56
57 # A class that contains a namespace’s direct members.
58 class SelfClass
59 super ClassCompound
60
61 # The namespace of the members
62 var namespace: Namespace
63
64 init do
65 super
66 name = "(self)"
67 end
68
69 redef fun put_in_graph do
70 if doc.is_empty then doc = namespace.doc
71 super
72 end
73 end