From 6a1213d5c152ddfe2410981763a6c4b2b958affc Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 29 Aug 2017 18:27:23 -0400 Subject: [PATCH] nitdoc: remove warnings from doc_readme Signed-off-by: Alexandre Terrasa --- src/doc/doc_phases/doc_readme.nit | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/doc/doc_phases/doc_readme.nit b/src/doc/doc_phases/doc_readme.nit index c026b77..f80b7af 100644 --- a/src/doc/doc_phases/doc_readme.nit +++ b/src/doc/doc_phases/doc_readme.nit @@ -38,7 +38,8 @@ class ReadmePhase 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 @@ -51,14 +52,15 @@ 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 @@ -91,6 +93,7 @@ class ReadmeMdEmitter # 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 @@ -119,6 +122,7 @@ class ReadmeMdEmitter # 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 @@ -187,12 +191,12 @@ class ReadmeDecorator 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 @@ -201,7 +205,7 @@ class ReadmeDecorator 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 @@ -223,8 +227,9 @@ class ReadmeDecorator # 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 -- 1.7.9.5