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 # Wiki internal links handling.
23 # Url to `self` once generated.
24 fun url
: String do return wiki
.config
.root_url
.join_path
(breadcrumbs
.join
("/"))
28 if not is_dirty
and not wiki
.force_render
then return
32 redef class WikiSection
34 # The index page for this section.
36 # If no file `index.md` exists for this section,
37 # a summary is generated using contained articles.
38 var index
: WikiArticle is lazy
do
39 for child
in children
.values
do
40 if child
isa WikiArticle and child
.is_index
then return child
42 return new WikiSectionIndex(wiki
, "index", self)
46 redef class WikiArticle
48 # Headlines ids and titles.
49 var headlines
= new ArrayMap[String, HeadLine]
51 # Is `self` an index page?
53 # Checks if `self.name == "index"`.
54 fun is_index
: Bool do return name
== "index"
57 if parent
== null then
58 return wiki
.config
.root_url
.join_path
("{name}.html")
60 return parent
.url
.join_path
("{name}.html")
66 if not is_dirty
and not wiki
.force_render
or not has_source
then return
67 var md_proc
= new MarkdownProcessor
68 content
= md_proc
.process
(md
.as(not null))
69 headlines
.recover_with
(md_proc
.emitter
.decorator
.headlines
)
73 # A `WikiArticle` that contains the section index tree.
74 class WikiSectionIndex
77 # The section described by `self`.
78 var section
: WikiSection
80 redef fun title
do return section
.title
82 redef fun url
do return section
.url