diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-customizing-help-usage.tape b/Spectre.Docs.Cli.Examples/VCR/cli-customizing-help-usage.tape
new file mode 100644
index 0000000..d989e8c
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-customizing-help-usage.tape
@@ -0,0 +1,14 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 80
+Set Rows 20
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.CustomizingHelpText.Demo.RunAsync(System.String[])"
+
+Exec "./example --help"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-customizing-help-usage.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-defining-arguments-help.tape b/Spectre.Docs.Cli.Examples/VCR/cli-defining-arguments-help.tape
new file mode 100644
index 0000000..31d04ba
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-defining-arguments-help.tape
@@ -0,0 +1,14 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 80
+Set Rows 20
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.DefiningCommandsAndArguments.Demo.RunAsync(System.String[])"
+
+Exec "./example --help"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-defining-arguments-help.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-di-step1.tape b/Spectre.Docs.Cli.Examples/VCR/cli-di-step1.tape
new file mode 100644
index 0000000..ad0741f
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-di-step1.tape
@@ -0,0 +1,17 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 10
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.DependencyInjection.NoDI.Demo.RunAsync(System.String[])"
+
+Exec "./example Alice"
+Wait
+Sleep 1s
+Exec "./example Alice --formal"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-di-step1.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-di-step2.tape b/Spectre.Docs.Cli.Examples/VCR/cli-di-step2.tape
new file mode 100644
index 0000000..50c700a
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-di-step2.tape
@@ -0,0 +1,14 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 8
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.DependencyInjection.WithService.Demo.RunAsync(System.String[])"
+
+Exec "./example Alice"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-di-step2.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-di-step3.tape b/Spectre.Docs.Cli.Examples/VCR/cli-di-step3.tape
new file mode 100644
index 0000000..f25c116
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-di-step3.tape
@@ -0,0 +1,20 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 12
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.DependencyInjection.DIComplete.Demo.RunAsync(System.String[])"
+
+Exec "./example Alice"
+Wait
+Sleep 1s
+Exec "./example Alice --style Formal"
+Wait
+Sleep 1s
+Exec "./example Alice --style Enthusiastic"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-di-step3.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-dictionary-lookup-output.tape b/Spectre.Docs.Cli.Examples/VCR/cli-dictionary-lookup-output.tape
new file mode 100644
index 0000000..cc4adc7
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-dictionary-lookup-output.tape
@@ -0,0 +1,14 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 80
+Set Rows 14
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.DictionaryOptions.Demo.RunAsync(System.String[])"
+
+Exec "./example --lookup env=dev --lookup env=staging --lookup env=prod --lookup region=us"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-dictionary-lookup-output.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-flag-arguments-help.tape b/Spectre.Docs.Cli.Examples/VCR/cli-flag-arguments-help.tape
new file mode 100644
index 0000000..8fc766f
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-flag-arguments-help.tape
@@ -0,0 +1,14 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 80
+Set Rows 20
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.FlagArguments.Demo.RunAsync(System.String[])"
+
+Exec "./example --help"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-flag-arguments-help.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-logging-step1.tape b/Spectre.Docs.Cli.Examples/VCR/cli-logging-step1.tape
new file mode 100644
index 0000000..39a0c2a
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-logging-step1.tape
@@ -0,0 +1,14 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 12
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.Logging.NoLogging.Demo.RunAsync(System.String[])"
+
+Exec "./example myfile.txt"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-logging-step1.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-logging-step2.tape b/Spectre.Docs.Cli.Examples/VCR/cli-logging-step2.tape
new file mode 100644
index 0000000..b35c05d
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-logging-step2.tape
@@ -0,0 +1,14 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 14
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.Logging.WithLogging.Demo.RunAsync(System.String[])"
+
+Exec "./example myfile.txt"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-logging-step2.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-logging-step3.tape b/Spectre.Docs.Cli.Examples/VCR/cli-logging-step3.tape
new file mode 100644
index 0000000..90009e4
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-logging-step3.tape
@@ -0,0 +1,20 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 20
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.Logging.LoggingComplete.Demo.RunAsync(System.String[])"
+
+Exec "./example myfile.txt"
+Wait
+Sleep 1s
+Exec "./example myfile.txt --logLevel Debug"
+Wait
+Sleep 1s
+Exec "./example myfile.txt --logLevel Warning"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-logging-step3.svg"
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step1.tape b/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step1.tape
new file mode 100644
index 0000000..a95c973
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step1.tape
@@ -0,0 +1,21 @@
+Output "Spectre.Docs/Content/assets/cli-multi-command-step1.svg"
+
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 12
+Set EndBuffer 5s
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.MultiCommand.Step1.Demo.RunAsync(System.String[])"
+
+Type "./example add Newtonsoft.Json"
+Sleep 400ms
+Enter
+Sleep 1s
+
+Type "./example list"
+Sleep 400ms
+Enter
+Sleep 3s
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step2.tape b/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step2.tape
new file mode 100644
index 0000000..bcdc79d
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step2.tape
@@ -0,0 +1,26 @@
+Output "Spectre.Docs/Content/assets/cli-multi-command-step2.svg"
+
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 16
+Set EndBuffer 5s
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.MultiCommand.Step2.Demo.RunAsync(System.String[])"
+
+Type "./example add package Newtonsoft.Json"
+Sleep 400ms
+Enter
+Sleep 1s
+
+Type "./example add reference ../MyLib/MyLib.csproj"
+Sleep 400ms
+Enter
+Sleep 1s
+
+Type "./example add --help"
+Sleep 400ms
+Enter
+Sleep 5s
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step3.tape b/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step3.tape
new file mode 100644
index 0000000..9fe493f
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-multi-command-step3.tape
@@ -0,0 +1,21 @@
+Output "Spectre.Docs/Content/assets/cli-multi-command-step3.svg"
+
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 70
+Set Rows 18
+Set EndBuffer 5s
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.MultiCommand.Finished.Demo.RunAsync(System.String[])"
+
+Type "./example add package Serilog --version 3.0.0 --verbose"
+Sleep 400ms
+Enter
+Sleep 1s
+
+Type "./example list --verbose"
+Sleep 400ms
+Enter
+Sleep 3s
diff --git a/Spectre.Docs.Cli.Examples/VCR/cli-required-options-help.tape b/Spectre.Docs.Cli.Examples/VCR/cli-required-options-help.tape
new file mode 100644
index 0000000..c4d7004
--- /dev/null
+++ b/Spectre.Docs.Cli.Examples/VCR/cli-required-options-help.tape
@@ -0,0 +1,14 @@
+Set DisableCursor true
+Set Shell "pwsh"
+Set FontSize 22
+Set Theme "one dark"
+Set TransparentBackground "true"
+Set Cols 80
+Set Rows 20
+Set WorkingDirectory "Spectre.Docs.Cli.Examples/bin/Debug/net10.0"
+Env SPECTRE_APP "M:Spectre.Docs.Cli.Examples.DemoApps.MakingOptionsRequired.Demo.RunAsync(System.String[])"
+
+Exec "./example --help"
+Wait
+Sleep 1s
+Screenshot "Spectre.Docs/Content/assets/cli-required-options-help.svg"
diff --git a/Spectre.Docs.Examples/VCR/creating-custom-renderables-tutorial.tape b/Spectre.Docs.Examples/VCR/creating-custom-renderables-tutorial.tape
index 13f73ba..876f199 100644
--- a/Spectre.Docs.Examples/VCR/creating-custom-renderables-tutorial.tape
+++ b/Spectre.Docs.Examples/VCR/creating-custom-renderables-tutorial.tape
@@ -1,5 +1,3 @@
-Output "anim.svg"
-
Set DisableCursor true
Set FontSize 22
Set Theme "one dark"
diff --git a/Spectre.Docs.Examples/VCR/rule.tape b/Spectre.Docs.Examples/VCR/rule.tape
index 2085291..f967e85 100644
--- a/Spectre.Docs.Examples/VCR/rule.tape
+++ b/Spectre.Docs.Examples/VCR/rule.tape
@@ -1,5 +1,4 @@
Output "Spectre.Docs/Content/assets/rule.svg"
-Output "Spectre.Docs/Content/assets/rule.gif"
Set DisableCursor true
Set FontSize 22
Set Theme "one dark"
diff --git a/Spectre.Docs/Components/Shared/Screenshot.razor b/Spectre.Docs/Components/Shared/Screenshot.razor
index b84e7a8..5f44646 100644
--- a/Spectre.Docs/Components/Shared/Screenshot.razor
+++ b/Spectre.Docs/Components/Shared/Screenshot.razor
@@ -14,7 +14,16 @@
? $"width: 100%; aspect-ratio: {_aspectRatio};"
: "width: 100%;";
}
-
+ @if (_svgContent != null)
+ {
+
+ @((MarkupString)_svgContent)
+
+ }
+ else
+ {
+
+ }
@@ -26,22 +35,36 @@
[Parameter]
public string Alt { get; set; } = "Screenshot";
+ [Parameter]
+ public bool Embed { get; set; }
+
private string? _aspectRatio;
+ private string? _svgContent;
protected override void OnParametersSet()
{
_aspectRatio = null;
+ _svgContent = null;
// Only process SVG files from /assets/
if (!string.IsNullOrEmpty(Src) &&
Src.StartsWith("/assets/", StringComparison.OrdinalIgnoreCase) &&
Src.EndsWith(".svg", StringComparison.OrdinalIgnoreCase))
{
- _aspectRatio = TryGetAspectRatio(Src);
+ var contentPath = ResolvePath(Src);
+ if (contentPath != null && File.Exists(contentPath))
+ {
+ if (Embed)
+ {
+ _svgContent = TryReadAndPrepareSvg(contentPath);
+ }
+
+ _aspectRatio = TryParseAspectRatio(_svgContent, contentPath);
+ }
}
}
- private string? TryGetAspectRatio(string srcUrl)
+ private string? ResolvePath(string srcUrl)
{
try
{
@@ -54,19 +77,56 @@
relativePath = relativePath.Replace('/', Path.DirectorySeparatorChar);
}
- var contentPath = Path.Combine(Environment.ContentRootPath, "Content", relativePath);
+ return Path.Combine(Environment.ContentRootPath, "Content", relativePath);
+ }
+ catch
+ {
+ return null;
+ }
+ }
- if (!File.Exists(contentPath))
+ private static string? TryReadAndPrepareSvg(string contentPath)
+ {
+ try
+ {
+ var svg = File.ReadAllText(contentPath);
+
+ // Inject width="100%" so inline SVG scales to fill container.
+ // viewBox handles aspect ratio preservation automatically.
+ svg = System.Text.RegularExpressions.Regex.Replace(
+ svg,
+ @"