import toolcontext
import model_ext
-import model::model_views
+import model::model_collect
# The model of a Nitdoc documentation.
#
# The model is populated through `DocPhase` to be constructed.
# It is a placeholder to share data between each phase.
class DocModel
- super ModelView
- autoinit model, mainmodule, filter
+ # Model to generate the documentation for
+ var model: Model
+
+ # Main module of the sources behing documented
+ var mainmodule: MModule
+
+ # Model filters to apply
+ var filter: ModelFilter
# `DocPage` composing the documentation associated to their ids.
#
var doc = v.doc
var mmodules = new HashSet[MModule]
for mmodule in mentity.mmodules do
- if doc.mmodules.has(mmodule) then mmodules.add mmodule
+ if doc.filter.accept_mentity(mmodule) then mmodules.add mmodule
# collect mclasses
for mclass in mmodule.intro_mclasses do
- if doc.mclasses.has(mclass) then intros.add mclass
+ if doc.filter.accept_mentity(mclass) then intros.add mclass
end
- for mclass in mmodule.collect_redef_mclasses(v.doc) do
- if doc.mclasses.has(mclass) then redefs.add mclass
+ for mclass in mmodule.collect_redef_mclasses(doc.filter) do
+ if doc.filter.accept_mentity(mclass) then redefs.add mclass
end
end
concerns = doc.model.concerns_tree(mmodules)
var doc = v.doc
# extract mclassdefs in mmodule
for mclassdef in mentity.mclassdefs do
- if doc.mclassdefs.has(mclassdef) then mclassdefs.add mclassdef
+ if doc.filter.accept_mentity(mclassdef) then mclassdefs.add mclassdef
end
# extract mclasses in mmodule
for mclassdef in mclassdefs do
var mclass = mclassdef.mclass
- if doc.mclasses.has(mclass) then mclasses.add mclass
+ if doc.filter.accept_mentity(mclass) then mclasses.add mclass
end
# extract concerns
var mods = new HashSet[MModule]
for mclass in mclasses do
var mod = mclass.intro_mmodule
- if doc.mmodules.has(mod) then mods.add mod
+ if doc.filter.accept_mentity(mod) then mods.add mod
end
concerns = doc.model.concerns_tree(mods)
end
var doc = v.doc
# collect mclassdefs
for mclassdef in mentity.mclassdefs do
- if doc.mclassdefs.has(mclassdef) then mclassdefs.add mclassdef
+ if doc.filter.accept_mentity(mclassdef) then mclassdefs.add mclassdef
end
# collect mpropdefs
for mclassdef in mclassdefs do
for mpropdef in mclassdef.mpropdefs do
- if doc.mpropdefs.has(mpropdef) then mpropdefs.add mpropdef
+ if doc.filter.accept_mentity(mpropdef) then mpropdefs.add mpropdef
end
end
# collect concerns
var mods = new HashSet[MModule]
for mpropdef in mpropdefs do
var mod = mpropdef.mclassdef.mmodule
- if doc.mmodules.has(mod) then mods.add mod
+ if doc.filter.accept_mentity(mod) then mods.add mod
end
concerns = doc.model.concerns_tree(mods)
end
for mpropdef in mentity.mpropdefs do
# FIXME diff hack
if mpropdef.is_intro then continue
- if doc.mpropdefs.has(mpropdef) then mpropdefs.add mpropdef
+ if doc.filter.accept_mentity(mpropdef) then mpropdefs.add mpropdef
end
# collect concerns
var mods = new HashSet[MModule]
for mpropdef in mpropdefs do
var mod = mpropdef.mclassdef.mmodule
- if doc.mmodules.has(mod) then mods.add mod
+ if doc.filter.accept_mentity(mod) then mods.add mod
end
concerns = doc.model.concerns_tree(mods)
end
# TODO filter here?
super
var mclasses = new HashSet[MClass]
- mclasses.add_all mentity.collect_intro_mclasses(v.doc)
- mclasses.add_all mentity.collect_redef_mclasses(v.doc)
+ mclasses.add_all mentity.collect_intro_mclasses(v.doc.filter)
+ mclasses.add_all mentity.collect_redef_mclasses(v.doc.filter)
if mclasses.is_empty then return
var list = new UnorderedList
list.css_classes.add "list-unstyled list-labeled"
private fun mclass_inherited_mprops(v: RenderHTMLPhase, doc: DocModel): Set[MProperty] do
var res = new HashSet[MProperty]
- var local = mentity.collect_local_mproperties(v.doc)
- for mprop in mentity.collect_inherited_mproperties(v.doc) do
+ var local = mentity.collect_local_mproperties(v.doc.filter)
+ for mprop in mentity.collect_inherited_mproperties(doc.mainmodule, v.doc.filter) do
if local.has(mprop) then continue
#if mprop isa MMethod and mprop.is_init then continue
if mprop.intro.mclassdef.mclass.name == "Object" and
super DocPhase
redef fun apply do
- for mmodule in doc.mmodules do
+ for mmodule in doc.model.mmodules do
add_result_for(mmodule.name, mmodule.full_name, mmodule.nitdoc_url)
end
- for mclass in doc.mclasses do
+ for mclass in doc.model.mclasses do
add_result_for(mclass.name, mclass.full_name, mclass.nitdoc_url)
end
- for mproperty in doc.mproperties do
+ for mproperty in doc.model.mproperties do
for mpropdef in mproperty.mpropdefs do
- if not doc.mpropdefs.has(mpropdef) then continue
+ if not doc.filter.accept_mentity(mpropdef) then continue
var full_name = mpropdef.mclassdef.mclass.full_name
var cls_url = mpropdef.mclassdef.mclass.nitdoc_url
var def_url = "{cls_url}#{mpropdef.nitdoc_id}.definition"
var section = new TabbedGroup("{mentity.nitdoc_id}.intros_redefs")
section.toc_title = "Intros / Redefs"
var group = new PanelGroup("list.group", "List")
- var intros = mmodule.collect_intro_mclassdefs(v.doc).to_a
+ var intros = mmodule.collect_intro_mclassdefs(v.doc.filter).to_a
doc.mainmodule.linearize_mclassdefs(intros)
group.add_child new MEntitiesListArticle("{mentity.nitdoc_id}.intros", "Introduces", intros)
- var redefs = mmodule.collect_redef_mclassdefs(v.doc).to_a
+ var redefs = mmodule.collect_redef_mclassdefs(v.doc.filter).to_a
doc.mainmodule.linearize_mclassdefs(redefs)
group.add_child new MEntitiesListArticle("{mentity.nitdoc_id}.redefs", "Redefines", redefs)
section.add_child group
var section = new TabbedGroup("{mentity.nitdoc_id}.intros_redefs")
section.toc_title = "Intros / Redefs"
var group = new PanelGroup("list.group", "List")
- var intros = mclassdef.collect_intro_mpropdefs(v.doc).to_a
+ var intros = mclassdef.collect_intro_mpropdefs(v.doc.filter).to_a
# FIXME avoid diff changes
# v.ctx.mainmodule.linearize_mpropdefs(intros)
group.add_child new MEntitiesListArticle("{mentity.nitdoc_id}.intros", "Introduces", intros)
- var redefs = mclassdef.collect_redef_mpropdefs(v.doc).to_a
+ var redefs = mclassdef.collect_redef_mpropdefs(v.doc.filter).to_a
# FIXME avoid diff changes
# v.ctx.mainmodule.linearize_mpropdefs(redefs)
group.add_child new MEntitiesListArticle("{mentity.nitdoc_id}.redefs", "Redefines", redefs)
redef fun apply do
doc.add_page new OverviewPage("overview", "Overview")
doc.add_page new SearchPage("search", "Index")
- for mgroup in doc.mgroups do
+ for mgroup in doc.model.collect_mgroups(doc.filter) do
doc.add_page new ReadmePage(mgroup)
doc.add_page new MGroupPage(mgroup)
end
- for mmodule in doc.mmodules do
+ for mmodule in doc.model.mmodules do
doc.add_page new MModulePage(mmodule)
end
- for mclass in doc.mclasses do
+ for mclass in doc.model.mclasses do
doc.add_page new MClassPage(mclass)
end
- for mproperty in doc.mproperties do
+ for mproperty in doc.model.mproperties do
doc.add_page new MPropertyPage(mproperty)
end
end
# collect importation
for dep in mentity.in_importation.greaters do
if dep == mentity then continue
- if not doc.mmodules.has(dep) then continue
+ if not doc.filter.accept_mentity(dep) then continue
imports.add dep
end
# FIXME avoid diff
imports.clear
for dep in mentity.in_importation.direct_greaters do
if dep == mentity then continue
- if not doc.mmodules.has(dep) then continue
+ if not doc.filter.accept_mentity(dep) then continue
imports.add dep
end
end
# collect clients
for dep in mentity.in_importation.smallers do
if dep == mentity then continue
- if not doc.mmodules.has(dep) then continue
+ if not doc.filter.accept_mentity(dep) then continue
clients.add dep
end
if clients.length > 10 then
clients.clear
for dep in mentity.in_importation.direct_smallers do
if dep == mentity then continue
- if not doc.mmodules.has(dep) then continue
+ if not doc.filter.accept_mentity(dep) then continue
clients.add dep
end
end
# Build the POSet of importation from a list of `mmodules`.
private fun build_importation_poset(doc: DocModel, mmodules: Set[MModule]): POSet[MModule] do
for mmodule in mmodules do
- if not doc.mmodules.has(mmodule) then continue
+ if not doc.filter.accept_mentity(mmodule) then continue
poset.add_node mmodule
for omodule in mmodules do
- if not doc.mmodules.has(omodule) then continue
+ if not doc.filter.accept_mentity(omodule) then continue
poset.add_node mmodule
if mmodule.in_importation < omodule then
poset.add_edge(mmodule, omodule)
var h = mentity.in_hierarchy(doc.mainmodule)
# parents
for mclass in h.direct_greaters do
- if doc.mclasses.has(mclass) then parents.add mclass
+ if doc.filter.accept_mentity(mclass) then parents.add mclass
end
# ancestors
for mclass in h.greaters do
if mclass == mentity then continue
- if not doc.mclasses.has(mclass) then continue
+ if not doc.filter.accept_mentity(mclass) then continue
if parents.has(mclass) then continue
ancestors.add mclass
end
# children
for mclass in h.direct_smallers do
- if doc.mclasses.has(mclass) then children.add mclass
+ if doc.filter.accept_mentity(mclass) then children.add mclass
end
# descendants
for mclass in h.smallers do
if mclass == mentity then continue
- if not doc.mclasses.has(mclass) then continue
+ if not doc.filter.accept_mentity(mclass) then continue
if children.has(mclass) then continue
descendants.add mclass
end
# Find mentities matching `query`.
fun find_mentities(query: String): Array[MEntity] do
# search MEntities by full_name
- var mentity = phase.doc.mentity_by_full_name(query)
+ var mentity = phase.doc.model.mentity_by_full_name(query)
if mentity != null then return [mentity]
# search MEntities by name
- return phase.doc.mentities_by_name(query)
+ return phase.doc.model.mentities_by_name(query)
end
# Suggest mentities based on `query`.
fun suggest_mentities(query: String): Array[MEntity] do
- return phase.doc.find(query, 3)
+ return phase.doc.model.find(query, 3)
end
# Display a warning message with suggestions.
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(v.phase.doc)
+ var mprops = mentity.collect_intro_mproperties(v.phase.doc.filter)
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 SearchPage
redef fun apply_structure(v, doc) do
- var mmodules = doc.mmodules.to_a
+ var mmodules = doc.model.mmodules.to_a
v.name_sorter.sort(mmodules)
- var mclasses = doc.mclasses.to_a
+ var mclasses = doc.model.mclasses.to_a
v.name_sorter.sort(mclasses)
- var mprops = doc.mproperties.to_a
+ var mprops = doc.model.mproperties.to_a
v.name_sorter.sort(mprops)
root.add_child new IndexArticle("index.article", null, mmodules, mclasses, mprops)
end
page_counter.print_elements(100)
# Model metrics
var model_counter = new Counter[String]
- for mentity in doc.mentities do
+ for mentity in doc.model.collect_mentities(doc.filter) do
model_counter.inc mentity.class_name
end
- print "Found {doc.mentities.length} mentities"
+ print "Found {doc.model.collect_mentities(doc.filter).length} mentities"
model_counter.print_elements(100)
end
end
min_visibility,
accept_attribute = accept_attribute,
accept_fictive = false)
- var doc = new DocModel(mainmodule.model, mainmodule, filters)
+ var doc = new DocModel(toolcontext.modelbuilder.model, mainmodule, filters)
var phases = [
new IndexingPhase(toolcontext, doc),
dep_class_module_95d1-__B.dot
dep_module_module_95d0-.dot
dep_module_module_95d1-.dot
+dep_module_module_95d1_45dm.dot
group_module_95d0.html
group_module_95d1.html
index.html
less/
module_module_95d0-.html
module_module_95d1-.html
+module_module_95d1_45dm.html
property_module_95d0-__Object__init.html
property_module_95d0-__Object__output.html
property_module_95d0-__Object__print.html
dep_class_base_attr_nullable-__Object.dot
dep_class_base_attr_nullable-__Sys.dot
dep_module_base_attr_nullable-.dot
+dep_module_base_attr_nullable_45dm.dot
group_base_attr_nullable.html
index.html
js/
less/
module_base_attr_nullable-.html
+module_base_attr_nullable_45dm.html
+property_base_attr_nullable-__Bar___a3.html
property_base_attr_nullable-__Bar__a3.html
property_base_attr_nullable-__Bar__a3_61d.html
+property_base_attr_nullable-__Foo___a1.html
+property_base_attr_nullable-__Foo___a2.html
property_base_attr_nullable-__Foo__a1.html
property_base_attr_nullable-__Foo__a1_61d.html
property_base_attr_nullable-__Foo__a2.html
property_base_attr_nullable-__Foo__run_other.html
property_base_attr_nullable-__Int___43d.html
property_base_attr_nullable-__Int__output.html
+property_base_attr_nullable-__Integer___val.html
property_base_attr_nullable-__Integer__init.html
property_base_attr_nullable-__Integer__output.html
property_base_attr_nullable-__Integer__val.html
dep_class_base_attr_nullable-__Object.dot
dep_class_base_attr_nullable-__Sys.dot
dep_module_base_attr_nullable-.dot
+dep_module_base_attr_nullable_45dm.dot
group_base_attr_nullable.html
index.html
js/
less/
module_base_attr_nullable-.html
+module_base_attr_nullable_45dm.html
+property_base_attr_nullable-__Bar___a3.html
property_base_attr_nullable-__Bar__a3.html
property_base_attr_nullable-__Bar__a3_61d.html
+property_base_attr_nullable-__Foo___a1.html
+property_base_attr_nullable-__Foo___a2.html
property_base_attr_nullable-__Foo__a1.html
property_base_attr_nullable-__Foo__a1_61d.html
property_base_attr_nullable-__Foo__a2.html
property_base_attr_nullable-__Foo__run_other.html
property_base_attr_nullable-__Int___43d.html
property_base_attr_nullable-__Int__output.html
+property_base_attr_nullable-__Integer___val.html
property_base_attr_nullable-__Integer__init.html
property_base_attr_nullable-__Integer__output.html
property_base_attr_nullable-__Integer__val.html
# start.section
## test_prog-__Starter__start.intro
+MModulePage test_prog-m
+ # test_prog-m.section
+ ## test_prog_45dm.intro
+ ## test_prog_45dm.importation
+ ### test_prog_45dm.graph
+ ### list.group
+ #### test_prog_45dm.imports
+ #### test_prog_45dm.clients
+
MGroupPage examples
# examples.section
## test_prog__examples.intro
### test_prog__examples-__MyGame__stop_game.definition
#### test_prog__examples-__MyGame__stop_game.lin
+MPropertyPage _computer_characters
+ # _computer_characters.section
+ ## test_prog__examples-__MyGame___computer_characters.intro
+
+MPropertyPage _player_characters
+ # _player_characters.section
+ ## test_prog__examples-__MyGame___player_characters.intro
+
MPropertyPage computer_characters=
# computer_characters=.section
## test_prog__examples-__MyGame__computer_characters_61d.intro
### test_prog__rpg__careers__Career__strength_bonus.definition
### test_prog__rpg__careers__Career__strength_bonus_61d.definition
+MPropertyPage _endurance_bonus
+ # _endurance_bonus.section
+ ## test_prog__rpg__careers__Career___endurance_bonus.intro
+
+MPropertyPage _intelligence_bonus
+ # _intelligence_bonus.section
+ ## test_prog__rpg__careers__Career___intelligence_bonus.intro
+
+MPropertyPage _strength_bonus
+ # _strength_bonus.section
+ ## test_prog__rpg__careers__Career___strength_bonus.intro
+
MPropertyPage endurance_bonus
# endurance_bonus.section
## test_prog__rpg__careers__Career__endurance_bonus.intro
### test_prog__rpg__combat__Character__hit_points.definition
#### test_prog__rpg__combat__Character__hit_points.lin
+MPropertyPage _age
+ # _age.section
+ ## test_prog__rpg__character__Character___age.intro
+
+MPropertyPage _career
+ # _career.section
+ ## test_prog__rpg__character__Character___career.intro
+
+MPropertyPage _health
+ # _health.section
+ ## test_prog__rpg__character__Character___health.intro
+
+MPropertyPage _name
+ # _name.section
+ ## test_prog__rpg__character__Character___name.intro
+
+MPropertyPage _race
+ # _race.section
+ ## test_prog__rpg__character__Character___race.intro
+
+MPropertyPage _sex
+ # _sex.section
+ ## test_prog__rpg__character__Character___sex.intro
+
MPropertyPage age
# age.section
## test_prog__rpg__character__Character__age.intro
### test_prog__rpg__races__Race__base_strength.definition
### test_prog__rpg__races__Race__base_strength_61d.definition
+MPropertyPage _base_endurance
+ # _base_endurance.section
+ ## test_prog__rpg__races__Race___base_endurance.intro
+
+MPropertyPage _base_intelligence
+ # _base_intelligence.section
+ ## test_prog__rpg__races__Race___base_intelligence.intro
+
+MPropertyPage _base_strength
+ # _base_strength.section
+ ## test_prog__rpg__races__Race___base_strength.intro
+
MPropertyPage base_endurance
# base_endurance.section
## test_prog__rpg__races__Race__base_endurance.intro
#### test_prog__tests-__TestGame__player_characters.lin
### test_prog__tests-__TestGame__player_characters_61d.definition
+MPropertyPage _player_characters
+ # _player_characters.section
+ ## test_prog__tests-__TestGame___player_characters.intro
+
MPropertyPage player_characters=
# player_characters=.section
## test_prog__tests-__TestGame__player_characters_61d.intro
-Generated 114 pages
+Generated 130 pages
list:
- MPropertyPage: 62 (54.38%)
- MClassPage: 23 (20.17%)
- MModulePage: 11 (9.64%)
- ReadmePage: 8 (7.01%)
- MGroupPage: 8 (7.01%)
- SearchPage: 1 (0.87%)
- OverviewPage: 1 (0.87%)
+ MPropertyPage: 77 (59.23%)
+ MClassPage: 23 (17.69%)
+ MModulePage: 12 (9.23%)
+ ReadmePage: 8 (6.15%)
+ MGroupPage: 8 (6.15%)
+ SearchPage: 1 (0.76%)
+ OverviewPage: 1 (0.76%)
Found 212 mentities
list:
MMethodDef: 79 (37.26%)