Skip to content

Commit e4781c3

Browse files
committed
Documentation
1 parent 383a447 commit e4781c3

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

Source/SVGImage/SVG/Shapes/LengthPercentageOrNumber.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ public struct LengthPercentageOrNumber
99
private static readonly Regex _lengthRegex = new Regex(@"(?<Value>\d+(?:\.\d+)?)\s*(?<Unit>%|\w+)?", RegexOptions.Compiled | RegexOptions.Singleline);
1010
private readonly LengthContext _context;
1111
private readonly double _value;
12+
/// <summary>
13+
/// Represents a length, percentage, or number value that has been resolved based on the context.
14+
/// </summary>
1215
public double Value => ResolveValue();
1316

1417

@@ -130,15 +133,33 @@ private double ResolveValue()
130133
}
131134
}
132135
/// <summary>
133-
///
136+
/// Represents a length that may have a value that is context dependent.
134137
/// </summary>
135-
/// <param name="value"></param>
136-
/// <param name="context">If null, units will be ignored</param>
138+
/// <param name="value">The numerical part of the length that is related to the <paramref name="context"/></param>
139+
/// <param name="context">If <see langword="null"/>, units will be ignored</param>
137140
public LengthPercentageOrNumber(double value, LengthContext context)
138141
{
139142
_context = context;
140143
_value = value;
141144
}
145+
/// <summary>
146+
/// Parses a string representation of a length, percentage, or number value into a <see cref="LengthPercentageOrNumber"/> instance.
147+
/// </summary>
148+
/// <param name="owner">
149+
/// The element that the length is associated with.
150+
/// </param>
151+
/// <param name="value">A string representation of a length</param>
152+
/// <param name="orientation">Used to establish the context of the length.
153+
/// Should be <see cref="LengthOrientation.Horizontal"/> for inherntly horizontal values like 'x' and 'dx'.
154+
/// Should be <see cref="LengthOrientation.Vertical"/> for inherntly vertical values like 'y' and 'dy'.
155+
/// Should be <see cref="LengthOrientation.None"/> for other values.
156+
/// </param>
157+
/// <returns>
158+
/// A <see cref="LengthPercentageOrNumber"/> instance that represents the parsed value.
159+
/// </returns>
160+
/// <exception cref="ArgumentException">
161+
/// Thrown when the provided value is not a valid length, percentage, or number.
162+
/// </exception>
142163
public static LengthPercentageOrNumber Parse(Shape owner, string value, LengthOrientation orientation = LengthOrientation.None)
143164
{
144165
var lengthMatch = _lengthRegex.Match(value.Trim());

Source/SVGImage/SVG/Shapes/LengthPercentageOrNumberList.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ private LengthPercentageOrNumberList(Shape owner, LengthOrientation orientation
1818
_owner = owner;
1919
_orientation = orientation;
2020
}
21+
/// <summary>
22+
/// Creates a new instance of LengthPercentageOrNumberList with the specified owner and orientation.
23+
/// </summary>
24+
/// <param name="owner">
25+
/// The element that the length list is associated with.
26+
/// </param>
27+
/// <param name="value">A string representation of a length list</param>
28+
/// <param name="orientation">Used to establish the context of the lengths.
29+
/// Should be <see cref="LengthOrientation.Horizontal"/> for inherntly horizontal values like 'x' and 'dx'.
30+
/// Should be <see cref="LengthOrientation.Vertical"/> for inherntly vertical values like 'y' and 'dy'.
31+
/// Should be <see cref="LengthOrientation.None"/> for other values.
32+
/// </param>
2133
public LengthPercentageOrNumberList(Shape owner, string value, LengthOrientation orientation = LengthOrientation.None) : this(owner, orientation)
2234
{
2335
Parse(value);

Source/SVGImage/SVG/Shapes/Text.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace SVGImage.SVG
88
using Shapes;
99
using System.Linq;
1010

11+
/// <summary>
12+
/// The original TextShape class.
13+
/// </summary>
1114
public sealed class TextShape2 : Shape
1215
{
1316
public TextShape2(SVG svg, XmlNode node, Shape parent)

Source/SVGImage/SVG/Shapes/TextPath.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace SVGImage.SVG.Shapes
55
{
6+
/// <summary>
7+
/// A placeholder class for TextPath.
8+
/// </summary>
69
internal class TextPath : TextShapeBase, ITextChild
710
{
811
protected TextPath(SVG svg, XmlNode node, Shape parent) : base(svg, node, parent)

Source/SVGImage/SVG/Shapes/TextRender.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ namespace SVGImage.SVG.Shapes
88
using System.Linq;
99
using System.Windows.Markup;
1010

11+
/// <summary>
12+
/// This class is responsible for rendering text shapes in SVG.
13+
/// </summary>
1114
public sealed partial class TextRender : TextRenderBase
1215
{
13-
14-
1516
public override GeometryGroup BuildTextGeometry(TextShape text)
1617
{
1718

Source/SVGImage/SVG/Shapes/TextString.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@
66

77
[DebuggerDisplay("{Text}")]
88
/// <summary>
9-
/// Text not wrapped in a tspan element.
9+
/// The leaf of the Text tree
1010
/// </summary>
1111
public class TextString : ITextChild
1212
{
13+
private static readonly Regex _trimmedWhitespace = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.Singleline);
14+
/// <summary>
15+
/// Represents the layout info for the string of text owned by this TextString.
16+
/// </summary>
1317
public CharacterLayout[] Characters { get; set; }
1418
public Shape Parent { get; set; }
15-
public int Index { get; set; }
16-
private static readonly Regex _trimmedWhitespace = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.Singleline);
19+
/// <summary>
20+
/// The index of this TextString in the root TextShape. This is set by the <see cref="TextRender"/>.
21+
/// </summary>
22+
public int Index { get; internal set; }
1723
public TextString(Shape parent, string text)
1824
{
1925
Parent = parent;

0 commit comments

Comments
 (0)