Commits (20)
all:
mkdir -p tmp
mkdir -p new-templates
# Extract the latest template tags from any demo project and put them in the new-templates folder
cd ../test/test-cv && kazoo --doc -o ../../doc/tmp --gw -g --glue && mv ../../doc/tmp/Dump/Doc/* ../../doc/new-templates
mkdir -p preprocess
cp templates/templates_from_wiki preprocess # copy the previous one
rm templates/* # delete the old templates
$(MAKE) -C preprocess
cp preprocess/output/order.txt .
./kazoo-merge-doc.py
rm -rf tmp new-templates preprocess/output
clean:
rm -rf preprocess/output/*
find preprocess/templates/ -type f -delete
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This application merges freshly-generated template documentation
with previous documentation containing tag description/
It is part of kazoo - TASTE Project
Copyright (c) 2019 Maxime Perrotin
(c) 2019 European Space Agency
Contact : maxime.perrotin@esa.int
"""
__version__ = "1.0.0"
import os
import signal
import argparse
import traceback
import logging
import shutil
from itertools import chain
from typing import List, Dict, Tuple
LOG = logging.getLogger(__name__)
def init_logging(options):
''' Initialize logging '''
terminal_formatter = logging.Formatter(fmt="[%(levelname)s] %(message)s")
handler_console = logging.StreamHandler()
handler_console.setFormatter(terminal_formatter)
LOG.addHandler(handler_console)
level = logging.DEBUG if options.debug else logging.INFO
LOG.setLevel(level)
def parse_args():
''' Parse command line arguments '''
parser = argparse.ArgumentParser()
parser.add_argument(
'-v',
'--version',
action='version',
version=__version__)
parser.add_argument(
'-g',
'--debug',
action='store_true',
default=False,
help='Display debug information')
parser.add_argument(
'-o',
'--outputfolder',
type=str,
metavar='out_folder',
default='templates',
help='Output file name')
parser.add_argument(
'-i',
'--oldfolder',
type=str,
default='./preprocess/output',
metavar='old',
help='Previous file containing tags description')
parser.add_argument(
'-n',
'--newfolder',
type=str,
default='./new-templates',
metavar='new',
help='Freshly generated tag list')
parser.add_argument(
'-k',
'--orderlist',
type=str,
default='./order.txt',
metavar='order',
help='List of ordered template files to be processed')
return parser.parse_args()
def process_one_file (tmplt: str, old: str, new: str, res_folder: str) -> None:
# Read the input files
try:
old_content = open(old, "r").readlines()
except FileNotFoundError:
LOG.info("Skipping template " + old + " (file not found)")
raise
try:
new_content = open(new, "r").readlines()
except FileNotFoundError:
LOG.info("Skipping template " + new + " (file not found)")
raise
shutil.copyfile(old + ".pre", res_folder + "/" + tmplt + ".pre")
shutil.copyfile(old + ".post", res_folder + "/" + tmplt + ".post")
# Build dictionnaries from the content of the two files
assert len(old_content) > 4 and len(new_content) > 5
# The dict has to be ordered: this can work only with Python 3.6+
old_dict = {}
current_tag = ""
for line in old_content[3:-1]:
if line.startswith ("|-"):
if current_tag != "":
old_dict[current_tag] = descr
next_line = "tagname"
descr = []
current_tag = ""
elif next_line == "tagname":
current_tag = line
next_line = "description"
elif next_line == "description":
# there can be several description lines
descr.append(line.strip())
# Don't forget the last line...
if current_tag != "":
old_dict[current_tag] = descr
# In the new file, we ignore description, we only care about tag names
new_tags = set()
next_line = ""
for line in new_content[3:-1]:
if line.startswith ("|-"):
next_line = "tagname"
tagname = ""
elif next_line == "tagname":
new_tags.add(line)
next_line = "description"
elif next_line == "description":
# ignore description
pass
# Keep the wikimedia header
newdoc = [line.strip() for line in old_content[0:3]]
for name in old_dict.keys():
if name not in new_tags:
LOG.info ("Tag " + name.strip() + " has been removed")
else:
LOG.info ("Tag " + name.strip() + " has been kept")
new_tags.remove(name)
newdoc.append("|-")
newdoc.append(name.strip())
newdoc.extend(old_dict[name]) # Add the description lines
# If there are still some items in new_tags, they must be added
for name in new_tags:
LOG.info ("Tag " + name.strip() + " had been added")
newdoc.append("|-")
newdoc.append(name.strip())
newdoc.append("|DOCUMENTATION MISSING")
newdoc.append("|}")
with open (res_folder+"/"+tmplt, "w") as output:
LOG.debug (f"Writing to {res_folder}/{tmplt}")
output.write("\n".join (newdoc))
def run(options):
old_folder = options.oldfolder
new_folder = options.newfolder
result_folder = options.outputfolder
os.makedirs(result_folder, exist_ok=True)
if not os.path.exists(old_folder):
LOG.error ("Input folder(s) missing, check --help - " + old_folder)
return
if not os.path.exists(new_folder):
LOG.error ("Input folder(s) missing, check --help - " + new_folder )
return
if not os.path.exists(options.orderlist):
LOG.error ("Missing order specification file " + options.orderlist)
return
orderlist = open(options.orderlist, "r").readlines()
wiki_output = open(result_folder + "/templates_from_wiki", "w")
wiki_output.write("== Templates ==\n")
for each in orderlist:
filename=each.strip()
name=filename.replace("/", "_").replace("-", "_").split(".tmplt")[0]
middle_file = f"{result_folder}/{name}"
pre_file = f"{middle_file}.pre"
post_file = f"{middle_file}.post"
try:
process_one_file (tmplt=name,
old=old_folder+"/"+name,
new=new_folder+"/"+name,
res_folder=result_folder)
except FileNotFoundError:
pass
else:
wiki_output.write(f"\n=== {filename} ===\n")
pre_content = open(pre_file, "r").readlines()
middle_content = open(middle_file, "r").readlines()
post_content = open(post_file, "r").readlines()
for lines in chain(pre_content, middle_content, post_content):
wiki_output.write(lines)
# Once the wiki file is generated, delete intermediate files
os.remove(pre_file)
os.remove(middle_file)
os.remove(post_file)
wiki_output.close()
def main():
''' Tool entry point '''
# Catch Ctrl-C to stop the app from the console
signal.signal(signal.SIGINT, signal.SIG_DFL)
options = parse_args()
init_logging(options)
LOG.info('Kazoo Documentation Merger - version ' + __version__)
run(options)
if __name__ == '__main__':
''' Run main application '''
main()
table
{
border: 2px solid black;
border-collapse: collapse;
font-family: Arial, Helvetica, sans-serif;
max-width: 60em;
}
table td
{
border-left: 1px solid gray;
border-top: 1px solid gray;
padding-top: 2pt;
padding-bottom: 2pt;
padding-left: 3pt;
padding-right: 3pt;
}
table td:first-child
{
border-left: none;
}
.headerRow
{
background-color: #BBBBBB;
}
.typeRow
{
font-size: 14pt;
color: white;
background-color: gray;
white-space: nowrap;
}
.hrNo
{
text-align: center;
color: white;
font-size: 10pt;
width: 1%;
}
.hrField
{
text-align: left;
color: white;
font-size: 10pt;
width: 15%;
}
.hrComment
{
text-align: left;
color: white;
font-size: 10pt;
width: 20%;
}
.hrType
{
text-align: left;
color: white;
font-size: 10pt;
width: 20%;
}
.hrConstraint
{
text-align: left;
color: white;
font-size: 10pt;
white-space: nowrap;
width: 1%;
}
.hrConstraint2
{
text-align: left;
color: white;
font-size: 10pt;
}
.hrOptional
{
text-align: left;
color: white;
font-size: 10pt;
white-space: nowrap;
width: 1%;
}
.hrMin
{
text-align: left;
color: white;
font-size: 10pt;
white-space: nowrap;
width: 1%;
}
.hrMax
{
text-align: left;
color: white;
font-size: 10pt;
white-space: nowrap;
width: 1%;
}
.CommentRow
{
background-color: #e9e9e9;
height: 18pt;
}
.OddRow
{
background-color: #e9e9e9;
height: 18pt;
}
.EvenRow
{
background-color: #DBDBDB;
height: 18pt;
}
.no
{
text-align: center;
color: black;
font-size: 9pt;
}
.field
{
text-align: left;
color: black;
font-size: 9pt;
}
.comment
{
color: black;
font-size: 9pt;
text-align: left;
}
.comment2
{
color: black;
font-size: 9pt;
text-align: left;
}
.threeDots
{
color: black;
font-size: 9pt;
text-align:center;
}
.type
{
text-align: left;
color: black;
font-size: 9pt;
}
.constraint
{
text-align: left;
color: black;
white-space: nowrap;
font-size: 9pt;
}
.optional
{
text-align: left;
color: black;
font-size: 9pt;
white-space: nowrap;
}
.min
{
text-align: right;
color: black;
font-size: 9pt;
}
.max
{
text-align: right;
color: black;
font-size: 9pt;
}
h1
{
font-family: Verdana, Sans-Serif;
color: black;
font-size: 14pt;
}
h2
{
font-family: Verdana, Sans-Serif;
color: black;
font-size: 12pt;
}
a
{
color: black;
}
a.fileLink
{
color: white;
}
a.acnParamsLink
{
color: white;
text-decoration: none;
vertical-align: super;
font-size: 8pt;
}
ul.enumeration
{
list-style-type: square;
margin-top: 0pt;
margin-bottom: 1pt;
padding-left: 20pt;
}
font.enumeration_name
{
font-style: italic;
}
\ No newline at end of file
templates/build-script.tmplt
templates/skeletons/makefile.tmplt
templates/skeletons/context-parameters.tmplt
templates/skeletons/sub/trigger.tmplt
templates/skeletons/sub/makefile-filename.tmplt
templates/skeletons/sub/function-filename.tmplt
templates/skeletons/sub/interface.tmplt
templates/skeletons/sub/makefile.tmplt
templates/skeletons/sub/function.tmplt
templates/concurrency_view/sub/filenode.tmplt
templates/concurrency_view/sub/trigger.tmplt
templates/concurrency_view/sub/filepart.tmplt
templates/concurrency_view/sub/thread.tmplt
templates/concurrency_view/sub/filethread.tmplt
templates/concurrency_view/sub/fileblock.tmplt
templates/concurrency_view/sub/pi.tmplt
templates/concurrency_view/sub/ri.tmplt
templates/concurrency_view/sub/block.tmplt
templates/concurrency_view/sub/partition.tmplt
templates/concurrency_view/sub/node.tmplt
templates/concurrency_view/sub/system.tmplt
all: clean
[ -f templates_from_wiki ] && ./maker.sh ./templates_from_wiki
clean:
rm -rf output templates
BEGIN {
inside=0;
insideSection=0;
}
/^=== / {
fname=$2;
order = "output/order.txt";
print fname > order;
insideSection=1;
}
/class.*wikitable/ {
inside=1;
}
/^\|}/ {
inside=0;
insideSection=2;
print $0 > fname ;
}
{
if (inside && insideSection == 1) {
print $0 > fname;
}
if (insideSection == 1 && !inside) {
pre = sprintf("%s.pre", fname);
print $0 > pre;
}
if (insideSection == 2 && !inside) {
post = sprintf("%s.post", fname);
print $0 > post;
}
}
#!/bin/bash
mkdir -p templates/concurrency_view/sub
mkdir -p templates/skeletons/sub
mkdir -p output
cat $1 | awk -f f.awk
find . -type f -iname '*tmplt' | \
cut -c 3- | \
while read ANS ; do \
mv -i "$ANS" output/"$(echo ${ANS/.tmplt/} | sed 's,[/-],_,g')" ; \
done
find . -type f -iname '*.pre' | \
cut -c 3- | \
while read ANS ; do \
cat "$ANS" | sed 1d > output/"$(echo ${ANS/.tmplt.pre/.pre} | sed 's,[/-],_,g')"
done
find . -type f -iname '*.post' | \
cut -c 3- | \
while read ANS ; do \
cat "$ANS" | sed 1d > output/"$(echo ${ANS/.tmplt.post/.post} | sed 's,[/-],_,g')"
done
rm -rf templates
This diff is collapsed.
This diff is collapsed.
pandoc -c kazoo.css -f mediawiki -t html5 -s updated.mediawiki -o test.html
...@@ -15,6 +15,7 @@ begin ...@@ -15,6 +15,7 @@ begin
if Model.Configuration.Debug_Flag then if Model.Configuration.Debug_Flag then
TASTE.Dump.Dump_Input_Model (Model); TASTE.Dump.Dump_Input_Model (Model);
Model.Dump; Model.Dump;
end if; end if;
if Model.Configuration.Glue then if Model.Configuration.Glue then
...@@ -25,6 +26,12 @@ begin ...@@ -25,6 +26,12 @@ begin
Model.Generate_Build_Script; Model.Generate_Build_Script;
Model.Generate_Code; Model.Generate_Code;
if Model.Configuration.Generate_Doc then
Dump_Documentation
(Output_Folder =>
Model.Configuration.Output_Dir.Element & "/Dump/Doc");
end if;
end; end;
exception exception
when TASTE.Quit_TASTE => when TASTE.Quit_TASTE =>
......
with System.OS_Lib, with Text_IO,
Text_IO,
Ada.Exceptions, Ada.Exceptions,
Ada.Directories, Ada.Directories,
Templates_Parser, Templates_Parser,
TASTE.Parser_Utils; TASTE.Parser_Utils;
use System.OS_Lib, use Text_IO,
Text_IO,
Ada.Exceptions, Ada.Exceptions,
Ada.Directories, Ada.Directories,
Templates_Parser, Templates_Parser,
...@@ -15,61 +13,21 @@ package body TASTE.Backend.Build_Script is ...@@ -15,61 +13,21 @@ package body TASTE.Backend.Build_Script is
procedure Generate (Model : TASTE_Model) is procedure Generate (Model : TASTE_Model) is
Prefix : constant String := Prefix : constant String :=
Model.Configuration.Binary_Path.Element & "templates/"; Model.Configuration.Binary_Path.Element & "templates/";
Vec_Code : Tag;
Vec_Zip : Tag;
Vec_Func : Tag;
begin begin
for Each of Model.Interface_View.Flat_Functions loop Put_Info ("Generating legacy build-script.sh");
declare
Template_Data : constant Translate_Table :=
(1 => Assoc ("Function_Name", Each.Name),
2 => Assoc ("Language", Language_Spelling (Each)));
Element_Code : constant String :=
Parse (Prefix & "build-script-gencode.tmplt", Template_Data);
Element_Zip : constant String :=
Parse (Prefix & "build-script-zip.tmplt", Template_Data);
Element_Func : constant String :=
Parse (Prefix & "build-script-func.tmplt", Template_Data);
begin
if Element_Code'Length > 0 then
Vec_Code := Vec_Code & Element_Code;
end if;
if Element_Zip'Length > 0 then
Vec_Zip := Vec_Zip & Element_Zip;
end if;
if Element_Func'Length > 0 then
Vec_Func := Vec_Func & Element_Func;
end if;
end;
end loop;
Put_Info ("Generating build script");
declare declare
Template_Data : constant Translate_Set := Template_Data : constant Translate_Set :=
+Assoc ("Interface_View_Path", +Assoc ("Interface_View_Path",
Model.Configuration.Interface_View.Element) Model.Configuration.Interface_View.Element)
& Assoc ("Output_Path", Model.Configuration.Output_Dir.Element) & Assoc ("Output_Path", Model.Configuration.Output_Dir.Element);
& Assoc ("Generate_Code", Vec_Code)
& Assoc ("Zip_Code", Vec_Zip)
& Assoc ("Functions", Vec_Func)
& Assoc ("CodeCoverage", "# TODO");
Result : constant String := Parse (Prefix & "build-script.tmplt", Result : constant String := Parse (Prefix & "build-script.tmplt",
Template_Data); Template_Data);
Output_Path : constant String := Output_Path : constant String :=
Model.Configuration.Output_Dir.Element; Model.Configuration.Output_Dir.Element;
Filename : constant String := Output_Path & "/build-script.sh"; Filename : constant String := Output_Path & "/build-script.sh";
Output : File_Type; Output : File_Type;
Success : Boolean;
begin begin
Create_Path (Output_Path); Create_Path (Output_Path);
if Exists (Filename) then
Put_Info ("Making backup of build script (build-script.sh.old)");
Rename_File (Old_Name => Filename,
New_Name => Output_Path & "/build-script.sh.old",
Success => Success);
if not Success then
raise Backend_Error with "Impossible to rename build-script.sh";
end if;
end if;
Create (File => Output, Mode => Out_File, Name => Filename); Create (File => Output, Mode => Out_File, Name => Filename);
Put_Line (Output, Result); Put_Line (Output, Result);
Close (Output); Close (Output);
......
...@@ -2,5 +2,9 @@ with TASTE.AADL_Parser; ...@@ -2,5 +2,9 @@ with TASTE.AADL_Parser;
use TASTE.AADL_Parser; use TASTE.AADL_Parser;
package TASTE.Backend.Build_Script is package TASTE.Backend.Build_Script is
-- The generation of the build script is there for legacy purpose only
-- It is deprecated and only ensures backward compatibility with
-- Buildsupport/Orchestrator build habits.
-- Kazoo generates a Makefile in place of this build script.
procedure Generate (Model : TASTE_Model); procedure Generate (Model : TASTE_Model);
end TASTE.Backend.Build_Script; end TASTE.Backend.Build_Script;
...@@ -104,6 +104,7 @@ package body TASTE.Backend.Code_Generators is ...@@ -104,6 +104,7 @@ package body TASTE.Backend.Code_Generators is
Create (File => Output_File, Create (File => Output_File,
Mode => Out_File, Mode => Out_File,
Name => Model.Configuration.Output_Dir.Element & "/Makefile"); Name => Model.Configuration.Output_Dir.Element & "/Makefile");
Document_Template (Templates_Skeletons_Makefile, Content_Set);
Put_Line (Output_File, Parse (Tmplt, Content_Set)); Put_Line (Output_File, Parse (Tmplt, Content_Set));
Close (Output_File); Close (Output_File);
end Generate_Global_Makefile; end Generate_Global_Makefile;
...@@ -116,6 +117,7 @@ package body TASTE.Backend.Code_Generators is ...@@ -116,6 +117,7 @@ package body TASTE.Backend.Code_Generators is
Tmplt_Sign : constant String := Path & "interface.tmplt"; Tmplt_Sign : constant String := Path & "interface.tmplt";
begin begin
for Each of Interfaces loop for Each of Interfaces loop
Document_Template (Templates_Skeletons_Sub_Interface, Each);
Result := Result & String'(Parse (Tmplt_Sign, Each)); Result := Result & String'(Parse (Tmplt_Sign, Each));
end loop; end loop;
return Result; return Result;
...@@ -135,6 +137,7 @@ package body TASTE.Backend.Code_Generators is ...@@ -135,6 +137,7 @@ package body TASTE.Backend.Code_Generators is
CP_File_Dash : Unbounded_String; CP_File_Dash : Unbounded_String;
begin begin
Document_Template (Templates_Skeletons_Context_Parameters, CP_Tmpl);
-- To keep backward compatibility, file name uses dash -- To keep backward compatibility, file name uses dash
for C of CP_File loop for C of CP_File loop
CP_File_Dash := CP_File_Dash & (if C = '_' then '-' else C); CP_File_Dash := CP_File_Dash & (if C = '_' then '-' else C);
...@@ -200,6 +203,7 @@ package body TASTE.Backend.Code_Generators is ...@@ -200,6 +203,7 @@ package body TASTE.Backend.Code_Generators is
Output_Dir : constant String := Output_Lang & Output_Sub; Output_Dir : constant String := Output_Lang & Output_Sub;
begin begin
Document_Template (Templates_Skeletons_Sub_Makefile, Make_Tmpl);
-- Create directory tree (output/function/language/src) -- Create directory tree (output/function/language/src)
Create_Path (Output_Dir); Create_Path (Output_Dir);
if File_Name /= "" then if File_Name /= "" then
...@@ -328,6 +332,12 @@ package body TASTE.Backend.Code_Generators is ...@@ -328,6 +332,12 @@ package body TASTE.Backend.Code_Generators is
and then Strip_String (Parse and then Strip_String (Parse
(Path & "/trigger.tmplt", Trig_Tmpl)) = "TRUE"); (Path & "/trigger.tmplt", Trig_Tmpl)) = "TRUE");
begin begin
Document_Template
(Templates_Skeletons_Sub_Function_Filename, File_Tmpl);
Document_Template
(Templates_Skeletons_Sub_Makefile_Filename, File_Tmpl);
Document_Template
(Templates_Skeletons_Sub_Trigger, Trig_Tmpl);
if Trigger then if Trigger then
-- Output code and Makefile from this template folder -- Output code and Makefile from this template folder
Process_Template (F => Each, Process_Template (F => Each,
......
...@@ -252,6 +252,8 @@ package body TASTE.Concurrency_View is ...@@ -252,6 +252,8 @@ package body TASTE.Concurrency_View is
-- Part_File_Name may contain a subfolder -- Part_File_Name may contain a subfolder
Subfolder : Unbounded_String; Subfolder : Unbounded_String;
begin begin
Document_Template
(Templates_Concurrency_View_Sub_File_Part, Part_Tag);
for Each of Partition.In_Ports loop for Each of Partition.In_Ports loop
Input_Port_Names := Input_Port_Names & Each.Port_Name; Input_Port_Names := Input_Port_Names & Each.Port_Name;
Input_Port_Type_Name := Input_Port_Type_Name Input_Port_Type_Name := Input_Port_Type_Name
...@@ -293,6 +295,12 @@ package body TASTE.Concurrency_View is ...@@ -293,6 +295,12 @@ package body TASTE.Concurrency_View is
then Strip_String (Parse (Thread_File_Id, Thread_Tag)) then Strip_String (Parse (Thread_File_Id, Thread_Tag))
else ""); else "");
begin begin
Document_Template
(Templates_Concurrency_View_Sub_Thread, Thread_Assoc);
Document_Template
(Templates_Concurrency_View_Sub_File_Thread,
Thread_Tag);
Threads := Threads & Newline & Result; Threads := Threads & Newline & Result;
Part_Threads := Part_Threads & Newline & Result; Part_Threads := Part_Threads & Newline & Result;
Thread_Names := Thread_Names & Name; Thread_Names := Thread_Names & Name;
...@@ -358,6 +366,8 @@ package body TASTE.Concurrency_View is ...@@ -358,6 +366,8 @@ package body TASTE.Concurrency_View is
then Strip_String (Parse (Block_File_Id, Block_Tag)) then Strip_String (Parse (Block_File_Id, Block_Tag))
else ""); else "");
begin begin
Document_Template
(Templates_Concurrency_View_Sub_File_Block, Block_Tag);
Block_Names := Block_Names & Block_Name; Block_Names := Block_Names & Block_Name;
All_Block_Names := All_Block_Names & Block_Name; All_Block_Names := All_Block_Names & Block_Name;
Block_Languages := Block_Languages Block_Languages := Block_Languages
...@@ -366,6 +376,9 @@ package body TASTE.Concurrency_View is ...@@ -366,6 +376,9 @@ package body TASTE.Concurrency_View is
& B.Ref_Function.Instance_Of.Value_Or (US ("")); & B.Ref_Function.Instance_Of.Value_Or (US (""));
for PI_Assoc of Tmpl.Protected_Provided loop for PI_Assoc of Tmpl.Protected_Provided loop
Document_Template
(Templates_Concurrency_View_Sub_PI,
PI_Assoc & Assoc ("Partition_Name", ""));
Pro_PI_Tag := Pro_PI_Tag & Newline Pro_PI_Tag := Pro_PI_Tag & Newline
& String'(Parse (Path & "/pi.tmplt", & String'(Parse (Path & "/pi.tmplt",
PI_Assoc & Assoc PI_Assoc & Assoc
...@@ -378,6 +391,10 @@ package body TASTE.Concurrency_View is ...@@ -378,6 +391,10 @@ package body TASTE.Concurrency_View is
("Partition_Name", Partition_Name))); ("Partition_Name", Partition_Name)));
end loop; end loop;
for RI_Assoc of Tmpl.Required loop for RI_Assoc of Tmpl.Required loop
Document_Template
(Templates_Concurrency_View_Sub_RI,
RI_Assoc & Assoc ("Partition_Name", ""));
RI_Tag := RI_Tag & Newline RI_Tag := RI_Tag & Newline
& String'(Parse (Path & "/ri.tmplt", & String'(Parse (Path & "/ri.tmplt",
RI_Assoc & Assoc RI_Assoc & Assoc
...@@ -393,6 +410,8 @@ package body TASTE.Concurrency_View is ...@@ -393,6 +410,8 @@ package body TASTE.Concurrency_View is
& Assoc ("Required", RI_Tag); & Assoc ("Required", RI_Tag);
Result := Parse (Path & "/block.tmplt", Block_Assoc); Result := Parse (Path & "/block.tmplt", Block_Assoc);
Document_Template
(Templates_Concurrency_View_Sub_Block, Block_Assoc);
Blocks := Blocks & Newline & To_String (Result); Blocks := Blocks & Newline & To_String (Result);
...@@ -438,6 +457,9 @@ package body TASTE.Concurrency_View is ...@@ -438,6 +457,9 @@ package body TASTE.Concurrency_View is
Part_Content := Part_Content :=
Parse (Path & "/partition.tmplt", Partition_Assoc); Parse (Path & "/partition.tmplt", Partition_Assoc);
Document_Template
(Templates_Concurrency_View_Sub_Partition, Partition_Assoc);
-- Save the content of the partition in a file -- Save the content of the partition in a file
-- (if required at template folder level) -- (if required at template folder level)
if Part_File_Name /= "" then if Part_File_Name /= "" then
...@@ -516,7 +538,9 @@ package body TASTE.Concurrency_View is ...@@ -516,7 +538,9 @@ package body TASTE.Concurrency_View is
& Assoc ("Package_Name", & Assoc ("Package_Name",
CV.Nodes (Node_Name).Deployment_Node.Package_Name) CV.Nodes (Node_Name).Deployment_Node.Package_Name)
& Assoc ("Ada_Runtime", & Assoc ("Ada_Runtime",
CV.Nodes (Node_Name).Deployment_Node.Ada_Runtime); CV.Nodes (Node_Name).Deployment_Node.Ada_Runtime);
Document_Template
(Templates_Concurrency_View_Sub_Node, Node_Assoc);
return Parse (Path & "/node.tmplt", Node_Assoc); return Parse (Path & "/node.tmplt", Node_Assoc);
end Generate_Node; end Generate_Node;
...@@ -640,6 +664,10 @@ package body TASTE.Concurrency_View is ...@@ -640,6 +664,10 @@ package body TASTE.Concurrency_View is
(if Trigger then Generate_Node (Node_Name) (if Trigger then Generate_Node (Node_Name)
else ""); else "");
begin begin
Document_Template
(Templates_Concurrency_View_Sub_File_Node, Filename_Set);
Document_Template
(Templates_Concurrency_View_Sub_Trigger, Trig_Tmpl);
if Trigger then if Trigger then
-- Associate node name, CPU name and CPU classifier -- Associate node name, CPU name and CPU classifier
...@@ -806,6 +834,8 @@ package body TASTE.Concurrency_View is ...@@ -806,6 +834,8 @@ package body TASTE.Concurrency_View is
Mode => Out_File, Mode => Out_File,
Name => CV_Out_Dir & File_Sys); Name => CV_Out_Dir & File_Sys);
Put_Line (Output_File, Parse (Tmpl_Sys, Set_Sys)); Put_Line (Output_File, Parse (Tmpl_Sys, Set_Sys));
Document_Template
(Templates_Concurrency_View_Sub_System, Set_Sys);
Close (Output_File); Close (Output_File);
end if; end if;
end; end;
......
...@@ -124,13 +124,11 @@ package body TASTE.Dump is ...@@ -124,13 +124,11 @@ package body TASTE.Dump is
Result : Unbounded_String; Result : Unbounded_String;
begin begin
for I of Interfaces loop for I of Interfaces loop
Result := Result & String'(Parse (IF_Template, I)) & Newline; Result := Result & String'(Parse (IF_Template, I)) & Newline;
end loop; end loop;
return Result; return Result;
end Process_Interfaces; end Process_Interfaces;
begin begin
Document_Template (Prefix, "interfaceview.tmplt", IV_Tags);
if not Check or not Trigger then if not Check or not Trigger then
Put_Info ("Nothing generated from " & Path); Put_Info ("Nothing generated from " & Path);
return; return;
...@@ -251,7 +249,11 @@ package body TASTE.Dump is ...@@ -251,7 +249,11 @@ package body TASTE.Dump is
& Assoc ("Dest_Ports", Dest_Ports); & Assoc ("Dest_Ports", Dest_Ports);
-- Output is made of interface, deployment and data views -- Output is made of interface, deployment and data views
Document_Template (Prefix, "interfaceview.tmplt", IV_Tags); Document_Template (Category => Templates_Dump_Interfaceview,
Tags => IV_Tags);
Document_Template (Category => Templates_Dump_Deploymentview,
Tags => DV_Tags);
-- interfaceview.tmplt
Output_Tags := +Assoc ("Interface_View", Output_Tags := +Assoc ("Interface_View",
String'(Parse (IV_Template, IV_Tags))) String'(Parse (IV_Template, IV_Tags)))
& Assoc ("Deployment_View", & Assoc ("Deployment_View",
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
-- Model of the Concurrency View -- Model of the Concurrency View
with TASTE.AADL_Parser; with TASTE.AADL_Parser;
use TASTE.AADL_Parser;
use TASTE.AADL_Parser;
package TASTE.Dump is package TASTE.Dump is
......
...@@ -515,7 +515,7 @@ package body TASTE.Interface_View is ...@@ -515,7 +515,7 @@ package body TASTE.Interface_View is
(if Context /= From then From else "_env"); (if Context /= From then From else "_env");
Result : Remote_Entity := Result : Remote_Entity :=
(US ("Not found!"), US ("Not found!"), US ("Not found!")); (US ("Not found!"), US ("Not found!"), US ("Not found!"));
Connections : Channels.Vector; Connections : Channels.Vector := Channels.Empty_Vector;
Set_Going_Out : Boolean := False; Set_Going_Out : Boolean := False;
begin begin
-- Note: There is a limitation in the interface view when there are -- Note: There is a limitation in the interface view when there are
...@@ -526,7 +526,10 @@ package body TASTE.Interface_View is ...@@ -526,7 +526,10 @@ package body TASTE.Interface_View is
-- * This is NOT RIGHT and should be fixed by Ellidiss * -- * This is NOT RIGHT and should be fixed by Ellidiss *
-- Retrieve the list of connections of the source function context -- Retrieve the list of connections of the source function context
Connections := Routes_Map.Element (Key => Context); if Routes_Map.Contains (Key => Context) then
Connections := Routes_Map.Element (Key => Context);
end if;
for Each of Connections loop for Each of Connections loop
if Each.Caller = Source and Each.RI_Name = US (RI) then if Each.Caller = Source and Each.RI_Name = US (RI) then
-- Found the connection in the current context -- Found the connection in the current context
......
...@@ -6,6 +6,7 @@ with Ada.Characters.Latin_1, ...@@ -6,6 +6,7 @@ with Ada.Characters.Latin_1,
Ada.Strings.Maps, Ada.Strings.Maps,
Ada.Strings.Fixed, Ada.Strings.Fixed,
Ada.Strings, Ada.Strings,
Ada.Characters.Handling,
Ada.Directories, Ada.Directories,
Ada.Command_Line, Ada.Command_Line,
Ada.Environment_Variables, Ada.Environment_Variables,
...@@ -13,6 +14,7 @@ with Ada.Characters.Latin_1, ...@@ -13,6 +14,7 @@ with Ada.Characters.Latin_1,
GNAT.Strings, GNAT.Strings,
GNAT.Command_Line, GNAT.Command_Line,
Templates_Parser.Utils, Templates_Parser.Utils,
Templates_Parser.Query,
Ocarina.AADL_Values, Ocarina.AADL_Values,
Ocarina.Configuration, Ocarina.Configuration,
Ocarina.FE_AADL.Parser, Ocarina.FE_AADL.Parser,
...@@ -22,8 +24,10 @@ with Ada.Characters.Latin_1, ...@@ -22,8 +24,10 @@ with Ada.Characters.Latin_1,
package body TASTE.Parser_Utils is package body TASTE.Parser_Utils is
use GNAT.OS_Lib, use Ada.Characters.Handling,
GNAT.OS_Lib,
GNAT.Command_Line, GNAT.Command_Line,
Ada.Directories,
Templates_Parser.Utils, Templates_Parser.Utils,
Ocarina.ME_AADL.AADL_Tree.Entities.Properties, Ocarina.ME_AADL.AADL_Tree.Entities.Properties,
Ocarina.Instances.Queries; Ocarina.Instances.Queries;
...@@ -58,23 +62,56 @@ package body TASTE.Parser_Utils is ...@@ -58,23 +62,56 @@ package body TASTE.Parser_Utils is
New_Line; New_Line;
end Banner; end Banner;
-- Generate documentation for a translate set (TODO..) -- Generate documentation for a translate set
procedure Document_Template (Source_Folder, Template_Name : String; procedure Document_Template (Category : Template_Category;
T : Translate_Set) Tags : Translate_Set)
is is
Result : Unbounded_String :=
"{| class=""wikitable""" & ASCII.LF
& "!Parameter name" & ASCII.LF
& "!Description" & ASCII.LF
& US ("|-");
procedure Action (Item : Association; Quit : in out Boolean) is procedure Action (Item : Association; Quit : in out Boolean) is
pragma Unreferenced (Item);
begin begin
-- Put_Debug (" " & Templates_Parser.Query.Variable (Item) & " - " Result :=
Result & ASCII.LF
& "|" & US (Templates_Parser.Query.Variable (Item)) & ASCII.LF
& "|@@ADD DESCRIPTION@@" & ASCII.LF
& "|-";
-- & Templates_Parser.Query.Kind (Item)'Img); -- & Templates_Parser.Query.Kind (Item)'Img);
Quit := False; Quit := False;
end Action; end Action;
procedure Iterate is new For_Every_Association (Action); procedure Iterate is new For_Every_Association (Action);
begin begin
Put_Debug (Template_Name & " (subfolder " & Source_Folder & ")"); if Doc_Map.Contains (Category) then
Iterate (T); -- 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);
Result :=
Result & ASCII.LF
& "|}";
Doc_Map.Insert (Key => Category, New_Item => To_String (Result));
end Document_Template; 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 & "/" & To_Lower (Key (Each)'Img));
Put_Line (Output_File, Element (Each));
Close (Output_File);
end loop;
end Dump_Documentation;
-- Strip function as in Python -- Strip function as in Python
function Strip_String (Input_String : String) return String is function Strip_String (Input_String : String) return String is
use Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
...@@ -225,6 +262,10 @@ package body TASTE.Parser_Utils is ...@@ -225,6 +262,10 @@ package body TASTE.Parser_Utils is
Switch => "-s", Switch => "-s",
Long_Switch => "--no-stdlib", Long_Switch => "--no-stdlib",
Help => "Don't use ocarina_components.aadl"); 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, Define_Switch (Config, Output => Version'Access,
Switch => "-v", Switch => "-v",
Long_Switch => "--version", Long_Switch => "--version",
......
...@@ -84,8 +84,41 @@ package TASTE.Parser_Utils is ...@@ -84,8 +84,41 @@ package TASTE.Parser_Utils is
unused_Context : Filter_Context) return String; unused_Context : Filter_Context) return String;
-- Generate documentation for a translate set -- Generate documentation for a translate set
procedure Document_Template (Source_Folder, Template_Name : String;
T : Translate_Set); -- Template_Category enumerants reflect the path containing the template
-- (directory separator is replaced by an underscore)
type Template_Category is
(Templates_Skeletons_Makefile, -- Main makefile
Templates_Skeletons_Context_Parameters, -- Context Parameters
Templates_Skeletons_Sub_Trigger, -- Trigger per skeleton folder
Templates_Skeletons_Sub_Makefile_Filename,
Templates_Skeletons_Sub_Makefile,
Templates_Skeletons_Sub_Function_Filename,
Templates_Skeletons_Sub_Function,
Templates_Skeletons_Sub_Interface,
Templates_Concurrency_View_Sub_Trigger,
Templates_Concurrency_View_Sub_File_Node,
Templates_Concurrency_View_Sub_File_Part,
Templates_Concurrency_View_Sub_File_Thread,
Templates_Concurrency_View_Sub_File_Block,
Templates_Concurrency_View_Sub_Thread,
Templates_Concurrency_View_Sub_PI,
Templates_Concurrency_View_Sub_RI,
Templates_Concurrency_View_Sub_Block,
Templates_Concurrency_View_Sub_Partition,
Templates_Concurrency_View_Sub_Node,
Templates_Concurrency_View_Sub_System,
Templates_Dump_Interfaceview,
Templates_Dump_Deploymentview);
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; AADL_Parser_Error : exception;
...@@ -154,6 +187,7 @@ package TASTE.Parser_Utils is ...@@ -154,6 +187,7 @@ package TASTE.Parser_Utils is
Timer_Resolution : aliased Integer := 100; Timer_Resolution : aliased Integer := 100;
Debug_Flag : aliased Boolean := False; Debug_Flag : aliased Boolean := False;
No_Stdlib : aliased Boolean := False; No_Stdlib : aliased Boolean := False;
Generate_Doc : aliased Boolean := False;
Other_Files : String_Vectors.Vector; Other_Files : String_Vectors.Vector;
end record; end record;
......