Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
# See `add_page`.
var pages: Map[String, DocPage] = new HashMap[String, DocPage]
# See `add_page`.
var pages: Map[String, DocPage] = new HashMap[String, DocPage]
- # The entry point of the `model`.
- var mainmodule: MModule is writable
-
# Add a `page` to this documentation.
fun add_page(page: DocPage) do
if pages.has_key(page.id) then
# Add a `page` to this documentation.
fun add_page(page: DocPage) do
if pages.has_key(page.id) then
if mentity isa MModule then
v.add_article new MEntitiesListArticle("Classes", null, mentity.mclassdefs)
else if mentity isa MClass then
if mentity isa MModule then
v.add_article new MEntitiesListArticle("Classes", null, mentity.mclassdefs)
else if mentity isa MClass then
- var mprops = mentity.collect_intro_mproperties(mentity.public_view)
+ var mprops = mentity.collect_intro_mproperties(v.phase.doc)
v.add_article new MEntitiesListArticle("Methods", null, mprops.to_a)
else if mentity isa MClassDef then
v.add_article new MEntitiesListArticle("Methods", null, mentity.mpropdefs)
v.add_article new MEntitiesListArticle("Methods", null, mprops.to_a)
else if mentity isa MClassDef then
v.add_article new MEntitiesListArticle("Methods", null, mentity.mpropdefs)
-redef class Model
-
- # Get a custom view for vimautocomplete.
- private fun vim_view: ModelView do
- var view = new ModelView(self)
- view.min_visibility = protected_visibility
- return view
- end
-end
-
redef class MEntity
private fun field_separator: String do return "#====#"
private fun line_separator: String do return "#nnnn#"
redef class MEntity
private fun field_separator: String do return "#====#"
private fun line_separator: String do return "#nnnn#"
- private fun write_doc(mainmodule: MModule, stream: Writer)
+ private fun write_doc(view: ModelView, stream: Writer)
do
# 1. Short name for autocompletion
stream.write complete_name
do
# 1. Short name for autocompletion
stream.write complete_name
stream.write mdoc.content.join(line_separator)
end
stream.write mdoc.content.join(line_separator)
end
- write_location(mainmodule, stream)
+ write_location(view.mainmodule, stream)
- write_extra_doc(mainmodule, stream)
+ write_extra_doc(view, stream)
private fun complete_mdoc: nullable MDoc do return mdoc
# Extra auto documentation to append to the `stream`
private fun complete_mdoc: nullable MDoc do return mdoc
# Extra auto documentation to append to the `stream`
- private fun write_extra_doc(mainmodule: MModule, stream: Writer) do end
+ private fun write_extra_doc(view: ModelView, stream: Writer) do end
# Location (file and line when available) of related declarations
private fun write_location(mainmodule: MModule, stream: Writer)
# Location (file and line when available) of related declarations
private fun write_location(mainmodule: MModule, stream: Writer)
end
redef class MClassType
end
redef class MClassType
- redef fun write_extra_doc(mainmodule, stream)
+ redef fun write_extra_doc(view, stream)
do
# Super classes
stream.write line_separator*2
stream.write "## Class hierarchy"
do
# Super classes
stream.write line_separator*2
stream.write "## Class hierarchy"
- var direct_supers = [for s in mclass.in_hierarchy(mainmodule).direct_greaters do s.name]
+ var direct_supers = [for s in mclass.in_hierarchy(view.mainmodule).direct_greaters do s.name]
if not direct_supers.is_empty then
alpha_comparator.sort direct_supers
stream.write line_separator
if not direct_supers.is_empty then
alpha_comparator.sort direct_supers
stream.write line_separator
stream.write direct_supers.join(", ")
end
stream.write direct_supers.join(", ")
end
- var supers = [for s in mclass.in_hierarchy(mainmodule).greaters do s.name]
+ var supers = [for s in mclass.in_hierarchy(view.mainmodule).greaters do s.name]
supers.remove mclass.name
if not supers.is_empty then
alpha_comparator.sort supers
supers.remove mclass.name
if not supers.is_empty then
alpha_comparator.sort supers
stream.write supers.join(", ")
end
stream.write supers.join(", ")
end
- var direct_subs = [for s in mclass.in_hierarchy(mainmodule).direct_smallers do s.name]
+ var direct_subs = [for s in mclass.in_hierarchy(view.mainmodule).direct_smallers do s.name]
if not direct_subs.is_empty then
alpha_comparator.sort direct_subs
stream.write line_separator
if not direct_subs.is_empty then
alpha_comparator.sort direct_subs
stream.write line_separator
stream.write direct_subs.join(", ")
end
stream.write direct_subs.join(", ")
end
- var subs = [for s in mclass.in_hierarchy(mainmodule).smallers do s.name]
+ var subs = [for s in mclass.in_hierarchy(view.mainmodule).smallers do s.name]
subs.remove mclass.name
if not subs.is_empty then
alpha_comparator.sort subs
subs.remove mclass.name
if not subs.is_empty then
alpha_comparator.sort subs
stream.write line_separator*2
stream.write "## Properties"
stream.write line_separator
stream.write line_separator*2
stream.write "## Properties"
stream.write line_separator
- var props = mclass.collect_accessible_mproperties(model.protected_view).to_a
+ var props = mclass.collect_accessible_mproperties(view).to_a
alpha_comparator.sort props
for prop in props do
if mclass.name == "Object" or prop.intro.mclassdef.mclass.name != "Object" then
alpha_comparator.sort props
for prop in props do
if mclass.name == "Object" or prop.intro.mclassdef.mclass.name != "Object" then
- prop.write_synopsis(mainmodule, stream)
+ prop.write_synopsis(view.mainmodule, stream)
# Got all known modules
var model = mainmodule.model
# Got all known modules
var model = mainmodule.model
+ var view = new ModelView(model, mainmodule)
for mmodule in model.mmodules do
for mmodule in model.mmodules do
- mmodule.write_doc(mainmodule, modules_stream)
+ mmodule.write_doc(view, modules_stream)
end
# TODO list other modules from the Nit lib
end
# TODO list other modules from the Nit lib
# Can it be instantiated?
if mclass.kind != interface_kind and mclass.kind != abstract_kind then
# Can it be instantiated?
if mclass.kind != interface_kind and mclass.kind != abstract_kind then
- for prop in mclass.collect_accessible_mproperties(model.public_view) do
+ for prop in mclass.collect_accessible_mproperties(view) do
if prop isa MMethod and prop.is_init then
mclass_intro.target_constructor = prop.intro
if prop isa MMethod and prop.is_init then
mclass_intro.target_constructor = prop.intro
- mclass_intro.write_doc(mainmodule, constructors_stream)
+ mclass_intro.write_doc(view, constructors_stream)
end
end
mclass_intro.target_constructor = null
end
# Always add to types and classes
end
end
mclass_intro.target_constructor = null
end
# Always add to types and classes
- mclass.mclass_type.write_doc(mainmodule, classes_stream)
- mclass.mclass_type.write_doc(mainmodule, types_stream)
+ mclass.mclass_type.write_doc(view, classes_stream)
+ mclass.mclass_type.write_doc(view, types_stream)
end
# Get all known properties
end
# Get all known properties
# Is it a virtual type?
if mproperty isa MVirtualTypeProp then
# Is it a virtual type?
if mproperty isa MVirtualTypeProp then
- mproperty.intro.write_doc(mainmodule, types_stream)
+ mproperty.intro.write_doc(view, types_stream)
var first_letter = mproperty.name.chars.first
if first_letter == '@' or first_letter == '_' then continue
var first_letter = mproperty.name.chars.first
if first_letter == '@' or first_letter == '_' then continue
- mproperty.intro.write_doc(mainmodule, properties_stream)
+ mproperty.intro.write_doc(view, properties_stream)
- redef fun write_extra_doc(mainmodule, stream)
+ redef fun write_extra_doc(view, stream)
- var class_intros = collect_intro_mclasses(model.protected_view).to_a
+ var class_intros = collect_intro_mclasses(view).to_a
if class_intros.not_empty then
alpha_comparator.sort class_intros
stream.write line_separator*2
if class_intros.not_empty then
alpha_comparator.sort class_intros
stream.write line_separator*2
# Introduced properties
var prop_intros = new Array[MPropDef]
for c in mclassdefs do
# Introduced properties
var prop_intros = new Array[MPropDef]
for c in mclassdefs do
- prop_intros.add_all c.collect_intro_mpropdefs(model.protected_view)
+ prop_intros.add_all c.collect_intro_mpropdefs(view)
end
if prop_intros.not_empty then
end
if prop_intros.not_empty then
stream.write line_separator
for p in prop_intros do
stream.write line_separator
for p in prop_intros do
- p.mproperty.write_synopsis(mainmodule, stream)
+ p.mproperty.write_synopsis(view.mainmodule, stream)