src: remove remaining references to .nit_compile
[nit.git] / src / doc / doc_phases / doc_html.nit
index f88be01..156a650 100644 (file)
@@ -133,8 +133,8 @@ class RenderHTMLPhase
 
        end
 
-       # A source link template for a given location
-       fun tpl_showsource(location: nullable Location): nullable String
+       # Returns a HTML link for a given `location`.
+       fun html_source_link(location: nullable Location): nullable String
        do
                if location == null then return null
                var source = ctx.opt_source.value
@@ -192,14 +192,7 @@ redef class DocPage
        # Build top menu template if any.
        fun init_topmenu(v: RenderHTMLPhase, doc: DocModel) do
                topmenu = new DocTopMenu
-               var brand = v.ctx.opt_custom_brand.value
-               if brand != null then
-                       var tpl = new Template
-                       tpl.add "<span class='navbar-brand'>"
-                       tpl.add brand
-                       tpl.add "</span>"
-                       topmenu.brand = tpl
-               end
+               topmenu.brand = v.ctx.opt_custom_brand.value
                var title = "Overview"
                if v.ctx.opt_custom_title.value != null then
                        title = v.ctx.opt_custom_title.value.to_s
@@ -379,7 +372,7 @@ redef class MClassPage
                if not mprop_is_local(mprop) then
                        classes.add "inherit"
                        var cls_url = mprop.intro.mclassdef.mclass.nitdoc_url
-                       var def_url = "{cls_url}#{mprop.nitdoc_id}"
+                       var def_url = "{cls_url}#article:{mprop.nitdoc_id}.definition"
                        var lnk = new Link(def_url, mprop.html_name)
                        var mdoc = mprop.intro.mdoc_or_fallback
                        if mdoc != null then lnk.title = mdoc.short_comment
@@ -393,12 +386,28 @@ redef class MClassPage
                else
                        classes.add "redef"
                end
+               var def = select_mpropdef(mprop)
+               var anc = def.html_link_to_anchor
+               anc.href = "#article:{def.nitdoc_id}.definition"
                var lnk = new Template
                lnk.add new DocHTMLLabel.with_classes(classes)
-               lnk.add mprop.html_link_to_anchor
+               lnk.add anc
                return new ListItem(lnk)
        end
 
+       # Get the mpropdef contained in `self` page for a mprop.
+       #
+       # FIXME this method is used to translate a mprop into a mpropdefs for
+       # section linking. A better page structure should avoid this...
+       private fun select_mpropdef(mprop: MProperty): MPropDef do
+               for mclassdef in mentity.mclassdefs do
+                       for mpropdef in mclassdef.mpropdefs do
+                               if mpropdef.mproperty == mprop then return mpropdef
+                       end
+               end
+               abort # FIXME is there a case where the prop is not found?
+       end
+
        private fun mclass_inherited_mprops(v: RenderHTMLPhase, doc: DocModel): Set[MProperty] do
                var res = new HashSet[MProperty]
                var local = mentity.local_mproperties(v.ctx.min_visibility)
@@ -473,7 +482,11 @@ redef class ConcernSection
        redef fun init_html_render(v, doc, page) do
                if not page isa MEntityPage then return
                var mentity = self.mentity
-               if page.mentity isa MModule and mentity isa MModule then
+               if page isa MGroupPage then
+                       html_title = null
+                       toc_title = mentity.html_name
+                       is_toc_hidden = false
+               else if page.mentity isa MModule and mentity isa MModule then
                        var title = new Template
                        if mentity == page.mentity then
                                title.add "in "
@@ -501,11 +514,11 @@ redef class IntroArticle
        redef fun init_html_render(v, doc, page) do
                var mentity = self.mentity
                if mentity isa MModule then
-                       # article.source_link = v.tpl_showsource(mentity.location)
+                       html_source_link = v.html_source_link(mentity.location)
                else if mentity isa MClassDef then
-                       # article.source_link = v.tpl_showsource(mentity.location)
+                       html_source_link = v.html_source_link(mentity.location)
                else if mentity isa MPropDef then
-                       # article.source_link = v.tpl_showsource(mentity.location)
+                       html_source_link = v.html_source_link(mentity.location)
                end
        end
 end
@@ -520,15 +533,9 @@ redef class DefinitionArticle
                        title.add mentity.html_namespace
                        html_title = title
                        toc_title = mentity.html_name
-                       # article.source_link = v.tpl_showsource(mentity.location)
-               else if mentity isa MClass then
-                       var title = new Template
-                       title.add mentity.html_icon
-                       title.add mentity.html_link
-                       html_title = title
-                       html_subtitle = mentity.html_namespace
-                       toc_title = mentity.html_name
-                       is_no_body = true
+                       if mentity isa MModule then
+                               html_source_link = v.html_source_link(mentity.location)
+                       end
                else if mentity isa MClassDef then
                        var title = new Template
                        title.add "in "
@@ -536,7 +543,7 @@ redef class DefinitionArticle
                        html_title = mentity.html_declaration
                        html_subtitle = title
                        toc_title = "in {mentity.html_name}"
-                       # article.source_link = v.tpl_showsource(mentity.location)
+                       html_source_link = v.html_source_link(mentity.location)
                        if page isa MEntityPage and mentity.is_intro and mentity.mmodule != page.mentity then
                                is_short_comment = true
                        end
@@ -556,7 +563,10 @@ redef class DefinitionArticle
                                html_title = title
                                toc_title = "in {mentity.mclassdef.html_name}"
                        end
-                       # article.source_link = v.tpl_showsource(mentity.location)
+                       html_source_link = v.html_source_link(mentity.location)
+               end
+               if page isa MGroupPage and mentity isa MModule then
+                       is_toc_hidden = true
                end
                super
        end
@@ -587,13 +597,3 @@ redef class GraphArticle
                fmap.close
        end
 end
-
-redef class Location
-       # Github url based on this location
-       fun github(gitdir: String): String do
-               var base_dir = getcwd.join_path(gitdir).simplify_path
-               var file_loc = getcwd.join_path(file.filename).simplify_path
-               var gith_loc = file_loc.substring(base_dir.length + 1, file_loc.length)
-               return "{gith_loc}:{line_start},{column_start}--{line_end},{column_end}"
-       end
-end