X-Git-Url: http://nitlanguage.org diff --git a/src/doc/console_templates/console_model.nit b/src/doc/console_templates/console_model.nit index 8de793c..96b1a40 100644 --- a/src/doc/console_templates/console_model.nit +++ b/src/doc/console_templates/console_model.nit @@ -39,7 +39,7 @@ redef class MEntity # Returns the mentity name with short signature. # - # * MProject: `foo` + # * MPackage: `foo` # * MGroup: `foo` # * MModule: `foo` # * MClass: `Foo[E]` @@ -53,7 +53,7 @@ redef class MEntity # Returns the complete MEntity declaration (modifiers + name + signature). # - # * MProject: `project foo` + # * MPackage: `package foo` # * MGroup: `group foo` # * MModule: `module foo` # * MClass: `private abstract class Foo[E: Object]` @@ -70,10 +70,10 @@ redef class MEntity # Returns `self` namespace formatted for console. # - # * MProject: `mproject` - # * MGroup: `mproject(::group)` + # * MPackage: `mpackage` + # * MGroup: `mpackage(::group)` # * MModule: `mgroup::mmodule` - # * MClass: `mproject::mclass` + # * MClass: `mpackage::mclass` # * MClassDef: `mmodule::mclassdef` # * MProperty: `mclass::mprop` # * MPropdef: `mclassdef:mpropdef` @@ -94,7 +94,10 @@ redef class MEntity return mdoc.cs_short_comment end - # Returns 1self` as a list element that can be displayed in console. + # Returns `self` as a list element that can be displayed in console. + # + # Displays `cs_icon`, `cs_name`, `cs_short_comment, `cs_namespace`, + # `cs_declaration` and `cs_location`. fun cs_list_item: String do var tpl = new FlatBuffer tpl.append " {cs_visibility_color(cs_icon).bold} {cs_name.blue.bold}" @@ -111,6 +114,18 @@ redef class MEntity return tpl.write_to_string end + # Returns `self` as a short list element that can be displayed in console. + # Displays `cs_icon`, `cs_name`, and `cs_short_comment. + fun cs_short_list_item: String do + var tpl = new FlatBuffer + tpl.append " {cs_visibility_color(cs_icon).bold} {cs_name.blue.bold}" + var comment = cs_short_comment + if comment != null then + tpl.append " # {comment}".green + end + return tpl.write_to_string + end + # ASCII icon to be displayed in front of the list item. fun cs_icon: String do return "*" @@ -121,10 +136,30 @@ redef class MEntity # # See module `console`. fun cs_visibility_color(string: String): String do return string.green + + # Source code associated to this MEntity. + # + # Uses `cs_location` to locate the source code. + fun cs_source_code: String do + # FIXME up location to mentity + var loc = new Location.from_string(cs_location) + var fr = new FileReader.open(loc.file.filename) + var content = new FlatBuffer + var i = 0 + while not fr.eof do + i += 1 + var line = fr.read_line + if i < loc.line_start or i > loc.line_end then continue + # FIXME add nitlight for console + content.append "{line}\n" + end + fr.close + return content.write_to_string + end end -redef class MProject - redef var cs_modifiers = ["project"] +redef class MPackage + redef var cs_modifiers = ["package"] redef fun cs_namespace do return cs_name redef fun cs_icon do return "P" redef fun cs_location do return root.mmodules.first.location.to_s @@ -136,12 +171,12 @@ redef class MGroup # Depends if `self` is root or not. # - # * If root `mproject`. - # * Else `mproject::self`. + # * If root `mpackage`. + # * Else `mpackage::self`. redef fun cs_namespace do var tpl = new FlatBuffer - tpl.append mproject.cs_namespace - if mproject.root != self then + tpl.append mpackage.cs_namespace + if mpackage.root != self then tpl.append "::" tpl.append cs_name end @@ -195,10 +230,10 @@ redef class MClass redef fun cs_modifiers do return intro.cs_modifiers redef fun cs_declaration do return intro.cs_declaration - # Returns `mproject::self`. + # Returns `mpackage::self`. redef fun cs_namespace do var tpl = new FlatBuffer - tpl.append intro_mmodule.mgroup.mproject.cs_namespace + tpl.append intro_mmodule.mgroup.mpackage.cs_namespace tpl.append "::" tpl.append cs_name return tpl.write_to_string