-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
76 lines (61 loc) · 2.49 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
namespace Documentation
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine($"Documentation of {typeof(VkApi).Name}");
var specifier = new Specifier<VkApi>();
var methodNames = specifier.GetApiMethodNames();
foreach (var methodName in methodNames)
{
WriteWithColor($"{methodName}", ConsoleColor.Yellow);
var methodDescription = specifier.GetApiMethodFullDescription(methodName);
WriteWithColor($"\t{methodDescription.MethodDescription.Description}", ConsoleColor.DarkGreen);
Console.WriteLine();
WriteWithColor($"\tReturn", ConsoleColor.Green);
WriteParamDescription(methodDescription.ReturnDescription);
Console.WriteLine();
WriteWithColor($"\tParameters", ConsoleColor.Green);
foreach (var paramDescription in methodDescription.ParamDescriptions)
{
WriteWithColor($"\t{paramDescription.ParamDescription.Name}", ConsoleColor.DarkYellow);
WriteParamDescription(paramDescription);
Console.WriteLine();
}
Console.WriteLine();
}
}
private static void WriteParamDescription(ApiParamDescription description)
{
if (description == null)
{
return;
}
if (!string.IsNullOrWhiteSpace(description.ParamDescription?.Description))
{
WriteWithColor($"\t\t{description.ParamDescription?.Description}", ConsoleColor.DarkGreen);
}
WriteWithColor($"\t\tRequired - {description.Required}", ConsoleColor.DarkGreen);
if (description.MinValue != null)
{
WriteWithColor($"\t\tMin - {description.MinValue}", ConsoleColor.DarkGreen);
}
if (description.MaxValue != null)
{
WriteWithColor($"\t\tMax - {description.MaxValue}", ConsoleColor.DarkGreen);
}
}
private static void WriteWithColor(string line, ConsoleColor color, bool saveOldColor = true)
{
var oldColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(line);
if (saveOldColor)
{
Console.ForegroundColor = oldColor;
}
}
}
}