src/doc_commands: merge Article and Comment commands
[nit.git] / src / web / api_docdown.nit
index e2721a4..80c50c7 100644 (file)
@@ -231,7 +231,7 @@ redef class DocCommand
        end
 end
 
-redef class ArticleCommand
+redef class CommentCommand
        redef fun render(v, token, model) do
                var name = arg
                var mentity = v.find_mentity(model, name)
@@ -242,25 +242,19 @@ redef class ArticleCommand
                        return
                end
                v.add "<h3>"
-               v.write_mentity_link(mentity)
-               v.add " - "
-               v.emit_text mdoc.synopsis
+               if not opts.has_key("no-link") then
+                       v.write_mentity_link(mentity)
+               end
+               if not opts.has_key("no-link") and not opts.has_key("no-synopsis") then
+                       v.add " - "
+               end
+               if not opts.has_key("no-synopsis") then
+                       v.emit_text mdoc.html_synopsis.write_to_string
+               end
                v.add "</h3>"
-               v.add v.processor.process(mdoc.comment).write_to_string
-       end
-end
-
-redef class CommentCommand
-       redef fun render(v, token, model) do
-               var name = arg
-               var mentity = v.find_mentity(model, name)
-               if mentity == null then return
-               var mdoc = mentity.mdoc_or_fallback
-               if mdoc == null then
-                       v.write_warning("no MDoc for mentity `{name}`")
-                       return
+               if not opts.has_key("no-comment") then
+                       v.add v.processor.process(mdoc.comment).write_to_string
                end
-               v.add v.processor.process(mdoc.comment).write_to_string
        end
 end