Skip to content

Commit

Permalink
Update XML doc for source generator related code
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinungf committed Feb 24, 2024
1 parent 5b39f72 commit aa85d89
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions SpreadCheetah/SourceGeneration/ColumnHeaderAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
namespace SpreadCheetah.SourceGeneration;

/// <summary>
/// Instructs the SpreadCheetah source generator about what header name to use for a column.
/// The source generator creates columns from properties, and using the attribute on a property will set the header name for the resulting column.
/// Header names are written to a worksheet with <see cref="Spreadsheet.AddHeaderRowAsync"/>.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public sealed class ColumnHeaderAttribute(string name) : Attribute;
12 changes: 7 additions & 5 deletions SpreadCheetah/SourceGeneration/ColumnOrderAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
namespace SpreadCheetah.SourceGeneration;

/// <summary>
/// Instructs the SpreadCheetah source generator to specify column ordering.
/// The order can be customized by using this attribute on a type's properties.
/// Instructs the SpreadCheetah source generator to specify the order between columns.
/// The source generator creates columns from properties, and using the attribute on a property will set the order for the resulting column.
/// <list type="bullet">
/// <item><description>The order will be in ascending order based on the <c>order</c> parameter. E.g. a property with <c>ColumnOrder(1)</c> will be in the column before the column for property with <c>ColumnOrder(2)</c>.</description></item>
/// <item><description>The order will be in ascending order based on the <c>order</c> parameter. E.g. the column from property with <c>ColumnOrder(1)</c> will be before
/// the column from property with <c>ColumnOrder(2)</c>.</description></item>
/// <item><description>The value for the <c>order</c> parameter can be any integer, including negative integers.</description></item>
/// <item><description>Two properties can not have the same value for the <c>order</c> parameter.</description></item>
/// <item><description>Properties that don't have the attribute will implicitly get the first non-duplicate value for <c>order</c> starting at 1.</description></item>
/// <item><description>Two different properties on a type can not have the same value for the <c>order</c> parameter.</description></item>
/// <item><description>The values used for a type's properties don't have to be consecutive.</description></item>
/// <item><description>Properties that don't have the attribute will implicitly get the first available value for <c>order</c> starting at 1.</description></item>
/// </list>
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
Expand Down
9 changes: 5 additions & 4 deletions SpreadCheetah/Spreadsheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,10 @@ public ValueTask AddRowAsync(IList<StyledCell> cells, RowOptions? options, Cance

/// <summary>
/// Add a row of header names in the active worksheet.
/// The header name in each cell will match the property name from the given type.
/// This functionality depends on the source generator, which will generate the <see cref="WorksheetRowTypeInfo{T}"/> type.
/// For properties of <typeparamref name="T"/>, the header name from the <see cref="ColumnHeaderAttribute"/> attribute will be used when set,
/// otherwise the property name will be used instead.
/// A style can optionally be applied to all the cells in the row.
/// The <see cref="WorksheetRowTypeInfo{T}"/> type must be generated by a source generator.
/// </summary>
public ValueTask AddHeaderRowAsync<T>(WorksheetRowTypeInfo<T> typeInfo, StyleId? styleId = null, CancellationToken token = default)
{
Expand All @@ -334,8 +335,8 @@ public ValueTask AddHeaderRowAsync<T>(WorksheetRowTypeInfo<T> typeInfo, StyleId?

/// <summary>
/// Add object as a row in the active worksheet.
/// This functionality depends on the source generator, which will generate the <see cref="WorksheetRowTypeInfo{T}"/> type.
/// Each property with a public getter on the object will be added as a cell in the row.
/// The <see cref="WorksheetRowTypeInfo{T}"/> type must be generated by a source generator.
/// </summary>
public ValueTask AddAsRowAsync<T>(T obj, WorksheetRowTypeInfo<T> typeInfo, CancellationToken token = default)
{
Expand All @@ -345,8 +346,8 @@ public ValueTask AddAsRowAsync<T>(T obj, WorksheetRowTypeInfo<T> typeInfo, Cance

/// <summary>
/// Add objects as rows in the active worksheet.
/// This functionality depends on the source generator, which will generate the <see cref="WorksheetRowTypeInfo{T}"/> type.
/// Each property with a public getter on the object will be added as a cell in the row.
/// The <see cref="WorksheetRowTypeInfo{T}"/> type must be generated by a source generator.
/// </summary>
public ValueTask AddRangeAsRowsAsync<T>(IEnumerable<T> objs, WorksheetRowTypeInfo<T> typeInfo, CancellationToken token = default)
{
Expand Down

0 comments on commit aa85d89

Please sign in to comment.