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 # Base entities shared by all the nitdoc code
21 # The model of a Nitdoc documentation
24 # Model used to select entities
27 # Mainmodule to resolve linearization
28 var mainmodule
: MModule
30 # ModelBuilder used to retrieve AST nodes
31 var modelbuilder
: ModelBuilder
33 # Catalog for building the homepage
36 # Model filters applied to the whole documentation
37 var filter
: ModelFilter
39 # Specific Markdown processor to use within Nitdoc
40 var md_processor
: MarkdownProcessor is lazy
do
41 var parser
= new CommandParser(model
, mainmodule
, modelbuilder
, catalog
)
42 var proc
= new CmdMarkdownProcessor(parser
)
43 proc
.decorator
= new CmdDecorator(model
)
47 # Specific Markdown processor to use within Nitdoc
48 var inline_processor
: MarkdownProcessor is lazy
do
49 var parser
= new CommandParser(model
, mainmodule
, modelbuilder
, catalog
)
50 var proc
= new CmdMarkdownProcessor(parser
)
51 proc
.decorator
= new CmdInlineDecorator(model
)
55 # Do not generate dot graphs
56 var no_dot
= false is writable
58 # Do not generate higlighted code
59 var no_code
= false is writable
61 # Url to code when `no_code` is true
62 var code_url
: nullable String = null is writable
65 var share_url
: nullable String = null is writable
68 var custom_brand
: nullable String = null is writable
70 # Custom homepage title
71 var custom_title
: nullable String = null is writable
74 var custom_footer
: nullable String = null is writable
76 # Custom homepage intro text
77 var custom_intro
: nullable String = null is writable
79 # Optional tracker url
80 var tracker_url
: nullable String = null is writable
82 # Optional tracker site id
83 var piwik_site_id
: nullable String = null is writable
85 # Used to sort sidebar elements by name.
86 var name_sorter
= new MEntityNameSorter
91 # A documentation page abstraction
95 var title
: String is writable
99 # Nitdoc pages are tabulated.
100 # If a page has only one tab, it is presented as a single page.
101 # With more than one tab, the HTML rendering process adds tab headers and
103 var tabs
: Array[DocTab] = [main_tab
] is lazy
107 # For most pages this tab is suffisent.
108 # Subclasses can add more tabs.
109 var main_tab
= new DocTab("main", "Main")
111 redef fun to_s
do return title
114 # The Nitdoc overview page that displays the nit packages catalog
119 # A DocPage documenting a MEntity
120 abstract class PageMEntity
124 new(mentity
: MEntity) do
125 if mentity
isa MPackage then
126 return new PageMPackage(mentity
)
127 else if mentity
isa MGroup then
128 return new PageMGroup(mentity
)
129 else if mentity
isa MModule then
130 return new PageMModule(mentity
)
131 else if mentity
isa MClass then
132 return new PageMClass(mentity
)
133 else if mentity
isa MProperty then
134 return new PageMProperty(mentity
)
136 print
"Not yet implemented: Page for {mentity.full_name} ({mentity.class_name})"
141 # Type of MEntity documented by this page
142 type MENTITY: MEntity
144 # MEntity documented by this page
147 # For mentities the main tab is the doc tab
148 redef var main_tab
= new DocTab("doc", "Doc", true, "book")
152 # Where the MEntity API (groups, modules, classes, props) is displayed
153 var api_tab
= new DocTab("api", "API", false, "list")
157 # Where the MEntity importation or inheritance is displayed
158 var dep_tab
= new DocTab("inh", "Dependencies", false, "object-align-vertical")
162 # Since all mentities does not have code, this tab in not in the `tabs` list
164 var code_tab
= new DocTab("code", "Code", false, "console")
168 # Since all mentities does not have a linearization, this tab in not in the
169 # `tabs` list by default.
170 var lin_tab
= new DocTab("lin", "Linearization", false, "arrow-down")
172 redef var tabs
= [main_tab
, api_tab
, dep_tab
] is lazy
173 redef var title
is lazy
do return mentity
.name
176 # A documentation page for a MPackage
180 redef type MENTITY: MPackage
181 redef var api_tab
= new DocTab("api", "Groups & Modules", false, "list")
184 # A documentation page about a MGroup
188 redef type MENTITY: MGroup
189 redef var api_tab
= new DocTab("api", "Subgroups & Modules", false, "list")
192 # A documentation page about a MModule
196 redef type MENTITY: MModule
197 redef var api_tab
= new DocTab("api", "Classes", false, "list")
198 redef var dep_tab
= new DocTab("inh", "Importation", false, "object-align-vertical")
199 redef var tabs
= [main_tab
, api_tab
, dep_tab
, code_tab
] is lazy
202 # A documentation page about a MClass
206 redef type MENTITY: MClass
207 redef var api_tab
= new DocTab("api", "All properties", false, "list")
208 redef var dep_tab
= new DocTab("inh", "Inheritance", false, "object-align-vertical")
209 redef var tabs
= [main_tab
, api_tab
, dep_tab
, lin_tab
] is lazy
212 # A documentation page about a MProperty
216 redef type MENTITY: MProperty
217 redef var tabs
= [main_tab
, lin_tab
] is lazy
220 # A page that lists the packages maintained and contributed by a person
225 # Person displayed in this page
228 redef var title
is lazy
do return person
.name
231 # A page that lists the packages related to a tab
236 # Tag displayed in this page
239 redef var title
is lazy
do return tag
245 # MEntities composing the breadcrumbs of a nitdoc page
246 fun nitdoc_breadcrumbs
: Array[MEntity] is abstract
250 redef var nitdoc_breadcrumbs
= [self: MEntity] is lazy
254 redef var nitdoc_breadcrumbs
is lazy
do
255 var parent
= self.parent
256 if parent
!= null then
257 return parent
.nitdoc_breadcrumbs
+ [self]
259 return mpackage
.nitdoc_breadcrumbs
264 redef var nitdoc_breadcrumbs
is lazy
do
265 var mgroup
= self.mgroup
266 if mgroup
!= null then
267 return mgroup
.nitdoc_breadcrumbs
+ [self]
274 redef var nitdoc_breadcrumbs
is lazy
do
275 return intro_mmodule
.nitdoc_breadcrumbs
+ [self]
279 redef class MClassDef
280 redef var nitdoc_breadcrumbs
is lazy
do
281 var res
= new Array[MEntity].from
(mmodule
.nitdoc_breadcrumbs
)
287 redef class MProperty
288 redef var nitdoc_breadcrumbs
is lazy
do
289 var res
= new Array[MEntity].from
(intro_mclassdef
.mclass
.nitdoc_breadcrumbs
)
296 redef var nitdoc_breadcrumbs
is lazy
do
297 var res
= new Array[MEntity].from
(mclassdef
.nitdoc_breadcrumbs
)
303 # Documentation base elements
305 # A documentation tabulated view
308 # Tab uniq id in the page
309 var id
: String is writable
312 var title
: String is writable
314 # Is this tab displayed by default?
315 var is_active
= false is optional
, writable
318 var icon
: nullable String = null is optional
, writable
321 var content
= new Array[StaticCard]
324 var sidebar
= new DocSidebar
326 # Tab metadata sidebar
327 var metadata
= new DocSidebar
330 fun is_empty
: Bool do return content
.is_empty
333 # A fictive tab used to display a link
336 autoinit
(id
, title
, icon
, url
)
338 # Link to open when the tab is clicked
342 # Nitdoc sidebar abstraction
345 # A sidebar contains `StaticCard`
346 var cards
= new Array[StaticCard]
348 # Is this sidebar empty?
349 fun is_empty
: Bool do return cards
.is_empty