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
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_namespace
html_title = title
toc_title = mentity.html_name
- # article.source_link = v.tpl_showsource(mentity.location)
+ if mentity isa MModule then
+ html_source_link = v.html_source_link(mentity.location)
+ end
else if mentity isa MClass then
var title = new Template
title.add mentity.html_icon
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
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
super
end
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
redef var is_hidden = false
redef var is_toc_hidden = true
+ # Link to source to display if any.
+ var html_source_link: nullable Writable is noinit, writable
+
+ redef fun render_title do
+ var lnk = html_source_link
+ if lnk != null then
+ add "<div class='source-link'>"
+ add lnk
+ addn "</div>"
+ end
+ super
+ end
+
redef fun render_body do
var comment = mentity.html_comment
if comment != null then addn comment
# FIXME diff hack
var is_short_comment: Bool = false is writable
+ # Link to source to display if any.
+ var html_source_link: nullable Writable is noinit, writable
+
+ redef fun render_title do
+ var lnk = html_source_link
+ if lnk != null then
+ add "<div class='source-link'>"
+ add lnk
+ addn "</div>"
+ end
+ super
+ end
+
redef fun render_body do
if not is_no_body then
var comment