Skip to content

Commit

Permalink
[Add] string output to Mardkown and HTML Generators
Browse files Browse the repository at this point in the history
  • Loading branch information
samatstariongroup committed Sep 27, 2024
1 parent 6669ddb commit 77518f9
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 26 deletions.
4 changes: 2 additions & 2 deletions ECoreNetto.Reporting/ECoreNetto.Reporting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Company>Starion Group S.A.</Company>
<Copyright>Copyright © Starion Group S.A.</Copyright>
<Title>ECoreNetto.Reporting</Title>
<Version>5.0.0</Version>
<Version>5.1.0</Version>
<Description>Ecore Reporting use in combination with the ECoreNetto library generate reports</Description>
<PackageId>ECoreNetto.Reporting</PackageId>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
Expand All @@ -23,7 +23,7 @@
<Authors>Sam Gerene</Authors>
<PackageTags>Ecore HandleBars Reporting</PackageTags>
<PackageReleaseNotes>
[Add] Report Generators
[Add] string output to HTML and Markdown reporters
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
42 changes: 31 additions & 11 deletions ECoreNetto.Reporting/Generators/HtmlReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,18 @@ public string QueryReportType()
/// Generates a table that contains all classes, attributes and their documentation
/// </summary>
/// <param name="modelPath">
/// the path to the Ecore model of which the report is to be generated.
/// /// the path to the Ecore model of which the report is to be generated.
/// </param>
/// <param name="outputPath">
/// the path, including filename, where the output is to be generated.
/// </param>
public void GenerateReport(FileInfo modelPath, FileInfo outputPath)
/// <returns>
/// the content of an HTML report in a string
/// </returns>
public string GenerateReport(FileInfo modelPath)
{
if (modelPath == null)
{
throw new ArgumentNullException(nameof(modelPath));
}

if (outputPath == null)
{
throw new ArgumentNullException(nameof(outputPath));
}

var sw = Stopwatch.StartNew();

this.logger.LogInformation("Start Generating Html report tables");
Expand All @@ -93,6 +88,31 @@ public void GenerateReport(FileInfo modelPath, FileInfo outputPath)

var generatedHtml = template(payload);

this.logger.LogInformation("Generated HTML report in {ElapsedTime} [ms]", sw.ElapsedMilliseconds);

return generatedHtml;
}

/// <summary>
/// Generates a table that contains all classes, attributes and their documentation
/// </summary>
/// <param name="modelPath">
/// the path to the Ecore model of which the report is to be generated.
/// </param>
/// <param name="outputPath">
/// the path, including filename, where the output is to be generated.
/// </param>
public void GenerateReport(FileInfo modelPath, FileInfo outputPath)
{
if (outputPath == null)
{
throw new ArgumentNullException(nameof(outputPath));
}

var sw = Stopwatch.StartNew();

var generatedHtml = this.GenerateReport(modelPath);

if (outputPath.Exists)
{
outputPath.Delete();
Expand All @@ -101,7 +121,7 @@ public void GenerateReport(FileInfo modelPath, FileInfo outputPath)
using var writer = outputPath.CreateText();
writer.Write(generatedHtml);

this.logger.LogInformation("Generated HTML report in {ElapsedTime} [ms]", sw.ElapsedMilliseconds);
this.logger.LogInformation("Generated and saved HTML report in {ElapsedTime} [ms]", sw.ElapsedMilliseconds);
}

/// <summary>
Expand Down
12 changes: 12 additions & 0 deletions ECoreNetto.Reporting/Generators/IHtmlReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@

namespace ECoreNetto.Reporting.Generators
{
using System.IO;

/// <summary>
/// The purpose of the <see cref="IHtmlReportGenerator"/> is to generate an HTML report of an
/// Ecore Model
/// </summary>
public interface IHtmlReportGenerator : IReportGenerator
{
/// <summary>
/// Generates a table that contains all classes, attributes and their documentation
/// </summary>
/// <param name="modelPath">
/// /// the path to the Ecore model of which the report is to be generated.
/// </param>
/// <returns>
/// the content of an HTML report in a string
/// </returns>
public string GenerateReport(FileInfo modelPath);
}
}
12 changes: 12 additions & 0 deletions ECoreNetto.Reporting/Generators/IMarkdownReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@

namespace ECoreNetto.Reporting.Generators
{
using System.IO;

/// <summary>
/// The purpose of the <see cref="IMarkdownReportGenerator"/> is to generate a Markdown report of an
/// Ecore Model
/// </summary>
public interface IMarkdownReportGenerator : IReportGenerator
{
/// <summary>
/// Generates a Markdown document with a table that contains all classes, attributes and their documentation
/// </summary>
/// <param name="modelPath">
/// the path to the Ecore model of which the report is to be generated.
/// </param>
/// <returns>
/// the content of a Markdown report in a string
/// </returns>
public string GenerateReport(FileInfo modelPath);
}
}
42 changes: 31 additions & 11 deletions ECoreNetto.Reporting/Generators/MarkdownReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,21 @@ public string QueryReportType()
}

/// <summary>
/// Generates a Markdown document with a table that contains all classes, attributes and their documentation
/// Generates a table that contains all classes, attributes and their documentation
/// </summary>
/// <param name="modelPath">
/// the path to the Ecore model of which the report is to be generated.
/// </param>
/// <param name="outputPath">
/// the path, including filename, where the output is to be generated.
/// /// the path to the Ecore model of which the report is to be generated.
/// </param>
public void GenerateReport(FileInfo modelPath, FileInfo outputPath)
/// <returns>
/// the content of an HTML report in a string
/// </returns>
public string GenerateReport(FileInfo modelPath)
{
if (modelPath == null)
{
throw new ArgumentNullException(nameof(modelPath));
}

if (outputPath == null)
{
throw new ArgumentNullException(nameof(outputPath));
}

var sw = Stopwatch.StartNew();

this.logger.LogInformation("Start Generating Markdown report");
Expand All @@ -93,6 +88,31 @@ public void GenerateReport(FileInfo modelPath, FileInfo outputPath)

var generatedHtml = template(payload);

this.logger.LogInformation("Generated Markdown report in {ElapsedTime} [ms]", sw.ElapsedMilliseconds);

return generatedHtml;
}

/// <summary>
/// Generates a Markdown document with a table that contains all classes, attributes and their documentation
/// </summary>
/// <param name="modelPath">
/// the path to the Ecore model of which the report is to be generated.
/// </param>
/// <param name="outputPath">
/// the path, including filename, where the output is to be generated.
/// </param>
public void GenerateReport(FileInfo modelPath, FileInfo outputPath)
{
if (outputPath == null)
{
throw new ArgumentNullException(nameof(outputPath));
}

var sw = Stopwatch.StartNew();

var generatedHtml = this.GenerateReport(modelPath) ;

if (outputPath.Exists)
{
outputPath.Delete();
Expand Down
4 changes: 2 additions & 2 deletions ECoreNetto.Tools/ECoreNetto.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<PackAsTool>true</PackAsTool>
<PackageId>ECoreNetto.Tools</PackageId>
<ToolCommandName>ecoretools</ToolCommandName>
<Version>5.0.0</Version>
<Version>5.1.0</Version>
<ImplicitUsings>disable</ImplicitUsings>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>ecorenetto-Icon.png</PackageIcon>
<NeutralLanguage>en-US</NeutralLanguage>
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>
<PackageReleaseNotes>
[Add] DataTypes to Excel report
[Update] to reporting version 5.1.0
</PackageReleaseNotes>
</PropertyGroup>

Expand Down

0 comments on commit 77518f9

Please sign in to comment.