redef fun apply do
init_output_dir
- for page in doc.pages do
+ for page in doc.pages.values do
page.render(self, doc).write_to_file("{ctx.output_dir.to_s}/{page.html_url}")
end
end
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
# all properties below are roughly copied from `doc_pages`
# Build page title string
- fun init_title(v: RenderHTMLPhase, doc: DocModel) is abstract
+ fun init_title(v: RenderHTMLPhase, doc: DocModel) do end
# 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
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}#{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
else
classes.add "redef"
end
+ var def = select_mpropdef(mprop)
+ var anc = def.html_link_to_anchor
+ anc.href = "#{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)
title.add mentity.html_signature
html_title = title
html_subtitle = mentity.html_namespace
- toc_title = mentity.html_name
+ html_toc_title = mentity.html_name
end
super
end
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
+ html_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 "
- toc_title = "in {mentity.html_name}"
+ html_toc_title = "in {mentity.html_name}"
else
title.add "from "
- toc_title = "from {mentity.html_name}"
+ html_toc_title = "from {mentity.html_name}"
end
title.add mentity.html_namespace
html_title = title
title.add "in "
title.add mentity.html_namespace
html_title = title
- toc_title = "in {mentity.html_name}"
+ html_toc_title = "in {mentity.html_name}"
end
super
end
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
title.add mentity.html_icon
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
+ html_toc_title = mentity.html_name
+ 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 "
title.add mentity.mmodule.html_namespace
html_title = mentity.html_declaration
html_subtitle = title
- toc_title = "in {mentity.html_name}"
- # article.source_link = v.tpl_showsource(mentity.location)
+ html_toc_title = "in {mentity.html_name}"
+ 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
title.add mentity.html_declaration
html_title = title
html_subtitle = mentity.html_namespace
- toc_title = mentity.html_name
+ html_toc_title = mentity.html_name
else
var title = new Template
title.add "in "
title.add mentity.mclassdef.html_link
html_title = title
- toc_title = "in {mentity.mclassdef.html_name}"
+ html_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
redef fun init_html_render(v, doc, page) do
if v.ctx.opt_custom_title.value != null then
self.html_title = v.ctx.opt_custom_title.value.to_s
- self.toc_title = v.ctx.opt_custom_title.value.to_s
+ self.html_toc_title = v.ctx.opt_custom_title.value.to_s
end
self.content = v.ctx.opt_custom_intro.value
super
redef class GraphArticle
redef fun init_html_render(v, doc, page) do
var output_dir = v.ctx.output_dir
- var path = output_dir / id
+ var path = output_dir / graph_id
var path_sh = path.escape_to_sh
var file = new FileWriter.open("{path}.dot")
file.write(dot)
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