Skip to content

Commit

Permalink
* post build commands for
Browse files Browse the repository at this point in the history
   AsciiDoc
* View command for AsciiDoc
  • Loading branch information
festo-i40 committed Sep 11, 2024
1 parent cda3ac6 commit 7f63aec
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/AasxPackageExplorer/debug.MIHO.script
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
// Tool("ExportTable", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\new.adoc", "Preset", "AsciiDoc");
// Select("Submodel", "First");
// Select("Submodel", "Next");
// Tool("exportsmtasciidoc", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\new.zip", "ExportHtml", "true");
// Tool("Exit");
// Tool("sammaspectimport", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\BatteryPass-spiel.ttl");
// Tool("sammaspectimport", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\Batch-MM-2_0_0.ttl");
// Tool("exportsmtasciidoc", "File", "C:\\HOMI\\Develop\\Aasx\\repo\\new.zip", "AntoraStyle", "true");
Tool("editkey");
Select("Submodel", "First");
Select("Plugin", "First");
// Select("Submodel", "Next");
// Tool("exportsmtasciidoc", "File", "C:\Users\homi0002\Desktop\tmp\new.zip", "ExportHtml", "true", "ExportPdf", "false", "AntoraStyle", "false", "ViewResult", "true");
// Select("Plugin", "First");
// Select("SME", "First");
// Tool("aas-elem-copy");
// Tool("aas-elem-paste-below");
Expand Down
16 changes: 13 additions & 3 deletions src/AasxPackageExplorer/options-debug.MIHO.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_TechData_Work\\IDTA 02003-1-2_SubmodelTemplate_TechnicalData_v1.2__with_Draft_1_3_and_AsciiDoc_v01.aasx",
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Draft_v22.aasx",
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx",
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx",
"AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\aaspe-testing\\210_Copy_Paste\\Sample_AAS.aasx",
"AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\aaspe-testing\\310_Plugin_DNP\\Sample_AAS.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\aaspe-testing\\310_Plugin_DNP\\Sample_AAS.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\aaspe-testing\\200_Find_Replace\\Sample_SMT.aasx",
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx",
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx",
Expand Down Expand Up @@ -408,14 +408,24 @@
]
},
{
"Name": "Test 7",
"Name": "AsciiDoc - Just export (Ctrl+Shift+7)",
"Lines": [
"Tool(\"LocationPush\");",
"Select(\"Submodel\", \"First\");",
"Select(\"Submodel\", \"Next\");",
"Tool(\"ExportSmtAsciiDoc\", \"File\", \"C:\\Users\\homi0002\\Desktop\\tmp\\new.zip\");",
"Tool(\"LocationPop\");"
]
},
{
"Name": "AsciiDoc - Export and view (Ctrl+Shift+8)",
"Lines": [
"Tool(\"LocationPush\");",
"Select(\"Submodel\", \"First\");",
"Select(\"Submodel\", \"Next\");",
"Tool(\"ExportSmtAsciiDoc\", \"File\", \"C:\\Users\\homi0002\\Desktop\\tmp\\new.zip\", \"ExportHtml\", \"true\", \"ExportPdf\", \"false\", \"AntoraStyle\", \"false\", \"ViewResult\", \"true\");",
"Tool(\"LocationPop\");"
]
}
],
"ScriptLoglevel": 2,
Expand Down
9 changes: 7 additions & 2 deletions src/AasxPluginExportTable/AasxPluginExportTable.options.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
"SmtExportHtmlCmd": "docker",
"SmtExportHtmlArgs": "run -it -v %WD%:/documents/ asciidoctor/docker-asciidoctor asciidoctor -r asciidoctor-diagram -a stylesheet=asciidoc-style-idta.css %ADOC%",
"SmtExportPdfCmd": "docker",
"SmtExportPdfArgs": "run -it -v %WD%:/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf -r asciidoctor-diagram -a pdf-theme=my-theme.yml %ADOC%",
/*
// without line numbers:
// "SmtExportPdfArgs": "run -it -v %WD%:/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf -r asciidoctor-diagram -a pdf-theme=my-theme.yml %ADOC%",
// with line numbers:
"SmtExportPdfArgs": "run -it -v %WD%:/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf -r asciidoctor-diagram -r ./extended.rb -a toc=macro -a pdf-theme=my-theme.yml -a env-pdf %ADOC%",
"SmtExportViewCmd": "cmd.exe",
"SmtExportViewArgs": "/c start %WD%\\%HTML% && ping 127.0.0.1 -n 5 >nul",
/*
"SmtExportHtmlCmd": "ping",
"SmtExportHtmlArgs": "127.0.0.1 -n 6",
"SmtExportPdfCmd": "ping",
Expand Down
2 changes: 2 additions & 0 deletions src/AasxPluginExportTable/ExportTableOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class ExportTableOptions : AasxPluginOptionsBase
public string SmtExportHtmlArgs = "";
public string SmtExportPdfCmd = "";
public string SmtExportPdfArgs = "";
public string SmtExportViewCmd = "";
public string SmtExportViewArgs = "";

public ExportUmlRecord UmlExport = null;

Expand Down
47 changes: 40 additions & 7 deletions src/AasxPluginExportTable/Smt/ExportSmt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ protected void ProcessUml(Aas.IReferenceElement refel)
pumlName = AdminShellUtil.FilterFriendlyName(refel.IdShort);
var pumlFn = pumlName + ".puml";
var absPumlFn = Path.Combine(_locationDiagrams, pumlFn);
var extraAntoraPath = _optionsSmt.AntoraStyle ? "partial$diagrams/" : "";

// make options
var umlOptions = new ExportUmlRecord();
Expand All @@ -240,7 +241,7 @@ protected void ProcessUml(Aas.IReferenceElement refel)
_adoc.AppendLine("");
_adoc.AppendLine($"[plantuml, {pumlName}, svg, id=\"{pumlName}\", {astr}]");
_adoc.AppendLine("----");
_adoc.AppendLine("include::" + pumlFn + "[]");
_adoc.AppendLine("include::" + extraAntoraPath + pumlFn + "[]");
_adoc.AppendLine("----");
_adoc.AppendLine("");
}
Expand Down Expand Up @@ -363,17 +364,37 @@ public void ExportSmtToFile(
{
try
{
_locationPages = Path.Combine(_tempDir, "pages");
_locationImages = Path.Combine(_tempDir, "images");
_locationDiagrams = Path.Combine(Path.Combine(_tempDir, "partials"), "diagrams");
// create a lot of directories
var docRoot = Path.Combine(_tempDir, "documentation");
Directory.CreateDirectory(docRoot);

var modules = Path.Combine(docRoot, "modules");
Directory.CreateDirectory(modules);

var root = Path.Combine(modules, "root");
Directory.CreateDirectory(root);

_locationPages = Path.Combine(root, "pages");
Directory.CreateDirectory(_locationPages);

_locationImages = Path.Combine(root, "images");
Directory.CreateDirectory(_locationImages);

_locationDiagrams = Path.Combine(Path.Combine(root, "partials"), "diagrams");
Directory.CreateDirectory(Path.Combine(_tempDir, "partials"));
Directory.CreateDirectory(_locationDiagrams);

_log?.Info(StoredPrint.Color.Black,
"Created dedicated sub-folders for pages, images, partials/diagrams.");
"Created dedicated sub-folders for documentation, modules, root, pages, images, partials/diagrams.");

// create some boiler plate
var antoraYamlTxt = AdminShellUtil.CleanHereStringWithNewlines(
@"name: IDTA-00000
title: 'TODO'
version: 'v1.0'
start_page: ROOT:index.adoc");

System.IO.File.WriteAllText(Path.Combine(docRoot, "antora.yml"), antoraYamlTxt);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -432,9 +453,9 @@ public void ExportSmtToFile(
var adocText = _adoc.ToString();

// build adoc file
var title = (_srcSm.IdShort?.HasContent() == true)
var title = (!optionsSmt.AntoraStyle && (_srcSm.IdShort?.HasContent() == true))
? AdminShellUtil.FilterFriendlyName(_srcSm.IdShort)
: "output";
: "index";
var adocFn = title + ".adoc";
var absAdocFn = Path.Combine(_locationPages, adocFn);

Expand Down Expand Up @@ -463,6 +484,18 @@ public void ExportSmtToFile(
displayContext?.MenuExecuteSystemCommand("Exporting PDF", _tempDir, cmd, args);
}

if (_optionsSmt.ViewResult)
{
var cmd = _optionsAll.SmtExportViewCmd;
var args = _optionsAll.SmtExportViewArgs
.Replace("%WD%", "" + _tempDir)
.Replace("%ADOC%", "" + adocFn)
.Replace("%HTML%", "" + adocFn.Replace(".adoc", ".html"))
.Replace("%PDF%", "" + adocFn.Replace(".adoc", ".pdf"));

displayContext?.MenuExecuteSystemCommand("Viewing results", _tempDir, cmd, args);
}

// now, how to handle files?
if (_singleFile)
{
Expand Down
10 changes: 8 additions & 2 deletions src/AasxPluginExportTable/Smt/ExportSmtRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ public class ExportSmtRecord
[AasxMenuArgument(help: "If true, will do dedicated sub-folders for images and diagrams.")]
public bool AntoraStyle = false;

[AasxMenuArgument(help: "If true, will execute external program to produce HTML from AsciiDic.")]
[AasxMenuArgument(help: "If true, will execute external program to produce HTML from AsciiDoc " +
"using options 'SmtExportHtmlCmd' and 'SmtExportHtmlArgs' with placeholders %WD%, %ADOC%.")]
public bool ExportHtml = false;

[AasxMenuArgument(help: "If true, will execute external program to produce PDF from AsciiDic.")]
[AasxMenuArgument(help: "If true, will execute external program to produce PDF from AsciiDoc " +
"using options 'SmtExportPdfCmd' and 'SmtExportPdfArgs' with placeholders %WD%, %ADOC%.")]
public bool ExportPdf = false;

[AasxMenuArgument(help: "If true, will execute external program while in temporary directory " +
"using options 'SmtExportViewCmd' and 'SmtExportViewArgs' with placeholders %WD%, %ADOC%, %HTML%, %PDF%.")]
public bool ViewResult = false;
}
}

0 comments on commit 7f63aec

Please sign in to comment.