fun warning(location: nullable MDLocation, page: ReadmePage, message: String) do
var loc = null
if location != null then
- loc = location.to_location(page.mentity.mdoc.location.file)
+ var mdoc = page.mentity.mdoc
+ if mdoc != null then loc = location.to_location(mdoc.location.file)
end
ctx.warning(loc, "readme-warning", message)
end
redef class ReadmePage
redef fun build_content(v, doc) do
- if mentity.mdoc == null then
+ var mdoc = mentity.mdoc
+ if mdoc == null then
v.warning(null, self, "Empty README for group `{mentity}`")
return
end
var proc = new MarkdownProcessor
proc.emitter = new ReadmeMdEmitter(proc, self, v)
proc.emitter.decorator = new ReadmeDecorator
- var md = mentity.mdoc.content.join("\n")
+ var md = mdoc.content.join("\n")
proc.process(md)
end
end
# Called from `add_headline`.
private fun open_section(lvl: Int, title: String) do
var section = new ReadmeSection(title.escape_to_c, title, lvl, processor)
+ var current_section = self.current_section
if current_section == null then
page.root.add_child(section)
else
# This closes the current article, inserts `article` then opens a new article.
private fun add_article(article: DocArticle) do
close_article
+ var current_section = self.current_section
if current_section == null then
page.root.add_child(article)
else
redef type EMITTER: ReadmeMdEmitter
redef fun add_headline(v, block) do
- var txt = block.block.first_line.value
+ var txt = block.block.first_line.as(not null).value
var lvl = block.depth
if not v.context.is_empty then
v.close_article
while v.current_section != null do
- if v.current_section.depth < lvl then break
+ if v.current_section.as(not null).depth < lvl then break
v.close_section
end
end
end
redef fun add_wikilink(v, token) do
- var link = token.link.to_s
+ var link = token.link.as(not null).to_s
var cmd = new DocCommand(link)
if cmd isa UnknownCommand then
# search MEntities by name
# TODO real link
var link = mentity.full_name
if name == null then name = mentity.name
- if comment == null and mentity.mdoc != null then
- comment = mentity.mdoc.synopsis
+ if comment == null then
+ var mdoc = mentity.mdoc
+ if mdoc != null then comment = mdoc.synopsis
end
add_link(v, link, name, comment)
end