From 5366cfb5a79fcc9ec6421eddbe34d608378d3a07 Mon Sep 17 00:00:00 2001
From: TomSun Sorry, but there's nothing here!
+
+ Selected value: @(value?.Name)
+ Page not found
- Example
-Example
+@Header
}
+else
+{ @Header
}
+
+@((MarkupString)DocComponentType.GetTypeDocu(ComponentType))
+
+@code{
+ [Parameter]
+ public Type ComponentType { get; set; }
+
+ [Parameter]
+ public Type DocComponentType { get; set; }
+
+ private string Header => this.ComponentType.Name;
+
+}
diff --git a/src/MatBlazor.Demo/DemoContainer/DemoContainer.razor b/src/MatBlazor.Doc/DemoContainer/DemoContainer.razor
similarity index 100%
rename from src/MatBlazor.Demo/DemoContainer/DemoContainer.razor
rename to src/MatBlazor.Doc/DemoContainer/DemoContainer.razor
diff --git a/src/MatBlazor.DevUtils/Core/MatDocumenationGenerator.cs b/src/MatBlazor.Doc/DemoContainer/MatDocumenationGenerator.cs
similarity index 83%
rename from src/MatBlazor.DevUtils/Core/MatDocumenationGenerator.cs
rename to src/MatBlazor.Doc/DemoContainer/MatDocumenationGenerator.cs
index 7fdc7389..4af2e2a2 100644
--- a/src/MatBlazor.DevUtils/Core/MatDocumenationGenerator.cs
+++ b/src/MatBlazor.Doc/DemoContainer/MatDocumenationGenerator.cs
@@ -14,27 +14,52 @@ public class MatDocumenationGenerator
{
public Assembly Assembly;
public string XmlPath;
- public string OutputPath;
- public void Generate()
+ public void Generate(string outputPath)
{
+ if (!Directory.Exists(outputPath))
+ {
+ throw new Exception("OutputPath not exists");
+ }
+
var xml = XDocument.Load(XmlPath);
- foreach (var fileInfo in new DirectoryInfo(OutputPath).GetFiles("*.razor", SearchOption.TopDirectoryOnly))
+ foreach (var fileInfo in new DirectoryInfo(outputPath).GetFiles("*.razor", SearchOption.TopDirectoryOnly))
{
fileInfo.Delete();
}
+ try
+ {
+ foreach (var output in DoGenerate(xml,true,outputPath))
+ {
+ File.WriteAllText(output.OutputFilePath, output.HtmlDoc);
+ }
+ }
+ catch(Exception ex)
+ {
+ Console.WriteLine(ex);
+ throw;
+ }
+ }
+ public (Type ComponentType,string HtmlDoc)[] GenerateDynamically(Assembly docFileContainer)
+ {
+ using var docfileStream = docFileContainer.GetManifestResourceStream(
+ docFileContainer.GetManifestResourceNames().Single(rn => rn.EndsWith(this.Assembly.GetName().Name + ".xml")));
+ var xml = XDocument.Load(docfileStream);
+ var result = DoGenerate(xml,false).Select(x=>(x.ComponentType,x.HtmlDoc)).ToArray();
+ return result;
+ }
+ private IEnumerable<(Type ComponentType, string OutputFilePath, string HtmlDoc)> DoGenerate(XDocument xml, bool generateComponentFrame, string outputRootPath = null)
+ {
foreach (var type in Assembly.ExportedTypes)
{
- try
- {
-// if (!type.IsSubclassOf(typeof(ComponentBase)))
-// {
-// continue;
-// }
+ // if (!type.IsSubclassOf(typeof(ComponentBase)))
+ // {
+ // continue;
+ // }
if (type.Name.StartsWith("Base") || type.Name.EndsWith("Internal") || type.Name.EndsWith("Internal`1"))
@@ -52,10 +77,11 @@ public void Generate()
Console.WriteLine(typeName);
- var outFilePath = Path.Combine(OutputPath, $"Doc{GetFileName(typeName)}.razor");
+ var outFilePath = Path.Combine(outputRootPath ?? "", $"Doc{GetFileName(typeName)}.razor");
var sb = new StringBuilder();
-
+ if (generateComponentFrame)
+ {
sb.AppendLine($"@inherits MatBlazor.Demo.Components.BaseDocComponent");
sb.AppendLine();
sb.AppendLine("@* THIS FILE IS AUTOGENERATED FROM C# XML Comments! *@");
@@ -66,6 +92,7 @@ public void Generate()
sb.AppendLine(
$"@if (!Secondary) {{@Header
}} else {{ @Header
}}");
sb.AppendLine();
+ }
var typeXml = FindDocXml(xml, type);
if (typeXml != null)
{
@@ -98,7 +125,7 @@ public void Generate()
.ToArray();
-// sb.AppendLine($"Documentation
");
+ // sb.AppendLine($"Documentation
");
sb.AppendLine($"");
sb.AppendLine($"\t
");
@@ -144,7 +171,8 @@ public void Generate()
sb.AppendLine($" Page not found
diff --git a/src/MatBlazor.Demo/Shared/MainLayout.razor b/src/MatBlazor.Doc/MainLayout.razor
similarity index 100%
rename from src/MatBlazor.Demo/Shared/MainLayout.razor
rename to src/MatBlazor.Doc/MainLayout.razor
diff --git a/src/MatBlazor.Doc/MatBlazor.Doc.csproj b/src/MatBlazor.Doc/MatBlazor.Doc.csproj
new file mode 100644
index 00000000..2061ee96
--- /dev/null
+++ b/src/MatBlazor.Doc/MatBlazor.Doc.csproj
@@ -0,0 +1,29 @@
+Example
+Example
+Icon
+Clear Button
+ItemTemplate
+
+ Selected value: @(value?.Name) +
+ + @code + { + + public class Car + { + public string Name { get; set; } + public double Price { get; set; } + + public Car(string name, double price) + { + Name = name; + Price = price; + } + } + + Car value = null; + + Car[] options2 = new[] + { + new Car(""Volkswagen Golf"", 10000), + new Car(""Volkswagen Passat"", 11000), + new Car(""Volkswagen Polo"", 12000), + new Car(""Ford Focus"", 13000), + new Car(""Ford Fiesta"", 14000), + new Car(""Ford Fusion"", 15000), + new Car(""Ford Mondeo"", 16000), + }; + + } + + ")> + + + + +{HtmlEncode(ParseXmlMember(typeXml))}
"); + sb.AppendLine(); + } + + + var includeFields = new HashSetName | "); + sb.AppendLine($"\t\tType | "); + sb.AppendLine($"\t\tDescription | "); + sb.AppendLine($"\t
---|---|---|
{HtmlEncode(genericArgument.Name)} | "); + sb.AppendLine($"\t\tGeneric argument | "); + sb.AppendLine( + $"\t\t{HtmlEncode(ParseXmlMember(typeXml, "typeparam", genericArgument.Name))} | "); + sb.AppendLine($"\t
{HtmlEncode(prop.Name)} | "); + sb.AppendLine($"\t\t{HtmlEncode(GetTypeName(prop.PropertyType, false))} | "); + sb.AppendLine($"\t\t{HtmlEncode(propText)} | "); + sb.AppendLine($"\t