1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2008 Jean Privat <jean@pryen.org>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 import abstract_compiler
24 private var toolcontext
: ToolContext
25 private var model
: Model
26 private var modelbuilder
: ModelBuilder
27 private var mainmodule
: MModule
28 private var arguments
: Array[String]
29 private var destinationdir
: nullable String
30 private var sharedir
: nullable String
32 private var opt_dir
= new OptionString("Directory where doc is generated", "-d", "--dir")
33 private var opt_source
= new OptionString("What link for source (%f for filename, %l for first line, %L for last line)", "--source")
34 private var opt_sharedir
= new OptionString("Directory containing the nitdoc files", "--sharedir")
35 private var opt_nodot
= new OptionBool("Do not generate graphes with graphiviz", "--no-dot")
37 init(toolcontext
: ToolContext) do
38 # We need a model to collect stufs
39 self.toolcontext
= toolcontext
40 self.arguments
= toolcontext
.option_context
.rest
41 toolcontext
.option_context
.add_option
(opt_dir
)
42 toolcontext
.option_context
.add_option
(opt_source
)
43 toolcontext
.option_context
.add_option
(opt_sharedir
)
44 toolcontext
.option_context
.add_option
(opt_nodot
)
47 if arguments
.length
< 1 then
48 toolcontext
.option_context
.usage
53 modelbuilder
= new ModelBuilder(model
, toolcontext
)
55 # Here we load an process std modules
56 var mmodules
= modelbuilder
.parse_and_build
([arguments
.first
])
57 if mmodules
.is_empty
then return
58 modelbuilder
.full_propdef_semantic_analysis
59 assert mmodules
.length
== 1
60 self.mainmodule
= mmodules
.first
63 private fun process_options
do
64 if not opt_dir
.value
is null then
65 destinationdir
= opt_dir
.value
67 destinationdir
= "nitdoc_directory"
69 if not opt_sharedir
.value
is null then
70 sharedir
= opt_sharedir
.value
72 var dir
= "NIT_DIR".environ
74 dir
= "{sys.program_name.dirname}/../share/nitdoc"
76 dir
= "{dir}/share/nitdoc"
79 if sharedir
is null then
80 print
"Error: Cannot locate nitdoc share files. Uses --sharedir or envvar NIT_DIR"
83 dir
= "{sharedir.to_s}/scripts/js-facilities.js"
84 if sharedir
is null then
85 print
"Error: Invalid nitdoc share files. Check --sharedir or envvar NIT_DIR"
92 if arguments
.length
== 1 then
93 # Create destination dir if it's necessary
94 if not destinationdir
.file_exists
then destinationdir
.mkdir
95 sys
.system
("cp -r {sharedir.to_s}/* {destinationdir.to_s}/")
104 var overviewpage
= new NitdocOverview.with
(modelbuilder
.nmodules
, self.opt_nodot
.value
, destinationdir
.to_s
)
105 overviewpage
.save
("{destinationdir.to_s}/index.html")
109 var fullindex
= new NitdocFullindex.with
(model
.mmodules
)
110 fullindex
.save
("{destinationdir.to_s}/full-index.html")
114 for mod
in modelbuilder
.nmodules
do
115 var modulepage
= new NitdocModules.with
(mod
)
116 modulepage
.save
("{destinationdir.to_s}/{mod.mmodule.name}.html")
121 for amodule
in modelbuilder
.nmodules
do
122 for mclass
, aclassdef
in amodule
.mclass2nclassdef
do
123 mclass
.amodule
(modelbuilder
.mmodule2nmodule
)
124 var classpage
= new NitdocMClasses.with
(mclass
, aclassdef
)
125 classpage
.save
("{destinationdir.to_s}/{mclass.name}.html")
135 var amodules
: Array[AModule]
137 # Init with Array[AModule] to get all ifnormations about each MModule containt in a program
138 # opt_nodot to inform about the graph gen
139 # destination: to know where will be saved dot files
140 init with
(modules
: Array[AModule], opt_nodot
: Bool, destination
: String) do
141 self.amodules
= modules
142 self.opt_nodot
= opt_nodot
143 self.destinationdir
= destination
148 add
("title").text
("Overview | Nit Standard Library")
153 open
("nav").add_class
("main")
155 add
("li").add_class
("current").text
("Overview")
157 add_html
("<a href=\"full-index
.html\
">Full Index</a>")
159 open
("li").attr
("id", "liGitHub")
160 open
("a").add_class
("btn").attr
("id", "logGitHub")
161 add
("img").attr
("id", "imgGitHub").attr
("src", "resources/icons/github-icon.png")
163 open
("div").add_class
("popover bottom")
164 add
("div").add_class
("arrow").text
(" ")
165 open
("div").add_class
("githubTitle")
166 add
("h3").text
("Github Sign In")
169 add
("label").attr
("id", "lbloginGit").text
("Username")
170 add
("input").attr
("id", "loginGit").attr
("name", "login").attr
("type", "text")
171 open
("label").attr
("id", "logginMessage").text
("Hello ")
172 open
("a").attr
("id", "githubAccount")
173 add
("strong").attr
("id", "nickName").text
(" ")
178 add
("label").attr
("id", "lbpasswordGit").text
("Password")
179 add
("input").attr
("id", "passwordGit").attr
("name", "password").attr
("type", "password")
180 open
("div").attr
("id", "listBranches")
181 add
("label").attr
("id", "lbBranches").text
("Branch")
182 add
("select").add_class
("dropdown").attr
("id", "dropBranches").attr
("name", "dropBranches").attr
("tabindex", "1").text
(" ")
186 add
("label").attr
("id", "lbrepositoryGit").text
("Repository")
187 add
("input").attr
("id", "repositoryGit").attr
("name", "repository").attr
("type", "text")
190 add
("label").attr
("id", "lbbranchGit").text
("Branch")
191 add
("input").attr
("id", "branchGit").attr
("name", "branch").attr
("type", "text")
194 add
("a").attr
("id", "signIn").text
("Sign In")
205 open
("div").add_class
("page")
206 open
("div").add_class
("content fullpage")
207 add
("h1").text
("Nit Standard Library")
208 open
("article").add_class
("overview")
209 add_html
("<p>Documentation for the standard library of Nit<br />Version jenkins-component=stdlib-19<br />Date: TODAY</p>")
211 open
("article").add_class
("overview")
212 add
("h2").text
("Modules")
220 add
("footer").text
("Nit standard library. Version jenkins-component=stdlib-19.")
224 var ls
= new List[nullable MModule]
225 for amodule
in amodules
do
226 var mmodule
= amodule
.mmodule
.public_owner
227 if mmodule
!= null and not ls
.has
(mmodule
) then
229 add
("a").attr
("href", "{mmodule.name}.html").text
("{mmodule.to_s} ")
230 add_html
(amodule
.comment
)
237 fun process_generate_dot
do
239 op
.append
("digraph dep \{ rankdir=BT; node[shape=none,margin=0,width=0,height=0,fontsize=10]; edge[dir=none,color=gray]; ranksep=0.2; nodesep=0.1;\n")
240 for amodule
in amodules
do
241 op
.append
("\"{amodule.mmodule.name}\
"[URL=\"{amodule.mmodule.name}.html\
"];\n")
242 for mmodule2
in amodule
.mmodule
.in_importation
.direct_greaters
do
243 op
.append
("\"{amodule.mmodule.name}\
"->\"{mmodule2.name}\
";\n")
247 generate_dot
(op
.to_s
, "dep", "Modules hierarchy")
252 class NitdocFullindex
255 var mmodules
: Array[MModule]
257 init with
(mmodules
: Array[MModule]) do
258 self.mmodules
= mmodules
265 add
("title").text
("Full Index | Nit Standard Library")
270 open
("nav").add_class
("main")
273 add_html
("<a href=\"index
.html\
">Overview</a>")
275 add
("li").add_class
("current").text
("Full Index")
276 open
("li").attr
("id", "liGitHub")
277 open
("a").add_class
("btn").attr
("id", "logGitHub")
278 add
("img").attr
("id", "imgGitHub").attr
("src", "resources/icons/github-icon.png")
280 open
("div").add_class
("popover bottom")
281 add
("div").add_class
("arrow").text
(" ")
282 open
("div").add_class
("githubTitle")
283 add
("h3").text
("Github Sign In")
286 add
("label").attr
("id", "lbloginGit").text
("Username")
287 add
("input").attr
("id", "loginGit").attr
("name", "login").attr
("type", "text")
288 open
("label").attr
("id", "logginMessage").text
("Hello ")
289 open
("a").attr
("id", "githubAccount")
290 add
("strong").attr
("id", "nickName").text
(" ")
295 add
("label").attr
("id", "lbpasswordGit").text
("Password")
296 add
("input").attr
("id", "passwordGit").attr
("name", "password").attr
("type", "password")
297 open
("div").attr
("id", "listBranches")
298 add
("label").attr
("id", "lbBranches").text
("Branch")
299 add
("select").add_class
("dropdown").attr
("id", "dropBranches").attr
("name", "dropBranches").attr
("tabindex", "1").text
(" ")
303 add
("label").attr
("id", "lbrepositoryGit").text
("Repository")
304 add
("input").attr
("id", "repositoryGit").attr
("name", "repository").attr
("type", "text")
307 add
("label").attr
("id", "lbbranchGit").text
("Branch")
308 add
("input").attr
("id", "branchGit").attr
("name", "branch").attr
("type", "text")
311 add
("a").attr
("id", "signIn").text
("Sign In")
322 open
("div").add_class
("page")
323 open
("div").add_class
("content fullpage")
324 add
("h1").text
("Full Index")
328 add
("footer").text
("Nit standard library. Version jenkins-component=stdlib-19.")
337 # Add to content modules column
339 var ls
= new List[nullable MModule]
340 open
("article").add_class
("modules filterable")
341 add
("h2").text
("Modules")
343 for mmodule
in mmodules
do
344 if mmodule
.public_owner
!= null and not ls
.has
(mmodule
.public_owner
) then
345 ls
.add
(mmodule
.public_owner
)
347 add
("a").attr
("href", "{mmodule.public_owner.name}.html").text
(mmodule
.public_owner
.name
)
355 # Add to content classes modules
356 fun classes_column
do
357 open
("article").add_class
("classes filterable")
358 add
("h2").text
("Classes")
361 for mclass
in mmodules
.first
.imported_mclasses
do
363 add
("a").attr
("href", "{mclass.name}.html").text
(mclass
.name
)
371 # Insert the properties column of fullindex page
372 fun properties_column
do
373 open
("article").add_class
("properties filterable")
374 add
("h2").text
("Properties")
377 for method
in mmodules
.first
.imported_methods
do
378 if method
.visibility
is none_visibility
or method
.visibility
is intrude_visibility
then continue
379 open
("li").add_class
("intro")
380 add
("span").attr
("title", "introduction").text
("I")
382 add
("a").attr
("href", "{method.local_class.name}.html").attr
("title", "").text
("{method.name} ({method.local_class.name})")
386 for method
in mmodules
.first
.redef_methods
do
387 if method
.visibility
is none_visibility
or method
.visibility
is intrude_visibility
then continue
388 open
("li").add_class
("redef")
389 add
("span").attr
("title", "redefinition").text
("R")
391 add
("a").attr
("href", "{method.local_class.name}.html").attr
("title", "").text
("{method.name} ({method.local_class.name})")
405 var modulename
: String
406 init with
(amodule
: AModule) do
407 self.amodule
= amodule
408 self.modulename
= self.amodule
.mmodule
.name
415 add
("title").text
("{modulename} module | {amodule.short_comment}")
420 open
("nav").add_class
("main")
423 add_html
("<a href=\"index
.html\
">Overview</a>")
425 add
("li").add_class
("current").text
(modulename
)
427 add_html
("<a href=\"full-index
.html\
" >Full Index</a>")
429 open
("li").attr
("id", "liGitHub")
430 open
("a").add_class
("btn").attr
("id", "logGitHub")
431 add
("img").attr
("id", "imgGitHub").attr
("src", "resources/icons/github-icon.png")
433 open
("div").add_class
("popover bottom")
434 add
("div").add_class
("arrow").text
(" ")
435 open
("div").add_class
("githubTitle")
436 add
("h3").text
("Github Sign In")
439 add
("label").attr
("id", "lbloginGit").text
("Username")
440 add
("input").attr
("id", "loginGit").attr
("name", "login").attr
("type", "text")
441 open
("label").attr
("id", "logginMessage").text
("Hello ")
442 open
("a").attr
("id", "githubAccount")
443 add
("strong").attr
("id", "nickName").text
(" ")
448 add
("label").attr
("id", "lbpasswordGit").text
("Password")
449 add
("input").attr
("id", "passwordGit").attr
("name", "password").attr
("type", "password")
450 open
("div").attr
("id", "listBranches")
451 add
("label").attr
("id", "lbBranches").text
("Branch")
452 add
("select").add_class
("dropdown").attr
("id", "dropBranches").attr
("name", "dropBranches").attr
("tabindex", "1").text
(" ")
456 add
("label").attr
("id", "lbrepositoryGit").text
("Repository")
457 add
("input").attr
("id", "repositoryGit").attr
("name", "repository").attr
("type", "text")
460 add
("label").attr
("id", "lbbranchGit").text
("Branch")
461 add
("input").attr
("id", "branchGit").attr
("name", "branch").attr
("type", "text")
464 add
("a").attr
("id", "signIn").text
("Sign In")
475 open
("div").add_class
("page")
479 add
("footer").text
("Nit standard library. Version jenkins-component=stdlib-19.")
482 # Insert all tags in content part
484 open
("div").add_class
("content")
485 add
("h1").text
(modulename
)
486 add
("div").add_class
("subtitle").text
("module {modulename}")
493 # Insert module comment in the content
494 fun module_comment
do
495 var doc
= amodule
.comment
496 open
("div").attr
("id", "description")
497 add
("pre").add_class
("text_label").text
(doc
)
498 add
("textarea").add_class
("edit").attr
("rows", "1").attr
("cols", "76").attr
("id", "fileContent").text
(" ")
499 add
("a").attr
("id", "cancelBtn").text
("Cancel")
500 add
("a").attr
("id", "commitBtn").text
("Commit")
501 add
("pre").add_class
("text_label").attr
("id", "preSave").attr
("type", "2")
506 var mmodule
= amodule
.mmodule
507 open
("div").add_class
("menu")
509 add
("h3").text
("Module Hierarchy").attr
("style","cursor: pointer;")
510 if mmodule
.in_importation
.direct_greaters
.length
> 0 then
511 add_html
("<h4>All dependencies</h4><ul>")
512 for m
in mmodule
.in_importation
.direct_greaters
do
513 if m
== mmodule
or mmodule
== m
.public_owner
then continue
515 add
("a").attr
("href", "{m.name}.html").text
(m
.name
)
520 if mmodule
.in_importation
.greaters
.length
> 0 then
521 add_html
("<h4>All clients</h4><ul>")
522 for m
in mmodule
.in_importation
.greaters
do
523 if m
== mmodule
then continue
525 add
("a").attr
("href", "{m.name}.html").text
(m
.name
)
531 if mmodule
.in_nesting
.direct_greaters
.length
> 0 then
533 add
("h3").text
("Nested Modules").attr
("style","cursor: pointer;")
535 for m
in mmodule
.in_nesting
.direct_greaters
do
537 add
("a").attr
("href", "{m.name}.html").text
(m
.name
)
548 open
("div").add_class
("module")
549 open
("article").add_class
("classes filterable")
550 add
("h2").text
("Classes")
552 for c
, state
in amodule
.mmodule
.mclasses
do
554 if state
== c_is_intro
or state
== c_is_imported
then
555 open
("li").add_class
("intro")
556 add
("span").attr
("title", "introduced in this module").text
("I ")
558 open
("li").add_class
("redef")
559 add
("span").attr
("title", "refined in this module").text
("R ")
561 add
("a").attr
("href", "{name}.html").text
(name
)
570 open
("article").add_class
("properties filterable")
571 add_html
("<h2>Properties</h2>")
573 for method
in amodule
.mmodule
.imported_methods
do
574 if method
.visibility
is none_visibility
or method
.visibility
is intrude_visibility
then continue
575 open
("li").add_class
("intro")
576 add
("span").attr
("title", "introduction").text
("I")
578 add
("a").attr
("href", "{method.local_class.name}.html").attr
("title", "").text
("{method.name} ({method.local_class.name})")
582 for method
in amodule
.mmodule
.redef_methods
do
583 if method
.visibility
is none_visibility
or method
.visibility
is intrude_visibility
then continue
584 open
("li").add_class
("redef")
585 add
("span").attr
("title", "redefinition").text
("R")
587 add
("a").attr
("href", "{method.local_class.name}.html").attr
("title", "").text
("{method.name} ({method.local_class.name})")
597 # Nit Standard Library
602 var aclassdef
: AClassdef
603 var stdclassdef
: nullable AStdClassdef
604 var public_owner
: nullable MModule
606 init with
(mclass
: MClass, aclassdef
: AClassdef) do
608 self.aclassdef
= aclassdef
609 if aclassdef
isa AStdClassdef then self.stdclassdef
= aclassdef
610 self.public_owner
= mclass
.intro_mmodule
.public_owner
617 add
("title").text
("{self.mclass.name} class | Nit Standard Library")
622 open
("nav").add_class
("main")
625 add_html
("<a href=\"index
.html\
">Overview</a>")
628 if public_owner
is null then
629 add_html
("<a href=\"{mclass.intro_mmodule.name}.html\
">{mclass.intro_mmodule.name}</a>")
631 add_html
("<a href=\"{public_owner.name}.html\
">{public_owner.name}</a>")
634 add
("li").add_class
("current").text
(mclass
.name
)
636 add_html
("<a href=\"full-index
.html\
" >Full Index</a>")
638 open
("li").attr
("id", "liGitHub")
639 open
("a").add_class
("btn").attr
("id", "logGitHub")
640 add
("img").attr
("id", "imgGitHub").attr
("src", "resources/icons/github-icon.png")
642 open
("div").add_class
("popover bottom")
643 add
("div").add_class
("arrow").text
(" ")
644 open
("div").add_class
("githubTitle")
645 add
("h3").text
("Github Sign In")
648 add
("label").attr
("id", "lbloginGit").text
("Username")
649 add
("input").attr
("id", "loginGit").attr
("name", "login").attr
("type", "text")
650 open
("label").attr
("id", "logginMessage").text
("Hello ")
651 open
("a").attr
("id", "githubAccount")
652 add
("strong").attr
("id", "nickName").text
(" ")
657 add
("label").attr
("id", "lbpasswordGit").text
("Password")
658 add
("input").attr
("id", "passwordGit").attr
("name", "password").attr
("type", "password")
659 open
("div").attr
("id", "listBranches")
660 add
("label").attr
("id", "lbBranches").text
("Branch")
661 add
("select").add_class
("dropdown").attr
("id", "dropBranches").attr
("name", "dropBranches").attr
("tabindex", "1").text
(" ")
665 add
("label").attr
("id", "lbrepositoryGit").text
("Repository")
666 add
("input").attr
("id", "repositoryGit").attr
("name", "repository").attr
("type", "text")
669 add
("label").attr
("id", "lbbranchGit").text
("Branch")
670 add
("input").attr
("id", "branchGit").attr
("name", "branch").attr
("type", "text")
673 add
("a").attr
("id", "signIn").text
("Sign In")
684 open
("div").add_class
("page")
687 add
("footer").text
("Nit standard library. Version jenkins-component=stdlib-19.")
690 # Insert all tags in content part
692 open
("div").add_class
("menu")
696 open
("div").add_class
("content")
701 fun properties_column
do
702 open
("nav").add_class
("properties filterable")
703 add
("h3").text
("Properties")
705 if mclass
.virtual_types
.length
> 0 then
706 add
("h4").text
("Virtual Types")
708 for prop
in mclass
.virtual_types
do
709 add_html
("<li class=\"redef\
"><span title=\"Redefined\
">R</span><a href=\"{prop.link_anchor}\
">{prop.name}</a></li>")
713 if mclass
.constructors
.length
> 0 then
714 add
("h4").text
("Constructors")
716 for prop
in mclass
.constructors
do
717 add_html
("<li class=\"intro\
"><span title=\"Introduced\
">I</span><a href=\"{prop.link_anchor}\
">{prop.name}</a></li>")
721 add
("h4").text
("Methods")
723 if mclass
.intro_methods
.length
> 0 then
724 for prop
in mclass
.intro_methods
do
725 if prop
.visibility
is public_visibility
or prop
.visibility
is protected_visibility
then add_html
("<li class=\"intro\
"><span title=\"Introduced\
">I</span><a href=\"{prop.link_anchor}\
">{prop.name}</a></li>")
728 if mclass
.inherited_methods
.length
> 0 then
729 for prop
in mclass
.inherited_methods
do
730 if prop
.visibility
is public_visibility
or prop
.visibility
is protected_visibility
then add_html
("<li class=\"inherit\
"><span title=\"Inherited\
">H</span><a href=\"{prop.link_anchor}\
">{prop.name}</a></li>")
733 if mclass
.redef_methods
.length
> 0 then
734 for prop
in mclass
.redef_methods
do
735 if prop
.visibility
is public_visibility
or prop
.visibility
is protected_visibility
then add_html
("<li class=\"redef\
"><span title=\"Refined\
">R</span><a href=\"{prop.link_anchor}\
">{prop.name}</a></li>")
742 fun inheritance_column
do
744 add
("h3").text
("Inheritance")
745 if mclass
.parents
.length
> 0 then
746 add
("h4").text
("Superclasses")
748 for sup
in mclass
.parents
do add_html
("<li><a href=\"{sup.name}.html\
">{sup.name}</a></li>")
752 if mclass
.descendants
.length
is 0 then
753 add
("h4").text
("No Known Subclasses")
754 else if mclass
.descendants
.length
<= 100 then
755 add
("h4").text
("Subclasses")
757 for sub
in mclass
.descendants
do add_html
("<li><a href=\"{sub.name}\
">{sub.name}</a></li>")
759 else if mclass
.children
.length
<= 100 then
760 add
("h4").text
("Direct Subclasses Only")
762 for sub
in mclass
.children
do add_html
("<li><a href=\"{sub.name}\
">{sub.name}</a></li>")
765 add
("h4").text
("Too much Subclasses to list")
772 var lmmodule
= new List[MModule]
773 # Insert the subtitle part
774 add
("h1").text
(mclass
.name
)
775 open
("div").add_class
("subtitle")
776 if mclass
.visibility
is none_visibility
then subtitle
+= "private "
777 subtitle
+= "{mclass.kind} <a href=\"{mclass.public_owner.name}.html\
">{mclass.public_owner.name}</a>::{mclass.name}"
780 add_html
("<div style=\"float
: right
;\
"><a id=\"lblDiffCommit\
"></a></div>")
781 # We add the class description
782 open
("section").add_class
("description")
783 if not stdclassdef
is null and not stdclassdef
.comment
.is_empty
then add_html
("<pre class=\"text_label\
" title=\"122\
" name=\"\
" tag=\"{mclass.mclassdefs.first.location.to_s}\
" type=\"2\
">{stdclassdef.comment} </pre><textarea id=\"fileContent\
" class=\"edit\
" cols=\"76\
" rows=\"1\
" style=\"display
: none
;\
"></textarea><a id=\"cancelBtn\
" style=\"display
: none
;\
">Cancel</a><a id=\"commitBtn\
" style=\"display
: none
;\
">Commit</a><pre id=\"preSave\
" class=\"text_label\
" type=\"2\
"></pre>")
785 open
("section").add_class
("concerns")
786 add
("h2").add_class
("section-header").text
("Concerns")
788 for owner
, childs
in mclass
.concerns
do
790 add_html
("<a href=\"#MOD_{owner.name}\">{owner.name}</a>: {owner.amodule.short_comment}")
791 if not childs
is null then
793 for child
in childs
.as(not null) do add_html
("<li><a href=\"#MOD_{child.name}\">{child.name}</a>: {child.amodule.short_comment} </li>")
800 # Insert virtual types if there is almost one
801 if mclass
.virtual_types
.length
> 0 or (stdclassdef
!= null and stdclassdef
.n_formaldefs
.length
> 0) then
802 open
("section").add_class
("types")
803 add
("h2").text
("Formal and Virtual Types")
804 if mclass
.virtual_types
.length
> 0 then for prop
in mclass
.virtual_types
do description
(prop
)
805 if stdclassdef
.n_formaldefs
.length
> 0 then
806 for prop
in stdclassdef
.n_formaldefs
do
807 open
("article").attr
("id", "FT_Object_{prop.collect_text}")
808 open
("h3").add_class
("signature").text
("{prop.collect_text}: nullable ")
809 add_html
("<a title=\"The root of the
class hierarchy
.\
" href=\"Object.html\
">Object</a>")
811 add_html
("<div class=\"info\
">formal generic type</div>")
817 # Insert constructors if there is almost one
818 if mclass
.constructors
.length
> 0 then
819 open
("section").add_class
("constructors")
820 add
("h2").add_class
("section-header").text
("Constructors")
821 for prop
in mclass
.constructors
do description
(prop
)
826 # Insert description tags for 'prop'
827 fun description
(prop
: MProperty) do
828 open
("article").add_class
("fun public {if prop.is_redef then "redef" else ""}").attr
("id", "{prop.anchor}")
830 if prop
.apropdef
!= null then sign
+= prop
.apropdef
.signature
831 add_html
("<h3 class=\"signature\
">{sign}</h3>")
832 add_html
("<div class=\"info\
">{if prop.is_redef then "redef" else ""} fun {prop.intro_mclassdef.namespace(mclass)}::{prop.name}</div><div style=\"float
: right
;\
"><a id=\"lblDiffCommit\
"></a></div>")
834 open
("div").add_class
("description")
835 if prop
.apropdef
is null or prop
.apropdef
.comment
== "" then
836 add_html
("<a class=\"newComment\
" title=\"32\
" tag=\"\
">New Comment</a>")
838 add_html
("<pre class=\"text_label\
" title=\"\
" name=\"\
" tag=\"\
" type=\"1\
">{prop.apropdef.comment}</pre>")
840 add_html
("<textarea id=\"fileContent\
" class=\"edit\
" cols=\"76\
" rows=\"1\
" style=\"display
: none
;\
"></textarea><a id=\"cancelBtn\
" style=\"display
: none
;\
">Cancel</a><a id=\"commitBtn\
" style=\"display
: none
;\
">Commit</a><pre id=\"preSave\
" class=\"text_label\
" type=\"2\
"></pre>")
842 if prop
.local_class
!= mclass
then add_html
("inherited from {prop.local_class.intro_mmodule.name} ")
843 #TODO display show code if doc github
844 add_html
("defined by the module <a href=\"{prop.intro_mclassdef.mmodule.name}.html\
">{prop.intro_mclassdef.mmodule.name}</a> (<a href=\"\
">show code</a>).")
846 for parent
in mclass
.parents
do
847 if prop
isa MMethod then if parent
.constructors
.has
(prop
) then add_html
(" Previously defined by: <a href=\"{parent.intro_mmodule.name}.html\
">{parent.intro_mmodule.name}</a> for <a href=\"{parent.name}.html\
">{parent.name}</a>.")
861 var destinationdir
: String
864 add
("meta").attr
("charset", "utf-8")
865 add
("script").attr
("type", "text/javascript").attr
("src", "scripts/jquery-1.7.1.min.js")
866 add
("script").attr
("type", "text/javascript").attr
("src", "quicksearch-list.js")
867 add
("script").attr
("type", "text/javascript").attr
("src", "scripts/js-facilities.js")
868 add
("link").attr
("rel", "stylesheet").attr
("href", "styles/main.css").attr
("type", "text/css").attr
("media", "screen")
871 redef fun body
do header
874 # Generate a clickable graphviz image using a dot content
875 fun generate_dot
(dot
: String, name
: String, alt
: String) do
876 if opt_nodot
then return
877 var file
= new OFStream.open
("{self.destinationdir}/{name}.dot")
880 sys
.system
("\{ test -f {self.destinationdir}/{name}.png && test -f {self.destinationdir}/{name}.s.dot && diff {self.destinationdir}/{name}.dot {self.destinationdir}/{name}.s.dot >/dev/null 2>&1 ; \} || \{ cp {self.destinationdir}/{name}.dot {self.destinationdir}/{name}.s.dot && dot -Tpng -o{self.destinationdir}/{name}.png -Tcmapx -o{self.destinationdir}/{name}.map {self.destinationdir}/{name}.s.dot ; \}")
881 open
("article").add_class
("graph")
882 add
("img").attr
("src", "{name}.png").attr
("usemap", "#{name}").attr
("style", "margin:auto").attr
("alt", "{alt}")
884 var fmap
= new IFStream.open
("{self.destinationdir}/{name}.map")
885 add_html
(fmap
.read_all
)
892 private fun comment
: String do
894 if n_moduledecl
is null or n_moduledecl
.n_doc
is null then ret
895 if n_moduledecl
.n_doc
is null then return ""
896 for t
in n_moduledecl
.n_doc
.n_comment
do
897 ret
+= "{t.text.replace("# ", "")}"
902 private fun short_comment
: String do
904 if n_moduledecl
!= null and n_moduledecl
.n_doc
!= null then
905 var txt
= n_moduledecl
.n_doc
.n_comment
.first
.text
906 txt
= txt
.replace
("# ", "")
907 txt
= txt
.replace
("\n", "")
916 var amodule
: nullable AModule
918 # Get the list of all methods in a module
919 fun imported_methods
: Set[MMethod] do
920 var methods
= new HashSet[MMethod]
921 for mclass
in imported_mclasses
do
922 for method
in mclass
.intro_methods
do
929 # Get the list aof all refined methods in a module
930 fun redef_methods
: Set[MMethod] do
931 var methods
= new HashSet[MMethod]
932 for mclass
in redef_mclasses
do
933 for method
in mclass
.intro_methods
do
941 redef class MProperty
944 var apropdef
: nullable APropdef
946 redef init(intro_mclassdef
: MClassDef, name
: String, visibility
: MVisibility)
952 fun local_class
: MClass do
953 var classdef
= self.intro_mclassdef
954 return classdef
.mclass
957 fun class_text
: String do
958 return local_class
.name
961 fun link_anchor
: String do
962 return "{class_text}.html#{anchor}"
965 fun anchor
: String do
966 return "PROP_{c_name}"
973 # Associate all MMethods to each MModule concerns
974 fun all_methods
: HashMap[MModule, Set[MMethod]] do
975 var hm
= new HashMap[MModule, Set[MMethod]]
976 for mmodule
, childs
in concerns
do
977 if not hm
.has_key
(mmodule
) then hm
[mmodule
] = new HashSet[MMethod]
978 for prop
in intro_methods
do
979 if mmodule
== prop
.intro_mclassdef
.mmodule
then
980 prop
.is_redef
= false
981 hm
[mmodule
].add
(prop
)
984 for prop
in redef_methods
do
985 if mmodule
== prop
.intro_mclassdef
.mmodule
then
987 hm
[mmodule
].add
(prop
)
991 if childs
!= null then
992 for child
in childs
do
993 if not hm
.has_key
(child
) then hm
[child
] = new HashSet[MMethod]
994 for prop
in intro_methods
do
995 if child
== prop
.intro_mclassdef
.mmodule
then
996 prop
.is_redef
= false
1000 for prop
in redef_methods
do
1001 if child
== prop
.intro_mclassdef
.mmodule
then
1002 prop
.is_redef
= true
1012 fun public_owner
: MModule do
1013 var owner
= intro_mmodule
1014 if owner
.public_owner
is null then
1017 return owner
.public_owner
.as(not null)
1021 # Associate Amodule to all MModule concern by 'self'
1022 fun amodule
(amodules
: HashMap[MModule, AModule]) do
1023 for owner
, childs
in concerns
do
1024 if childs
!= null then for child
in childs
do child
.amodule
= amodules
[child
]
1025 owner
.amodule
= amodules
[owner
]
1031 redef class AStdClassdef
1032 private fun comment
: String do
1034 if n_doc
!= null then
1035 for t
in n_doc
.n_comment
do
1036 var txt
= t
.text
.replace
("# ", "")
1037 txt
= txt
.replace
("#", "")
1044 private fun short_comment
: String do
1046 if n_doc
!= null then
1047 var txt
= n_doc
.n_comment
.first
.text
1048 txt
= txt
.replace
("# ", "")
1049 txt
= txt
.replace
("\n", "")
1056 redef class ASignature
1060 if not n_params
.is_empty
then
1061 ret
= "{ret}({n_params.join(", ")})"
1063 if n_type
!= null and n_type
.to_s
!= "" then ret
+= " {n_type.to_s}"
1070 var ret
= "{n_id.text}"
1071 if n_type
!= null then
1072 ret
= "{ret}: {n_type.to_s}"
1073 if n_dotdotdot
!= null then ret
= "{ret}..."
1081 var ret
= "<a href=\"{n_id.text}.html\
">{n_id.text}</a>"
1082 if n_kwnullable
!= null then ret
= "nullable {ret}"
1083 if not n_types
.is_empty
then ret
= "{ret}[{n_types.join(", ")}]"
1088 redef class APropdef
1089 private fun short_comment
: String is abstract
1090 private fun signature
: String is abstract
1091 private fun comment
: String is abstract
1094 redef class AAttrPropdef
1095 redef fun short_comment
do
1097 if n_doc
!= null then
1098 var txt
= n_doc
.n_comment
.first
.text
1099 txt
= txt
.replace
("# ", "")
1100 txt
= txt
.replace
("\n", "")
1107 redef class AMethPropdef
1108 redef fun short_comment
do
1110 if n_doc
!= null then
1111 var txt
= n_doc
.n_comment
.first
.text
1112 txt
= txt
.replace
("# ", "")
1113 txt
= txt
.replace
("\n", "")
1119 redef fun signature
: String do
1121 if n_signature
!= null then sign
= " {n_signature.to_s}"
1125 redef private fun comment
: String do
1127 if n_doc
!= null then
1128 for t
in n_doc
.n_comment
do
1129 var txt
= t
.text
.replace
("# ", "")
1130 txt
= txt
.replace
("#", "")
1138 redef class MClassDef
1139 private fun namespace
(mclass
: MClass): String do
1141 if mmodule
.public_owner
is null then
1142 return "{mmodule.full_name}::{mclass.name}"
1143 else if mclass
is self.mclass
then
1144 return "{mmodule.public_owner.name}::{mclass.name}"
1146 return "{mmodule.public_owner.name}::<a href=\"{mclass.name}.html\
">{mclass.name}</a>"
1151 # Create a tool context to handle options and paths
1152 var toolcontext
= new ToolContext
1153 toolcontext
.process_options
1155 # Here we launch the nit index
1156 var nitdoc
= new Nitdoc(toolcontext
)