mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 05:18:16 +08:00
Docs redesign (#728)
* Adding a dark mode * Adding reference for types to summary pages * Adding API Reference * Adding modifiers to methods/fields/etc * Minimizing files input * Caching a lot of the output pages * Cache only for each execution * Adding API references to existing docs
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Borders;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Calendars;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -4,8 +4,9 @@ Licensed under GNU Free Documentation License 1.2
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Canvas;
|
||||
|
||||
public static class Mandelbrot
|
||||
{
|
||||
@ -39,9 +40,9 @@ public static class Mandelbrot
|
||||
}
|
||||
}
|
||||
|
||||
public static Canvas Generate(int width, int height)
|
||||
public static Spectre.Console.Canvas Generate(int width, int height)
|
||||
{
|
||||
var canvas = new Canvas(width, height);
|
||||
var canvas = new Spectre.Console.Canvas(width, height);
|
||||
|
||||
var scale = 2 * MaxValueExtent / Math.Min(canvas.Width, canvas.Height);
|
||||
for (var i = 0; i < canvas.Height; i++)
|
||||
|
@ -1,9 +1,10 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Canvas;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Charts;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,7 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Examples;
|
||||
|
||||
namespace Colors;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Columns;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
@ -16,7 +17,7 @@ public static class Program
|
||||
}
|
||||
|
||||
// Render all cards in columns
|
||||
AnsiConsole.Write(new Columns(cards));
|
||||
AnsiConsole.Write(new Spectre.Console.Columns(cards));
|
||||
}
|
||||
|
||||
private static string GetCardContent(User user)
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Columns;
|
||||
|
||||
public sealed class User
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Cursor;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Emojis;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -3,8 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Authentication;
|
||||
using System.Threading.Tasks;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Exceptions;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Figlet;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Grids;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Info;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Links;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Live;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace LiveTable;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Panels;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Progress;
|
||||
|
||||
public static class DescriptionGenerator
|
||||
{
|
||||
|
@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Progress;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Prompt
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
@ -12,18 +14,28 @@ namespace Spectre.Console.Examples
|
||||
}
|
||||
|
||||
// Confirmation
|
||||
if (!AnsiConsole.Confirm("Run prompt example?"))
|
||||
if (!AskConfirmation())
|
||||
{
|
||||
AnsiConsole.MarkupLine("Ok... :(");
|
||||
return;
|
||||
}
|
||||
|
||||
// Ask the user for some different things
|
||||
WriteDivider("Strings");
|
||||
var name = AskName();
|
||||
|
||||
WriteDivider("Lists");
|
||||
var fruit = AskFruit();
|
||||
|
||||
WriteDivider("Choices");
|
||||
var sport = AskSport();
|
||||
|
||||
WriteDivider("Integers");
|
||||
var age = AskAge();
|
||||
|
||||
WriteDivider("Secrets");
|
||||
var password = AskPassword();
|
||||
|
||||
WriteDivider("Optional");
|
||||
var color = AskColor();
|
||||
|
||||
// Summary
|
||||
@ -40,19 +52,31 @@ namespace Spectre.Console.Examples
|
||||
.AddRow("[grey]Favorite color[/]", string.IsNullOrEmpty(color) ? "Unknown" : color));
|
||||
}
|
||||
|
||||
private static string AskName()
|
||||
private static void WriteDivider(string text)
|
||||
{
|
||||
AnsiConsole.WriteLine();
|
||||
AnsiConsole.Write(new Rule("[yellow]Strings[/]").RuleStyle("grey").LeftAligned());
|
||||
AnsiConsole.Write(new Rule($"[yellow]{text}[/]").RuleStyle("grey").LeftAligned());
|
||||
}
|
||||
|
||||
public static bool AskConfirmation()
|
||||
{
|
||||
if (!AnsiConsole.Confirm("Run prompt example?"))
|
||||
{
|
||||
AnsiConsole.MarkupLine("Ok... :(");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string AskName()
|
||||
{
|
||||
var name = AnsiConsole.Ask<string>("What's your [green]name[/]?");
|
||||
return name;
|
||||
}
|
||||
|
||||
private static string AskFruit()
|
||||
public static string AskFruit()
|
||||
{
|
||||
AnsiConsole.WriteLine();
|
||||
AnsiConsole.Write(new Rule("[yellow]Lists[/]").RuleStyle("grey").LeftAligned());
|
||||
|
||||
var favorites = AnsiConsole.Prompt(
|
||||
new MultiSelectionPrompt<string>()
|
||||
.PageSize(10)
|
||||
@ -87,11 +111,8 @@ namespace Spectre.Console.Examples
|
||||
return fruit;
|
||||
}
|
||||
|
||||
private static string AskSport()
|
||||
public static string AskSport()
|
||||
{
|
||||
AnsiConsole.WriteLine();
|
||||
AnsiConsole.Write(new Rule("[yellow]Choices[/]").RuleStyle("grey").LeftAligned());
|
||||
|
||||
return AnsiConsole.Prompt(
|
||||
new TextPrompt<string>("What's your [green]favorite sport[/]?")
|
||||
.InvalidChoiceMessage("[red]That's not a sport![/]")
|
||||
@ -101,11 +122,8 @@ namespace Spectre.Console.Examples
|
||||
.AddChoice("Basketball"));
|
||||
}
|
||||
|
||||
private static int AskAge()
|
||||
public static int AskAge()
|
||||
{
|
||||
AnsiConsole.WriteLine();
|
||||
AnsiConsole.Write(new Rule("[yellow]Integers[/]").RuleStyle("grey").LeftAligned());
|
||||
|
||||
return AnsiConsole.Prompt(
|
||||
new TextPrompt<int>("How [green]old[/] are you?")
|
||||
.PromptStyle("green")
|
||||
@ -121,22 +139,16 @@ namespace Spectre.Console.Examples
|
||||
}));
|
||||
}
|
||||
|
||||
private static string AskPassword()
|
||||
public static string AskPassword()
|
||||
{
|
||||
AnsiConsole.WriteLine();
|
||||
AnsiConsole.Write(new Rule("[yellow]Secrets[/]").RuleStyle("grey").LeftAligned());
|
||||
|
||||
return AnsiConsole.Prompt(
|
||||
new TextPrompt<string>("Enter [green]password[/]?")
|
||||
.PromptStyle("red")
|
||||
.Secret());
|
||||
}
|
||||
|
||||
private static string AskColor()
|
||||
public static string AskColor()
|
||||
{
|
||||
AnsiConsole.WriteLine();
|
||||
AnsiConsole.Write(new Rule("[yellow]Optional[/]").RuleStyle("grey").LeftAligned());
|
||||
|
||||
return AnsiConsole.Prompt(
|
||||
new TextPrompt<string>("[grey][[Optional]][/] What is your [green]favorite color[/]?")
|
||||
.AllowEmpty());
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Rules;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Showcase;
|
||||
|
||||
public static class ExceptionGenerator
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Spectre.Console;
|
||||
using Spectre.Console.Examples;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Showcase;
|
||||
|
||||
public static partial class Program
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Threading;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Spectre.Console.Examples;
|
||||
namespace Status;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Tables;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace Spectre.Console.Examples;
|
||||
using Spectre.Console;
|
||||
|
||||
namespace Trees;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
|
Reference in New Issue
Block a user