Skip to content

Commit 7790cba

Browse files
committed
Add docs support for TextUx
* Still more to come but this gets the basics in place
1 parent 69c724e commit 7790cba

File tree

10 files changed

+66
-9
lines changed

10 files changed

+66
-9
lines changed

docfx/TextUX/api/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# About
2+
Ubiquity.NET.TextUX contains general extensions for .NET. to support console (text) based applications

docfx/TextUX/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# About
2+
Ubiquity.NET.TextUX contains general extensions for .NET. to support console (text) based applications

docfx/TextUX/toc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# TOC (Left nav) for the 'extensions' folder
2+
- name: Overview
3+
href: index.md
4+
- name: Namespaces
5+
href: api/toc.yml

docfx/docfx.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@
6363
}
6464
],
6565
"dest": "interop-helpers/api"
66+
},
67+
{
68+
// TextUX library
69+
"memberLayout":"separatePages",
70+
"namespaceLayout":"nested",
71+
"src": [
72+
{
73+
"src": "../src/Ubiquity.NET.TextUX",
74+
"files": ["**.csproj"]
75+
}
76+
],
77+
"dest": "TextUX/api"
6678
}
6779
],
6880
"build": {
@@ -154,6 +166,18 @@
154166
"**/namespaces/**.md",
155167
"**/*-xref.yml"
156168
]
169+
},
170+
{
171+
// TextUX project additional content, Includes the generated metadata API folder
172+
// NOTE: File paths are relative to the location of this file
173+
"files": [
174+
"TextUX/**.{md,yml}"
175+
],
176+
// Exclude the namespace overwrites and XREF maps as they are listed explicitly elsewhere
177+
"exclude": [
178+
"**/namespaces/**.md",
179+
"**/*-xref.yml"
180+
]
157181
}
158182
],
159183
"resource": [

docfx/documentation.msbuildproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
<!-- Explicitly call out the non-generated files in the API folder-->
5656
<None Include="interop-helpers/api/index.md" />
5757
</ItemGroup>
58+
<ItemGroup>
59+
<!--Everything in the TextUX sub-folders except the API folder as that contains generated files -->
60+
<None Include="TextUX/**" Exclude="TextUX/api/**" />
61+
<!-- Explicitly call out the non-generated files in the API folder-->
62+
<None Include="TextUX/api/index.md" />
63+
</ItemGroup>
5864
<Target Name="AlwaysRun" BeforeTargets="AfterBuild">
5965
<Message Importance="High" Text="NOTE: Building $(MSBuildProjectFile) does NOTHING, docs are built using the docfx tool. This project is simply a convenient placeholder for organizing/editing files" />
6066
</Target>

docfx/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ included.
1414
| [Ubiquity.NET.Runtime.Utils](runtime-utils/index.md) | This library contains common support for DSL runtime and language implementors |
1515
| [Ubiquity.NET.Extensions](extensions/index.md) | This library contains general extensions and helpers for many scenarios using .NET |
1616
| [Ubiquity.NET.Antlr.Utils](antlr-utils/index.md) | This library contains extensions and helpers for using ANTLR with .NET |
17+
| [Ubiquity.NET.TextUX](TextUX/index.md) | This library contains extensions and helpers for Text User eXperience (UX) applications (console) |
1718
| [Ubiquity.NET.InteropHelpers](interop-helpers/index.md) | This library contains extensions and helpers for implementing interop support for native libraries |

docfx/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
href: extensions/index.md
1818
- name: ANTLR Utilities
1919
href: antlr-utils/index.md
20+
- name: TextUX Utilities
21+
href: TextUX/index.md
2022
- name: Interop Helpers
2123
href: interop-helpers/index.md

src/Ubiquity.NET.TextUX/ColoredConsoleReporter.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ public ColoredConsoleReporter( MsgLevel level = MsgLevel.Information)
1818
{
1919
}
2020

21+
/// <remarks>
22+
/// This implementation will apply ANSI color code sequences to each message based on <paramref name="level"/>.
23+
/// The colors are:
24+
/// <list type="table">
25+
/// <listheader><term>Level</term><description>Description</description></listheader>
26+
/// <item><term><see cref="MsgLevel.Verbose"/></term><description> Default console color</description></item>
27+
/// <item><term><see cref="MsgLevel.Information"/></term><description> Blue</description></item>
28+
/// <item><term><see cref="MsgLevel.Warning"/></term><description> Yellow</description></item>
29+
/// <item><term><see cref="MsgLevel.Error"/></term><description> Red</description></item>
30+
/// </list>
31+
/// </remarks>
2132
/// <inheritdoc/>
2233
protected override void ReportMessage( MsgLevel level, string msg )
2334
{

src/Ubiquity.NET.TextUX/ConsoleReporter.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
33

44
using System;
5-
using System.Globalization;
65
using System.Text;
76

87
namespace Ubiquity.NET.TextUX
98
{
109
/// <summary>Implementation of <see cref="IDiagnosticReporter"/> that reports messages to <see cref="Console"/></summary>
1110
/// <remarks>
12-
/// <see cref="MsgLevel.Error"/> is reported to <see cref="Console.Error"/> while other levels, if
13-
/// enabled, are reported to <see cref="Console.Out"/>
11+
/// Messages with a <see cref="DiagnosticMessage.Level"/> of <see cref="MsgLevel.Error"/> are reported to the console's <see cref="Console.Error"/>
12+
/// writer, while other levels, if enabled, are reported to the console's <see cref="Console.Out"/> writer.
1413
/// </remarks>
1514
public class ConsoleReporter
1615
: IDiagnosticReporter
@@ -34,7 +33,9 @@ public ConsoleReporter( MsgLevel level = MsgLevel.Information)
3433

3534
/// <inheritdoc/>
3635
/// <remarks>
37-
/// This implementation currently ignores the source of any diagnostics
36+
/// This implementation will test if the <see cref="DiagnosticMessage.Level"/> of the
37+
/// message is enabled. If so, then a call is made to the virtual <see cref="ReportMessage(MsgLevel, string)"/>
38+
/// with the results of <see cref="DiagnosticMessage.ToString()"/> as the message text.
3839
/// </remarks>
3940
public void Report( DiagnosticMessage diagnostic )
4041
{
@@ -43,16 +44,16 @@ public void Report( DiagnosticMessage diagnostic )
4344
return;
4445
}
4546

46-
ReportMessage(diagnostic.Level, diagnostic.ToString("G", CultureInfo.CurrentCulture));
47+
ReportMessage(diagnostic.Level, diagnostic.ToString());
4748
}
4849

4950
/// <summary>Virtual method to report a message formatted as a string</summary>
5051
/// <param name="level">Level of the message</param>
5152
/// <param name="msg">Message formatted as a string</param>
5253
/// <remarks>
5354
/// The default base implementation will simply redirect messages based on <paramref name="level"/> to
54-
/// <see cref="Console.Error"/> if <paramref name="level"/> == <see cref="MsgLevel.Error"/> or <see cref="Console.Out"/>
55-
/// for any other levels.
55+
/// the console's <see cref="Console.Error"/> writer if <paramref name="level"/> == <see cref="MsgLevel.Error"/>
56+
/// otherwise the <see cref="Console.Out"/> writer is used.
5657
/// </remarks>
5758
/// <exception cref="InvalidOperationException">Invalid/Unknown level - should never hit this, internal error if it does.</exception>
5859
protected virtual void ReportMessage(MsgLevel level, string msg)

src/Ubiquity.NET.TextUX/SourceRange.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public readonly record struct SourceRange
3535
public required SourcePosition End { get; init; }
3636

3737
/// <summary>Gets a value indicating whether this instance can slice an input</summary>
38-
/// <remarks>Attempts to slice an input when this is <see langword="false"/></remarks>
38+
/// <remarks>Attempts to slice an input when this is <see langword="false"/> result in an empty string.</remarks>
3939
public bool CanSlice => Start.Index.HasValue && End.Index.HasValue;
4040

4141
/// <summary>Gets the length of the range in characters if available</summary>
@@ -72,7 +72,10 @@ public string ToString( string? format, IFormatProvider? formatProvider )
7272
/// <returns>slice representing the characters of this range</returns>
7373
/// <exception cref="ArgumentOutOfRangeException">Thrown when the start or end of the range is not in range of the input source (&lt;0 or &gt;=Length)</exception>
7474
/// <remarks>
75-
/// If <see cref="CanSlice"/> is <see langword="false"/> then this returns an empty span. (i.e., does not throw)
75+
/// If <see cref="CanSlice"/> is <see langword="false"/> then this returns an empty span. (i.e., does not throw).
76+
/// Slicing is only possible if BOTH the <see cref="Start"/> and <see cref="End"/> have an <see cref="SourcePosition.Index"/> value as
77+
/// it is the index that is used to mark the start and end of the slice. Since various text sources track line positions uniquely
78+
/// they are not reliable for slicing the source.
7679
/// </remarks>
7780
public ReadOnlySpan<char> Slice(ReadOnlySpan<char> source)
7881
{

0 commit comments

Comments
 (0)