Skip to content

Commit

Permalink
Added code docs to Foobricator to remove all warnings on build
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffles committed Oct 18, 2015
1 parent 0342560 commit 19c8756
Show file tree
Hide file tree
Showing 33 changed files with 747 additions and 28 deletions.
6 changes: 6 additions & 0 deletions src/Foobricator.Tests/WhenNativelyFormattingAString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Foobricator.Tests
{
/// <summary>
/// Tests when formatting a string
/// </summary>
[TestClass]
public class WhenNativelyFormattingAString
{
Expand All @@ -28,6 +31,9 @@ public string ToString(string format, IFormatProvider formatProvider)
}
}

/// <summary>
/// Sample usage of custom formatting
/// </summary>
[TestMethod]
public void ThenCustomClassesShouldPrintProperly()
{
Expand Down
47 changes: 47 additions & 0 deletions src/Foobricator/DataSets/CrossJoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@

namespace Foobricator.DataSets
{
/// <summary>
/// Cross join two lists
/// </summary>
public class CrossJoin : IList<object>
{
private List<object> _list;

/// <summary>
/// Initialise
/// </summary>
/// <param name="refA"></param>
/// <param name="refB"></param>
public CrossJoin(DataReference refA, DataReference refB )
{
var a = refA.Dereference() as IList<object>;
Expand All @@ -17,66 +25,105 @@ public CrossJoin(DataReference refA, DataReference refB )
_list = a.Join(b, p => 1, p => 1, (l, r) => new List<object> {l, r}).Cast<object>().ToList();
}

/// <summary>
/// An enumerator for the joined list
/// </summary>
public IEnumerator<object> GetEnumerator()
{
return _list.GetEnumerator();
}

/// <summary>
/// An enumerator for the joined list
/// </summary>
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}

/// <summary>
/// See List
/// </summary>
public void Add(object item)
{
_list.Add(item);
}

/// <summary>
/// See List
/// </summary>
public void Clear()
{
_list.Clear();
}

/// <summary>
/// See List
/// </summary>
public bool Contains(object item)
{
return _list.Contains(item);
}

/// <summary>
/// See List
/// </summary>
public void CopyTo(object[] array, int arrayIndex)
{
_list.CopyTo(array, arrayIndex);
}

/// <summary>
/// See List
/// </summary>
public bool Remove(object item)
{
return _list.Remove(item);
}

/// <summary>
/// See List
/// </summary>
public int Count
{
get { return _list.Count; }
}

/// <summary>
/// Always true
/// </summary>
public bool IsReadOnly
{
get { return true; }
}

/// <summary>
/// See List
/// </summary>
public int IndexOf(object item)
{
return _list.IndexOf(item);
}

/// <summary>
/// See List
/// </summary>
public void Insert(int index, object item)
{
_list.Insert(index, item);
}

/// <summary>
/// See List
/// </summary>
public void RemoveAt(int index)
{
_list.RemoveAt(index);
}

/// <summary>
/// Get item at
/// </summary>
public object this[int index]
{
get { return _list[index]; }
Expand Down
3 changes: 3 additions & 0 deletions src/Foobricator/Output/ConditionalOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public ConditionalOutput(IEnumerable<IOutput> target, When when)
Target = target.ToList();
}

/// <summary>
/// Debug information from parsing. From <see cref="Foobricator.Tools.IDebugInfoProvider"/>
/// </summary>
public DebugInfo DebugInfo { get; set; }

/// <summary>
Expand Down
16 changes: 12 additions & 4 deletions src/Foobricator/Output/FormatString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Foobricator.Output
{
/// <summary>
/// Output a cusotm formatted string against an source data set
/// Output a custom formatted string against an source data set
/// </summary>
public class FormatString : IOutput, IDebugInfoProvider
{
Expand All @@ -23,13 +23,14 @@ public class FormatString : IOutput, IDebugInfoProvider
/// </summary>
public readonly object Source;

/// <summary>
/// Don't emit an end line
/// </summary>
public readonly bool SuppressEndLine;

/// <summary>
/// Create a new instance
/// </summary>
/// <param name="reference"></param>
/// <param name="formatString"></param>
/// </summary>
/// <example>{type:"formatString", format:"First{0}|Second{1}", source:{type:"reference", refersTo:"mySource"} }</example>
public FormatString(DataReference reference, string formatString, bool suppressEndLine)
{
Expand All @@ -38,13 +39,20 @@ public FormatString(DataReference reference, string formatString, bool suppressE
SuppressEndLine = suppressEndLine;
}

/// <summary>
/// Create a new instance
/// </summary>
/// <example>{type:"formatString", format:"First{0}|Second{1}", source:{type:"reference", refersTo:"mySource"} }</example>
public FormatString(ISource source, string formatString, bool suppressEndLine)
{
Source = source;
Format = formatString;
SuppressEndLine = suppressEndLine;
}

/// <summary>
/// Debug information from parsing. From <see cref="Foobricator.Tools.IDebugInfoProvider"/>
/// </summary>
public DebugInfo DebugInfo { get; set; }

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Foobricator/Output/IOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

namespace Foobricator.Output
{
/// <summary>
/// Interface for an output node
/// </summary>
public interface IOutput
{
/// <summary>
/// Implementing classes must evaluate and emit to the text writer
/// </summary>
void Evaluate(TextWriter writer);
}
}
16 changes: 16 additions & 0 deletions src/Foobricator/Output/Literal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,36 @@

namespace Foobricator.Output
{
/// <summary>
/// Emits a literal value
/// </summary>
public class Literal: IOutput, IDebugInfoProvider
{
/// <summary>
/// The value of the literal
/// </summary>
public readonly string Value;

/// <summary>
/// Initialise
/// </summary>
public Literal(string value)
{
Value = value;
}

/// <summary>
/// Emits <c>Value</c>
/// </summary>
/// <param name="writer"></param>
public void Evaluate(TextWriter writer)
{
writer.Write(Value);
}

/// <summary>
/// Debug information from parsing. From <see cref="Foobricator.Tools.IDebugInfoProvider"/>
/// </summary>
public DebugInfo DebugInfo { get; set; }
}
}
28 changes: 28 additions & 0 deletions src/Foobricator/Output/Times.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,34 @@

namespace Foobricator.Output
{
/// <summary>
/// A repeater output.
/// </summary>
public class Times : IOutput, IDebugInfoProvider
{
/// <summary>
/// List of outputs
/// </summary>
public readonly List<IOutput> Target;

/// <summary>
/// Number of times to repeat
/// </summary>
public readonly int Count;

/// <summary>
/// What to emit between repeats
/// </summary>
public readonly string Separator;

/// <summary>
/// The iterator scope
/// </summary>
public readonly string Scope;

/// <summary>
/// Initialise a new instance
/// </summary>
public Times(IEnumerable<IOutput> target, int count, string separator, string scope)
{
Target = target.ToList();
Expand All @@ -21,8 +42,15 @@ public Times(IEnumerable<IOutput> target, int count, string separator, string sc
Scope = scope ?? Iterator.DefaultScope;
}

/// <summary>
/// Debug information from parsing. From <see cref="Foobricator.Tools.IDebugInfoProvider"/>
/// </summary>
public DebugInfo DebugInfo { get; set; }

/// <summary>
/// Iterates <c>Count</c> times
/// </summary>
/// <param name="writer"></param>
public void Evaluate(TextWriter writer)
{
for (int i = 0; i < Count; i++)
Expand Down
43 changes: 43 additions & 0 deletions src/Foobricator/Output/When.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,80 @@

namespace Foobricator.Output
{
/// <summary>
/// Encapusulates a condition
/// </summary>
public class When : IDebugInfoProvider
{
/// <summary>
/// Logical condition operators
/// </summary>
/// <remarks>
/// Gt,Eq and Lt are combined as an OR, while NOT is combined as an AND.
/// i.e. NOT (EQ or GT or LT)
/// </remarks>
[Flags]
public enum Op
{
/// <summary>
/// Test equal
/// </summary>
Eq = 1<<1,
/// <summary>
/// Test greater than
/// </summary>
Gt = 1<<2,
/// <summary>
/// Test less than
/// </summary>
Lt = 1<<3,
/// <summary>
/// Logically not all other ops
/// </summary>
Not = 1<<4
}

/// <summary>
/// The target object to evaluate against
/// </summary>
public readonly ISource Source;

/// <summary>
/// The value to compare <c>Source</c> to
/// </summary>
public readonly object RightHandSide;

/// <summary>
/// Logical operator. Can be combination.
/// </summary>
public readonly Op Operator;

/// <summary>
/// Debug information from parsing. From <see cref="Foobricator.Tools.IDebugInfoProvider"/>
/// </summary>
public DebugInfo DebugInfo { get; set; }

/// <summary>
/// Initialise a new instance against a reference
/// </summary>
public When(DataReference reference, Op @operator, object rightHandSide)
:this(reference.Dereference() as ISource, @operator, rightHandSide)
{
}

/// <summary>
/// Initalise a new instance against a source
/// </summary>
public When(ISource source, Op @operator, object rightHandSide)
{
Source = source;
RightHandSide = rightHandSide;
Operator = @operator;
}

/// <summary>
/// Tests the conditions and returns the result
/// </summary>
public bool True()
{
object value = Source.GetItem();
Expand Down
Loading

0 comments on commit 19c8756

Please sign in to comment.