1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # Adds a methods to convert Doxygen’s names into short names.
16 module doxml
::doxyname
22 # Separator used by Doxygen to separate name’s components.
23 protected fun doxyname_separator
: String do return "::"
25 # Set the `name` using the specified name generated by Doxygen.
26 fun doxyname
=(doxyname
: String) do
27 name
= doxyname
.to_short_name
(doxyname_separator
)
30 # Declare an inner class.
32 # Note: Althought Doxygen indicates that both arguments are optional,
33 # declarations with an empty ID are not supported yet.
37 # * `id`: `model_id` of the inner class.
38 # * `doxyname`: qualified name of the inner class, as generated by Doxygen.
39 # * `prot`: visibility (proctection).
41 # TODO: Handle cases where only the `doxyname` is available.
42 fun doxygen_declare_class
(id
: String, doxyname
: String, prot
: String) do
43 declare_class
(id
, doxyname
.to_short_name
(doxyname_separator
), prot
)
48 # Set the `name` and the `full_name` using the specified name generated by Doxygen.
50 # Warning: This method assumes that `model_id` is already set.
51 redef fun doxyname
=(doxyname
: String) do
54 if doxyname
== name
and model_id
!= "" then
55 # Doxygen does not represent the root namespace.
56 # So, we have to link the root namespace with its children manually.
57 graph
.by_id
[""].as(Namespace).declare_namespace
(model_id
, doxyname
)
62 redef class FileCompound
63 redef fun doxyname_separator
do return "/"
67 # Return the substring that come after the last occurrence of `separator`.
69 # Return the whole string if `sperator` is not present.
70 private fun to_short_name
(separator
: String): SELFTYPE do
71 var m
= search_last
(separator
)
76 return substring_from
(m
.after
)