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 # Print the generated DocModel in stdout.
17 # Mainly used for tests.
23 redef class ToolContext
25 # File pattern used to link documentation to source code.
26 var opt_test
= new OptionBool("Print test data (metrics and structure)", "--test")
30 option_context
.add_option
(opt_test
)
34 # Display the DocModel in stdout.
39 if not ctx
.opt_test
.value
then return
41 var page_counter
= new Counter[String]
42 var pages
= doc
.pages
.keys
.to_a
43 default_comparator
.sort
(pages
)
45 var page
= doc
.pages
[title
]
46 page_counter
.inc page
.class_name
47 print page
.pretty_print
.write_to_string
49 print
"Generated {doc.pages.length} pages"
50 page_counter
.print_elements
(100)
52 var model_counter
= new Counter[String]
53 for mentity
in doc
.mentities
do
54 model_counter
.inc mentity
.class_name
56 print
"Found {doc.mentities.length} mentities"
57 model_counter
.print_elements
(100)