From c08b29eb83fef3192dc072e4cf54f3f36b7b8928 Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Tue, 7 Nov 2017 10:58:52 +0100
Subject: [PATCH] add -mdr-title option

---
 src/plugins/markdown-report/Report_markdown.mli |  3 +++
 src/plugins/markdown-report/md_gen.ml           | 11 +++++++----
 src/plugins/markdown-report/mdr_params.ml       |  8 ++++++++
 src/plugins/markdown-report/mdr_params.mli      |  3 +++
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/plugins/markdown-report/Report_markdown.mli b/src/plugins/markdown-report/Report_markdown.mli
index 1359dd68361..5edadb17f3d 100644
--- a/src/plugins/markdown-report/Report_markdown.mli
+++ b/src/plugins/markdown-report/Report_markdown.mli
@@ -19,6 +19,9 @@ module FlameGraph: Parameter_sig.String
 (** Value of [-mdr-authors]. *)
 module Authors: Parameter_sig.String_list
 
+(** Value of [-mdr-title]. *)
+module Title: Parameter_sig.String
+
 (** Value of [-mdr-stubs]. *)
 module Stubs: Parameter_sig.String_list
 end
diff --git a/src/plugins/markdown-report/md_gen.ml b/src/plugins/markdown-report/md_gen.ml
index fbeb5e0df12..37fcddd4ad1 100644
--- a/src/plugins/markdown-report/md_gen.ml
+++ b/src/plugins/markdown-report/md_gen.ml
@@ -525,11 +525,14 @@ let gen_report is_draft =
   let context = gen_context env in
   let coverage = gen_coverage env in
   let alarms = gen_alarms env in
+  let title = Mdr_params.Title.get () in
   let title =
-    if is_draft then
-      plain "Frama-C Analysis Report"
-    else
-      plain "Draft report"
+    if title = "" then begin
+      if is_draft then
+        plain "Draft report"
+      else
+        plain "Frama-C Analysis Report"
+    end else plain title
   in
   let authors = List.map (fun x -> plain x) (Mdr_params.Authors.get ()) in
   let date = mk_date () in
diff --git a/src/plugins/markdown-report/mdr_params.ml b/src/plugins/markdown-report/mdr_params.ml
index cc2b0d1f774..188830f2ac9 100644
--- a/src/plugins/markdown-report/mdr_params.ml
+++ b/src/plugins/markdown-report/mdr_params.ml
@@ -57,6 +57,14 @@ struct
   let help = "list of authors of the report"
 end)
 
+module Title = Empty_string(
+struct
+  let option_name = "-mdr-title"
+  let arg_name = "t"
+  let help = "title of the generated document"
+end
+)
+
 module Stubs = String_list(
   struct
     let option_name = "-mdr-stubs"
diff --git a/src/plugins/markdown-report/mdr_params.mli b/src/plugins/markdown-report/mdr_params.mli
index 9671bc092fb..993fcafd394 100644
--- a/src/plugins/markdown-report/mdr_params.mli
+++ b/src/plugins/markdown-report/mdr_params.mli
@@ -18,5 +18,8 @@ module FlameGraph: Parameter_sig.String
 (** Value of [-mdr-authors]. *)
 module Authors: Parameter_sig.String_list
 
+(** Value of [-mdr-title]. *)
+module Title: Parameter_sig.String
+
 (** Value of [-mdr-stubs]. *)
 module Stubs: Parameter_sig.String_list
-- 
GitLab