Commit eea51dfd authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add template documentation generator

parent 54ad3514
......@@ -15,6 +15,7 @@ begin
if Model.Configuration.Debug_Flag then
TASTE.Dump.Dump_Input_Model (Model);
Model.Dump;
end if;
if Model.Configuration.Glue then
......@@ -25,6 +26,12 @@ begin
Model.Generate_Build_Script;
Model.Generate_Code;
if Model.Configuration.Generate_Doc then
Dump_Documentation
(Output_Folder =>
Model.Configuration.Output_Dir.Element & "/Dump/Doc");
end if;
end;
exception
when TASTE.Quit_TASTE =>
......
......@@ -252,6 +252,7 @@ package body TASTE.Concurrency_View is
-- Part_File_Name may contain a subfolder
Subfolder : Unbounded_String;
begin
Document_Template (Template_CV_File_Part, Part_Tag);
for Each of Partition.In_Ports loop
Input_Port_Names := Input_Port_Names & Each.Port_Name;
Input_Port_Type_Name := Input_Port_Type_Name
......@@ -293,6 +294,9 @@ package body TASTE.Concurrency_View is
then Strip_String (Parse (Thread_File_Id, Thread_Tag))
else "");
begin
Document_Template (Template_CV_Thread, Thread_Assoc);
Document_Template (Template_CV_File_Thread, Thread_Tag);
Threads := Threads & Newline & Result;
Part_Threads := Part_Threads & Newline & Result;
Thread_Names := Thread_Names & Name;
......@@ -358,6 +362,7 @@ package body TASTE.Concurrency_View is
then Strip_String (Parse (Block_File_Id, Block_Tag))
else "");
begin
Document_Template (Template_CV_File_Block, Block_Tag);
Block_Names := Block_Names & Block_Name;
All_Block_Names := All_Block_Names & Block_Name;
Block_Languages := Block_Languages
......@@ -366,6 +371,9 @@ package body TASTE.Concurrency_View is
& B.Ref_Function.Instance_Of.Value_Or (US (""));
for PI_Assoc of Tmpl.Protected_Provided loop
Document_Template
(Template_CV_PI,
PI_Assoc & Assoc ("Partition_Name", ""));
Pro_PI_Tag := Pro_PI_Tag & Newline
& String'(Parse (Path & "/pi.tmplt",
PI_Assoc & Assoc
......@@ -378,6 +386,10 @@ package body TASTE.Concurrency_View is
("Partition_Name", Partition_Name)));
end loop;
for RI_Assoc of Tmpl.Required loop
Document_Template
(Template_CV_RI,
RI_Assoc & Assoc ("Partition_Name", ""));
RI_Tag := RI_Tag & Newline
& String'(Parse (Path & "/ri.tmplt",
RI_Assoc & Assoc
......@@ -393,6 +405,7 @@ package body TASTE.Concurrency_View is
& Assoc ("Required", RI_Tag);
Result := Parse (Path & "/block.tmplt", Block_Assoc);
Document_Template (Template_CV_Block, Block_Assoc);
Blocks := Blocks & Newline & To_String (Result);
......@@ -438,6 +451,8 @@ package body TASTE.Concurrency_View is
Part_Content :=
Parse (Path & "/partition.tmplt", Partition_Assoc);
Document_Template (Template_CV_Partition, Partition_Assoc);
-- Save the content of the partition in a file
-- (if required at template folder level)
if Part_File_Name /= "" then
......@@ -516,7 +531,8 @@ package body TASTE.Concurrency_View is
& Assoc ("Package_Name",
CV.Nodes (Node_Name).Deployment_Node.Package_Name)
& Assoc ("Ada_Runtime",
CV.Nodes (Node_Name).Deployment_Node.Ada_Runtime);
CV.Nodes (Node_Name).Deployment_Node.Ada_Runtime);
Document_Template (Template_CV_Node, Node_Assoc);
return Parse (Path & "/node.tmplt", Node_Assoc);
end Generate_Node;
......@@ -640,6 +656,8 @@ package body TASTE.Concurrency_View is
(if Trigger then Generate_Node (Node_Name)
else "");
begin
Document_Template (Template_CV_File_Node, Filename_Set);
Document_Template (Template_CV_Trigger, Trig_Tmpl);
if Trigger then
-- Associate node name, CPU name and CPU classifier
......@@ -806,6 +824,7 @@ package body TASTE.Concurrency_View is
Mode => Out_File,
Name => CV_Out_Dir & File_Sys);
Put_Line (Output_File, Parse (Tmpl_Sys, Set_Sys));
Document_Template (Template_CV_System, Set_Sys);
Close (Output_File);
end if;
end;
......
......@@ -124,13 +124,11 @@ package body TASTE.Dump is
Result : Unbounded_String;
begin
for I of Interfaces loop
Result := Result & String'(Parse (IF_Template, I)) & Newline;
end loop;
return Result;
end Process_Interfaces;
begin
Document_Template (Prefix, "interfaceview.tmplt", IV_Tags);
if not Check or not Trigger then
Put_Info ("Nothing generated from " & Path);
return;
......@@ -251,7 +249,9 @@ package body TASTE.Dump is
& Assoc ("Dest_Ports", Dest_Ports);
-- Output is made of interface, deployment and data views
Document_Template (Prefix, "interfaceview.tmplt", IV_Tags);
Document_Template (Category => Template_Dump_Interface_View,
Tags => IV_Tags);
-- interfaceview.tmplt
Output_Tags := +Assoc ("Interface_View",
String'(Parse (IV_Template, IV_Tags)))
& Assoc ("Deployment_View",
......
......@@ -5,8 +5,7 @@
-- Model of the Concurrency View
with TASTE.AADL_Parser;
use TASTE.AADL_Parser;
use TASTE.AADL_Parser;
package TASTE.Dump is
......
......@@ -13,6 +13,7 @@ with Ada.Characters.Latin_1,
GNAT.Strings,
GNAT.Command_Line,
Templates_Parser.Utils,
Templates_Parser.Query,
Ocarina.AADL_Values,
Ocarina.Configuration,
Ocarina.FE_AADL.Parser,
......@@ -24,6 +25,7 @@ package body TASTE.Parser_Utils is
use GNAT.OS_Lib,
GNAT.Command_Line,
Ada.Directories,
Templates_Parser.Utils,
Ocarina.ME_AADL.AADL_Tree.Entities.Properties,
Ocarina.Instances.Queries;
......@@ -58,23 +60,45 @@ package body TASTE.Parser_Utils is
New_Line;
end Banner;
-- Generate documentation for a translate set (TODO..)
procedure Document_Template (Source_Folder, Template_Name : String;
T : Translate_Set)
-- Generate documentation for a translate set
procedure Document_Template (Category : Template_Category;
Tags : Translate_Set)
is
Result : Unbounded_String := "# Tags for " & US (Category'Img);
procedure Action (Item : Association; Quit : in out Boolean) is
pragma Unreferenced (Item);
begin
-- Put_Debug (" " & Templates_Parser.Query.Variable (Item) & " - "
Result :=
Result & ASCII.LF & US (Templates_Parser.Query.Variable (Item));
-- & Templates_Parser.Query.Kind (Item)'Img);
Quit := False;
end Action;
procedure Iterate is new For_Every_Association (Action);
begin
Put_Debug (Template_Name & " (subfolder " & Source_Folder & ")");
Iterate (T);
if Doc_Map.Contains (Category) then
-- Already documented from a previous call - ignore
-- (Skeleton and Glue folders share the same template structures)
return;
end if;
Put_Debug ("Documenting template category: " & Category'Img);
Iterate (Tags);
Doc_Map.Insert (Key => Category, New_Item => To_String (Result));
end Document_Template;
procedure Dump_Documentation (Output_Folder : String) is
use Template_Doc_Maps;
Output_File : File_Type;
begin
Create_Path (Output_Folder);
for Each in Doc_Map.Iterate loop
Put_Debug ("Dump documentation of " & Key (Each)'Img);
Create (File => Output_File,
Mode => Out_File,
Name => Output_Folder & "/" & Key (Each)'Img & ".tmplt_doc");
Put_Line (Output_File, Element (Each));
Close (Output_File);
end loop;
end Dump_Documentation;
-- Strip function as in Python
function Strip_String (Input_String : String) return String is
use Ada.Characters.Latin_1;
......@@ -225,6 +249,10 @@ package body TASTE.Parser_Utils is
Switch => "-s",
Long_Switch => "--no-stdlib",
Help => "Don't use ocarina_components.aadl");
Define_Switch (Config, Output => Result.Generate_Doc'Access,
Switch => "-k",
Long_Switch => "--doc",
Help => "Generate templates documentation");
Define_Switch (Config, Output => Version'Access,
Switch => "-v",
Long_Switch => "--version",
......
......@@ -84,8 +84,38 @@ package TASTE.Parser_Utils is
unused_Context : Filter_Context) return String;
-- Generate documentation for a translate set
procedure Document_Template (Source_Folder, Template_Name : String;
T : Translate_Set);
type Template_Category is
(Template_Main_Makefile,
Template_Context_Parameters,
Template_Skeleton_And_Glue_Trigger,
Template_Skeleton_Makefile_Filename,
Template_Skeleton_Makefile,
Template_Skeleton_Function_Filename,
Template_Skeleton_Function,
Template_Skeleton_Interface,
Template_CV_Trigger,
Template_CV_File_Node,
Template_CV_File_Part,
Template_CV_File_Thread,
Template_CV_File_Block,
Template_CV_Thread,
Template_CV_PI,
Template_CV_RI,
Template_CV_Block,
Template_CV_Partition,
Template_CV_Node,
Template_CV_System,
Template_Dump_Interface_View,
Template_Dump_Deployment_View);
package Template_Doc_Maps is new Indefinite_Ordered_Maps
(Template_Category, String);
Doc_Map : Template_Doc_Maps.Map;
procedure Dump_Documentation (Output_Folder : String);
procedure Document_Template (Category : Template_Category;
Tags : Translate_Set);
AADL_Parser_Error : exception;
......@@ -154,6 +184,7 @@ package TASTE.Parser_Utils is
Timer_Resolution : aliased Integer := 100;
Debug_Flag : aliased Boolean := False;
No_Stdlib : aliased Boolean := False;
Generate_Doc : aliased Boolean := False;
Other_Files : String_Vectors.Vector;
end record;
......
......@@ -15,7 +15,7 @@ ada:
c: # Polyorb_HI_C output
rm -rf work
$(KAZOO) -p --gw --glue -o work
$(KAZOO) -p -g --gw --glue -o work
cp simple_c_function/*.c work/simple_c_function/C/src
$(MAKE) -C work
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment