# 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. # Adds a methods to convert Doxygen’s names into short names. module doxml::doxyname import model redef class Compound # Separator used by Doxygen to separate name’s components. protected fun doxyname_separator: String do return "::" # Set the `name` using the specified name generated by Doxygen. fun doxyname=(doxyname: String) do name = doxyname.to_short_name(doxyname_separator) end # Declare an inner class. # # Note: Althought Doxygen indicates that both arguments are optional, # declarations with an empty ID are not supported yet. # # Parameters: # # * `id`: `model_id` of the inner class. # * `doxyname`: qualified name of the inner class, as generated by Doxygen. # * `prot`: visibility (proctection). # # TODO: Handle cases where only the `doxyname` is available. fun doxygen_declare_class(id: String, doxyname: String, prot: String) do declare_class(id, doxyname.to_short_name(doxyname_separator), prot) end end redef class Namespace # Set the `name` and the `full_name` using the specified name generated by Doxygen. # # Warning: This method assumes that `model_id` is already set. redef fun doxyname=(doxyname: String) do full_name = doxyname super if doxyname == name and model_id != "" then # Doxygen does not represent the root namespace. # So, we have to link the root namespace with its children manually. graph.by_id[""].as(Namespace).declare_namespace(model_id, doxyname) end end end redef class FileCompound redef fun doxyname_separator do return "/" end redef class Text # Return the substring that come after the last occurrence of `separator`. # # Return the whole string if `sperator` is not present. private fun to_short_name(separator: String): SELFTYPE do var m = search_last(separator) if m == null then return self else return substring_from(m.after) end end end