Skip to content

Commit

Permalink
Update VNext Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbomhold3 committed Sep 14, 2024
1 parent 9661a53 commit cb2654e
Show file tree
Hide file tree
Showing 48 changed files with 290 additions and 212 deletions.
Binary file modified docs/VNext/_framework/BlazorStrap.Docs.pdb.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Docs.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Docs.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Docs.wasm.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.TreeView.pdb.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.TreeView.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.TreeView.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.TreeView.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.Wizard.pdb.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.Wizard.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.Wizard.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.Extensions.Wizard.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V4.pdb.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V4.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V4.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V4.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V5.pdb.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V5.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V5.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.V5.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.WASM.pdb.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.WASM.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.WASM.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.WASM.wasm.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.pdb.gz
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.wasm
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.wasm.br
Binary file not shown.
Binary file modified docs/VNext/_framework/BlazorStrap.wasm.gz
Binary file not shown.
18 changes: 9 additions & 9 deletions docs/VNext/_framework/blazor.boot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"mainAssemblyName": "BlazorStrap.WASM",
"resources": {
"hash": "sha256-wDullfvZ1An0kI6UoHwpjPswzNhSyRGACOrgIwuJTjE=",
"hash": "sha256-hQXFDCfzs1WxXKdqCDB6lNyPQB9djOAbtPUEko52Abg=",
"jsModuleNative": {
"dotnet.native.8.0.7.sgnytqlsjk.js": "sha256-tFsxPBbhkdn6GKNBKvCRLzrfAHdyM86odYTe0MtrwMk="
},
Expand All @@ -18,14 +18,14 @@
},
"assembly": {
"BlazorComponentUtilities.wasm": "sha256-7qa+C6Zt8hJgUpiGcE1MHWuwfOGMUMVd8ayItqmtQp0=",
"BlazorStrap.Docs.wasm": "sha256-p5/ujDsoTTW8n87bFURIfrvDCkaBCjGN9ZVe/bkjmOM=",
"BlazorStrap.Extensions.FluentValidation.wasm": "sha256-7nm2eQhhOdbEDOOrqmQ/XvEdTfGqy3P75keGCpCIl08=",
"BlazorStrap.Extensions.TreeView.wasm": "sha256-oByz/VDiIj1qCmN+d2yJO2pQXcvRhKE3P4cuuZDIeQY=",
"BlazorStrap.Extensions.Wizard.wasm": "sha256-5bEBQqoGROutP+gOWXIC7YnBeRWkwTJfnMNbvXmqBBw=",
"BlazorStrap.V4.wasm": "sha256-uVNr/2rj5HZ0AMYuOle8AFiNuWa+610eCmfM3219dRo=",
"BlazorStrap.V5.wasm": "sha256-4ic35Dz6lxcA44wjU0Mld7RIR2NcsuvnzcfNsefFne8=",
"BlazorStrap.wasm": "sha256-6w58/R3VQYU7s4f4qO9/nHy2ykZIplfJwkvytJgGAYQ=",
"BlazorStrap.WASM.wasm": "sha256-xmt3R4NPhPEME/k29N8jyt/nE+ZdN4RlgOo8y+H6N4s=",
"BlazorStrap.Docs.wasm": "sha256-LyVhiwNfMRY5K2nGzApCInbWtL++4HyUS/QIMGkMlYc=",
"BlazorStrap.Extensions.FluentValidation.wasm": "sha256-9UDERBwjeD3SNVjGZAX4/sBI9a+Jqa7lajCD24blFcs=",
"BlazorStrap.Extensions.TreeView.wasm": "sha256-b/Lw/uBjNpKDULwb2KpthxaT0hWzbR0SpM/Lb8K89wk=",
"BlazorStrap.Extensions.Wizard.wasm": "sha256-Ze1bHoEaB0GJJlu6Y4Sfv28ZnL9M3FUX5bH8EN1uvXE=",
"BlazorStrap.V4.wasm": "sha256-67uM0go4UFt6HiRNm4Z61RVG6XzIMXKR9tISKPFguKU=",
"BlazorStrap.V5.wasm": "sha256-gnya8rrAAvN4clAl48PeDDgSllsBJU4PHnRNpfH3qIU=",
"BlazorStrap.wasm": "sha256-/umzaOsWhfPOBDkTAX3q+CVccZShyk2UktD78Jiv6lo=",
"BlazorStrap.WASM.wasm": "sha256-rzcMWbZmZSVB6XIIWE4X6r5t83hOwUEcGbSeA+tByY8=",
"ColorCode.wasm": "sha256-Mz8W+iFHEtIXuTOac2VcI5RUaHwtcUTIC2fBfuvodVE=",
"FluentValidation.wasm": "sha256-FvsjqyJeVfoCs1v2ywx3Q1mEKXXI4uKcTOdMF+cAH98=",
"Markdig.SyntaxHighlighting.wasm": "sha256-X826lDfQCYyN/vrEQxxfipczU0w7acPz0NyOCyk45yg=",
Expand Down
Binary file modified docs/VNext/_framework/blazor.boot.json.br
Binary file not shown.
Binary file modified docs/VNext/_framework/blazor.boot.json.gz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ using BlazorStrap_Docs.SamplesHelpers.Content.Tables;
using BlazorStrap;
using BlazorStrap.Extensions;
using BlazorStrap.V4;
using Microsoft.AspNetCore.Components;

namespace BlazorStrap_Docs.Samples.V4.Components.DataGrid;

public partial class DataGrid1
public partial class DataGrid1 : ComponentBase
{
private PaginationState _pagination = new PaginationState() { ItemsPerPage = 10 };
private BSDataGrid<Employee> _dataGrid;
Expand Down
3 changes: 1 addition & 2 deletions src/BlazorStrap.Docs/AppDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BlazorStrap_Docs.Pages;
using BlazorStrap_Docs.SamplesHelpers.Content.Tables;
using BlazorStrap_Docs.SamplesHelpers.Content.Tables;
using Microsoft.EntityFrameworkCore;

namespace BlazorStrap_Docs;
Expand Down
9 changes: 9 additions & 0 deletions src/BlazorStrap.Docs/Helper/FileType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace BlazorStrap_Docs.Helper;

public enum FileType
{
Css,
Code,
Markup,
CodeBlock
}
54 changes: 30 additions & 24 deletions src/BlazorStrap.Docs/Helper/MarkdownToDocsV4.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,49 @@ else
@sample.Content
@if (sample.Component is not null)
{
<BSNav IsTabs="true">
<BSNavItem>
<TabLabel>Example</TabLabel>
<TabContent>
<div class="@DefaultClass @sample.Class mt-0">
<DynamicComponent Type="@sample.Component"/>
</div>
</TabContent>
</BSNavItem>
<BSNav IsTabs="true" @key="sample">
@if (sample.Class != "d-none")
{
<BSNavItem>
<TabLabel>Example</TabLabel>
<TabContent>
<div class="@DefaultClass @sample.Class mt-0">
<DynamicComponent Type="@sample.Component"/>
</div>
</TabContent>
</BSNavItem>
}
<BSNavItem>
<TabLabel>Markup</TabLabel>
<TabContent>
<div class="@DefaultClass mt-0">
@ToSourceMarkupString(RemoveCode(@_files[sample.MarkupFile]))
</div>
</TabContent>
</BSNavItem>
<BSNavItem>
<TabLabel>Code</TabLabel>
<TabContent>
<div class="@DefaultClass mt-0">
@ToCodeMarkupString(RemoveMarkup(_files[sample.MarkupFile]))
@if (sample.HasCode)
{
<h5>Code Behind</h5>
@ToCodeMarkupString(_files[sample.CodeFile])
}
<SampleLoader Files="_files" BaseAddress="new Uri(NavigationManager.BaseUri)" FilePath="@sample.MarkupFile" FileType="FileType.Markup"/>
</div>
</TabContent>
</BSNavItem>
@if (sample.Class != "d-none")
{
<BSNavItem >
<TabLabel>Code</TabLabel>
<TabContent>
<div class="@DefaultClass mt-0">
<SampleLoader Files="_files" BaseAddress="new Uri(NavigationManager.BaseUri)" FilePath="@sample.MarkupFile" FileType="FileType.CodeBlock"/>
@if (sample.HasCode)
{
<h5>Code Behind</h5>
<SampleLoader Files="_files" BaseAddress="new Uri(NavigationManager.BaseUri)" FilePath="@sample.CodeFile" FileType="FileType.Code"/>
}
</div>
</TabContent>
</BSNavItem>
}
@if (sample.HasCss)
{
<BSNavItem>
<TabLabel>Css</TabLabel>
<TabContent>
<div class="@DefaultClass mt-0">
<pre>@_files[sample.CssFile]</pre>
<SampleLoader Files="_files" BaseAddress="new Uri(NavigationManager.BaseUri)" FilePath="@sample.CssFile" FileType="FileType.Css"/>
</div>
</TabContent>
</BSNavItem>
Expand Down
125 changes: 54 additions & 71 deletions src/BlazorStrap.Docs/Helper/MarkdownToDocsV4.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
using Markdig;
using Markdig.SyntaxHighlighting;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;

namespace BlazorStrap_Docs.Helper;

public partial class MarkdownToDocsV4 : ComponentBase
public partial class MarkdownToDocsV4 : ComponentBase, IDisposable
{
[Inject] public NavigationManager NavigationManager { get; set; }
[Parameter] public string? NamespaceRoot { get; set; }
Expand All @@ -19,7 +20,8 @@ public partial class MarkdownToDocsV4 : ComponentBase
private bool _notFound;
private List<Sample>? Samples { get; set; } = null;
private string _indexPath = "index.txt";
private Dictionary<string,string> _files = new Dictionary<string, string>();
private Dictionary<string, string?> _files = new Dictionary<string, string?>();

private static MarkdownPipeline Pipeline => new MarkdownPipelineBuilder()
.UseBootstrap()
.UseEmojiAndSmiley()
Expand All @@ -32,15 +34,11 @@ public partial class MarkdownToDocsV4 : ComponentBase
.UseCitations()
.Build();

private static MarkdownPipeline SourcePipeline => new MarkdownPipelineBuilder()
.UseBootstrap()
.UseSyntaxHighlighting(new DefaultStyleSheet())
.Build();

protected override async Task OnParametersSetAsync()
{
if (!_initialized || _lastSource != Source)
{
NavigationManager.LocationChanged += NavigationManagerOnLocationChanged;
if (Source == null) return;
using var httpClient = new HttpClient() { BaseAddress = new Uri(NavigationManager.BaseUri) };
using var response = await httpClient.GetAsync(Source + "?" + Guid.NewGuid().ToString().Replace("-", ""));
Expand All @@ -59,6 +57,11 @@ protected override async Task OnParametersSetAsync()
}
}

private void NavigationManagerOnLocationChanged(object? sender, LocationChangedEventArgs e)
{
_files.Clear();
}

public static MatchCollection GetSamples(string data)
{
return Regex.Matches(data, @"{{sample=(.*?)}}");
Expand All @@ -77,6 +80,7 @@ public async Task<List<Sample>> GetContentBetweenSamplesAsync(MatchCollection ma
result.Add(new Sample { Content = ToMarkupString(source) });
return result;
}

// Adds the first part of the content before the first sample
foreach (var match in matchs)
{
Expand All @@ -85,108 +89,87 @@ public async Task<List<Sample>> GetContentBetweenSamplesAsync(MatchCollection ma
{
var sample = new Sample();
var typeName = match.ToString().Replace("/", ".").Replace("{{sample=", "").Replace("}}", "");
if(typeName.Contains(";"))
if (typeName.Contains(";"))
{
var parts = typeName.Split(";");
sample.Class = parts[1];
typeName = parts[0];
}

sample.Component = StringToType($"{namespaceRoot}.{typeName}");
sample.IndexPath = string.Join("/", typeName.Split(".").SkipLast(1)) + "/" + "index.txt";
if(result.Any(x => x.IndexPath == sample.IndexPath))

//Load the index file if it's not already loaded
if (_files.ContainsKey(sample.IndexPath))
{
sample.Index = result.First(x => x.IndexPath == sample.IndexPath).Index;
sample.Index = _files[sample.IndexPath];
}
else
{
using var httpClient = new HttpClient() { BaseAddress = new Uri(NavigationManager.BaseUri) };
using var response = await httpClient.GetAsync("docs/Samples/" + sample.IndexPath + "?" + Guid.NewGuid().ToString().Replace("-", ""));
if (response.StatusCode == HttpStatusCode.OK)
{
sample.Index = await response.Content.ReadAsStringAsync();
_files.TryAdd(sample.IndexPath, await response.Content.ReadAsStringAsync());
}
}

sample.Component = StringToType($"{namespaceRoot}.{typeName}");
var content = source.Substring(0, left + match.ToString().Length);
source = source.Substring(left + match.ToString().Length);
content = content.Replace(match.ToString(), "");
sample.Content = ToMarkupString(content);
result.Add(sample);

// Removes the content from the source
}
}


// Trim sample indexs to only related items
foreach (var sample in result)
{
if (sample.Index != null && sample.Component != null)
{
//Parse the index file to get the css and code files related to the sample
sample.Index = _files[sample.IndexPath];
var lines = sample.Index.Split("\n");
sample.Index = lines.Where(line => line.Contains(sample.Component.Name)).Aggregate("", (current, line) => current + (line + ";"));
sample.Index = sample.Index.Replace("\r", "").Replace("\n", "");
sample.Index = Regex.Replace(sample.Index, @"[^a-zA-Z0-9;:.,\s]", "");
}
}

//Finally load and cache all the files

foreach (var sample in result)
{
using var httpClient = new HttpClient() { BaseAddress = new Uri(NavigationManager.BaseUri) };
var lines = sample.Index.Split(";");
var path = sample.IndexPath.Replace("/index.txt", "");
foreach (var line in lines)
{
if (!_files.ContainsKey(line))
if (sample.Index.Contains(';'))
{
using var response = await httpClient.GetAsync("docs/Samples/" + path + "/" + line + "?" + Guid.NewGuid().ToString().Replace("-", ""));
if (response.StatusCode == HttpStatusCode.OK)
{
_files.Add(line, await response.Content.ReadAsStringAsync());
}
var items = sample.Index.Split(";");
var path = sample.IndexPath.Replace("/index.txt", "");
sample.HasCss = items.Any(x => x.EndsWith(".css.md"));
sample.HasCode = items.Any(x => x.EndsWith(".cs.md"));
sample.CssFile = $"{path}/{items.FirstOrDefault(x => x.EndsWith(".css.md"))}";
sample.CodeFile = $"{path}/{items.FirstOrDefault(x => x.EndsWith(".cs.md"))}";
sample.MarkupFile = $"{path}/{items.FirstOrDefault(x => x.EndsWith(".razor.md"))}";
if (sample.HasCode) _files.TryAdd(sample.CodeFile, null);
if (sample.HasCss) _files.TryAdd(sample.CssFile, null);
_files.TryAdd(sample.MarkupFile, null);
}


var content = source.Substring(0, left + match.ToString().Length);
// Removes the content from the source
source = source.Substring(left + match.ToString().Length);
content = content.Replace(match.ToString(), "");
sample.Content = ToMarkupString(content);
result.Add(sample);
}
}

// Adds the last part of the content after the last sample
result.Add(new Sample { Content = ToMarkupString(source) });
return result;
}

public static MarkupString ToMarkupString(string sample)
{
return new MarkupString(Markdown.ToHtml(sample, Pipeline));
}

public static string RemoveCode(string content)
{
content = Regex.Replace(content, @"^@using.*$\n", "", RegexOptions.Multiline);
content = Regex.Replace(content, @"^@inject.*$\n", "", RegexOptions.Multiline);
return Regex.Replace(content, @"@code\s*\{((?<Curly>\{)|(?<-Curly>\})|[^{}]+)*(?(Curly)(?!))\}", "", RegexOptions.Singleline);
}
public static string RemoveMarkup(string content)
{
return Regex.Match(content,@"@code\s*\{((?<Curly>\{)|(?<-Curly>\})|[^{}]+)*(?(Curly)(?!))\}", RegexOptions.Singleline).Value;
}
public static MarkupString ToSourceMarkupString(string sample)
public async Task<string?> LoadFile(string filePath)
{
sample = Regex.Replace(sample,@"<!--\\\\-->(.*?)<!--//-->", "" , RegexOptions.Singleline);
return new MarkupString(Markdown.ToHtml("```html\n" + sample + "\n```",SourcePipeline));
if (_files.TryGetValue(filePath, out var value)) return value;
using var httpClient = new HttpClient() { BaseAddress = new Uri(NavigationManager.BaseUri) };
using var response = await httpClient.GetAsync("docs/Samples/" + filePath + "?" + Guid.NewGuid().ToString().Replace("-", ""));
if (response.StatusCode == HttpStatusCode.OK)
{
_files.Add(filePath, await response.Content.ReadAsStringAsync());
}

return _files[filePath];
}

public static MarkupString ToCodeMarkupString(string sample)
public static MarkupString ToMarkupString(string sample)
{
sample = Regex.Replace(sample, @"<!--\\\\-->(.*?)<!--//-->", "", RegexOptions.Singleline);
//trim all lines that are empty
sample = string.Join("\n", sample.Split("\n").Where(x => !string.IsNullOrWhiteSpace(x)));
return new MarkupString(Markdown.ToHtml("```C#\n" + sample + "\n```", SourcePipeline));
return new MarkupString(Markdown.ToHtml(sample, Pipeline));
}

public static MarkupString ToCssMarkupString(string sample)
public void Dispose()
{
return new MarkupString(Markdown.ToHtml("```css\n" + sample + "\n```", SourcePipeline));
NavigationManager.LocationChanged -= NavigationManagerOnLocationChanged;
}
}
Loading

0 comments on commit cb2654e

Please sign in to comment.