From c7e2e2eb202625b35c7a4b6c6341a2072acbbfbc Mon Sep 17 00:00:00 2001 From: joshua-light Date: Sun, 10 Dec 2023 13:54:00 +0200 Subject: [PATCH 1/4] Extend `DocProperty` model to include `DocPropertyAccessor` --- docs/DocEvent.md | 17 ++++ docs/DocProperty.md | 7 ++ docs/DocPropertyAccessor.md | 37 +++++++++ src/Core/AccessorKind.cs | 33 ++++++++ src/Core/DocEvent.cs | 15 ++++ src/Core/DocProperty.cs | 5 ++ src/Core/DocPropertyAccessor.cs | 34 ++++++++ .../Extensions/FieldSyntaxExtensions.cs | 2 +- .../Extensions/MethodSyntaxExtensions.cs | 4 +- .../Extensions/PropertySyntaxExtensions.cs | 77 +++++++++++++++---- .../CSharp/Extensions/SyntaxExtensions.cs | 6 +- .../TypeDeclarationSyntaxExtensions.cs | 4 +- 12 files changed, 219 insertions(+), 22 deletions(-) create mode 100644 docs/DocEvent.md create mode 100644 docs/DocPropertyAccessor.md create mode 100644 src/Core/AccessorKind.cs create mode 100644 src/Core/DocEvent.cs create mode 100644 src/Core/DocPropertyAccessor.cs diff --git a/docs/DocEvent.md b/docs/DocEvent.md new file mode 100644 index 0000000..3947730 --- /dev/null +++ b/docs/DocEvent.md @@ -0,0 +1,17 @@ +# Summary.DocEvent +```cs +public record DocEvent : DocMember +``` + +A [`DocMember`](./DocMember.md) that represents a documented event in the parsed source code. + +_Similar to [`DocProperty`](./DocProperty.md) but with its own set of accessors._ + +## Properties +### Type +```cs +public required DocType Type { get; init; } +``` + +The type of the event. + diff --git a/docs/DocProperty.md b/docs/DocProperty.md index 867e43c..6495ab0 100644 --- a/docs/DocProperty.md +++ b/docs/DocProperty.md @@ -13,6 +13,13 @@ public required DocType Type { get; init; } The type of the property. +### Accessors +```cs +public required DocPropertyAccessor[] Accessors { get; init; } +``` + +The accessors of the property (e.g., `get`, `set`, `init`). + ### Generated ```cs public required bool Generated { get; init; } diff --git a/docs/DocPropertyAccessor.md b/docs/DocPropertyAccessor.md new file mode 100644 index 0000000..8c0a99c --- /dev/null +++ b/docs/DocPropertyAccessor.md @@ -0,0 +1,37 @@ +# Summary.DocPropertyAccessor +```cs +public record DocPropertyAccessor +``` + +One of the [`DocProperty`](./DocProperty.md) accessors (e.g., `get`, `set`, `init`). + +## Fields +### Access +```cs +public AccessModifier Access +``` + +The access modifier of the accessor. + +### Kind +```cs +public AccessorKind Kind +``` + +The kind of the accessor. + +## Methods +### Defaults() +```cs +public static DocPropertyAccessor[] Defaults() +``` + +The sequence that consists only of a default `public get` property accessor. + +### Default() +```cs +public static DocPropertyAccessor Default() +``` + +The default `public get` property accessor. + diff --git a/src/Core/AccessorKind.cs b/src/Core/AccessorKind.cs new file mode 100644 index 0000000..ea2ccd6 --- /dev/null +++ b/src/Core/AccessorKind.cs @@ -0,0 +1,33 @@ +namespace Summary; + +/// +/// The kind of accessor. +/// +public enum AccessorKind +{ + /// + /// It's a get accessor. + /// + Get, + + /// + /// It's a set accessor. + /// + Set, + + /// + /// It's a init accessor. + /// + Init, + + /// + /// It's an event add accessor. + /// + Add, + + /// + /// It's an event remove accessor. + /// + Remove, +} + diff --git a/src/Core/DocEvent.cs b/src/Core/DocEvent.cs new file mode 100644 index 0000000..69102fa --- /dev/null +++ b/src/Core/DocEvent.cs @@ -0,0 +1,15 @@ +namespace Summary; + +/// +/// A that represents a documented event in the parsed source code. +/// +/// +/// Similar to but with its own set of accessors. +/// +public record DocEvent : DocMember +{ + /// + /// The type of the event. + /// + public required DocType Type { get; init; } +} \ No newline at end of file diff --git a/src/Core/DocProperty.cs b/src/Core/DocProperty.cs index e2898e6..6b1d403 100644 --- a/src/Core/DocProperty.cs +++ b/src/Core/DocProperty.cs @@ -10,6 +10,11 @@ public record DocProperty : DocMember /// public required DocType Type { get; init; } + /// + /// The accessors of the property (e.g., get, set, init). + /// + public required DocPropertyAccessor[] Accessors { get; init; } + /// /// Whether this property was generated by compiler (e.g., it's a property of a record). /// diff --git a/src/Core/DocPropertyAccessor.cs b/src/Core/DocPropertyAccessor.cs new file mode 100644 index 0000000..811c2a7 --- /dev/null +++ b/src/Core/DocPropertyAccessor.cs @@ -0,0 +1,34 @@ +namespace Summary; + +/// +/// One of the accessors (e.g., get, set, init). +/// +public record DocPropertyAccessor +{ + /// + /// The sequence that consists only of a default public get property accessor. + /// + public static DocPropertyAccessor[] Defaults() => new[] + { + Default(), + }; + + /// + /// The default public get property accessor. + /// + public static DocPropertyAccessor Default() => new DocPropertyAccessor + { + Kind = AccessorKind.Get, + Access = AccessModifier.Public, + }; + + /// + /// The access modifier of the accessor. + /// + public AccessModifier Access; + + /// + /// The kind of the accessor. + /// + public AccessorKind Kind; +} \ No newline at end of file diff --git a/src/Plugins/Roslyn/CSharp/Extensions/FieldSyntaxExtensions.cs b/src/Plugins/Roslyn/CSharp/Extensions/FieldSyntaxExtensions.cs index b64530d..1d8ba2e 100644 --- a/src/Plugins/Roslyn/CSharp/Extensions/FieldSyntaxExtensions.cs +++ b/src/Plugins/Roslyn/CSharp/Extensions/FieldSyntaxExtensions.cs @@ -28,7 +28,7 @@ private static DocField Field(this VariableDeclaratorSyntax self, FieldDeclarati Type = field.Declaration.Type.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{field.Attributes()}{field.Modifiers} {field.Declaration.Type} {self.Identifier}", + Declaration = $"{field.AttributesDeclaration()}{field.Modifiers} {field.Declaration.Type} {self.Identifier}", Access = field.Access(), Comment = field.Comment(), DeclaringType = self.DeclaringType(), diff --git a/src/Plugins/Roslyn/CSharp/Extensions/MethodSyntaxExtensions.cs b/src/Plugins/Roslyn/CSharp/Extensions/MethodSyntaxExtensions.cs index 30a200e..05771f5 100644 --- a/src/Plugins/Roslyn/CSharp/Extensions/MethodSyntaxExtensions.cs +++ b/src/Plugins/Roslyn/CSharp/Extensions/MethodSyntaxExtensions.cs @@ -16,7 +16,7 @@ public static DocMethod Method(this MethodDeclarationSyntax self) => FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, Declaration = - $"{self.Attributes()}{self.Modifiers} {self.ReturnType} {self.Identifier}{self.TypeParameterList}{self.ParameterList}", + $"{self.AttributesDeclaration()}{self.Modifiers} {self.ReturnType} {self.Identifier}{self.TypeParameterList}{self.ParameterList}", Access = self.Access(), Comment = self.Comment(), DeclaringType = self.DeclaringType(), @@ -34,7 +34,7 @@ public static DocMethod Method(this MethodDeclarationSyntax self) => FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, Declaration = - $"{self.Attributes()}{self.Modifiers} {self.ReturnType} {self.Identifier}{self.TypeParameterList}{self.ParameterList}", + $"{self.AttributesDeclaration()}{self.Modifiers} {self.ReturnType} {self.Identifier}{self.TypeParameterList}{self.ParameterList}", Access = self.Access(), Comment = self.Comment(), Params = self.ParameterList.Params(), diff --git a/src/Plugins/Roslyn/CSharp/Extensions/PropertySyntaxExtensions.cs b/src/Plugins/Roslyn/CSharp/Extensions/PropertySyntaxExtensions.cs index 588a94e..19e5bb2 100644 --- a/src/Plugins/Roslyn/CSharp/Extensions/PropertySyntaxExtensions.cs +++ b/src/Plugins/Roslyn/CSharp/Extensions/PropertySyntaxExtensions.cs @@ -1,4 +1,6 @@ -using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Summary.Extensions; namespace Summary.Roslyn.CSharp.Extensions; @@ -23,11 +25,12 @@ public static DocProperty Property(this PropertyDeclarationSyntax self) => Type = self.Type.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{self.Attributes()}{self.Modifiers} {self.Type} {self.Identifier} {self.Accessors()}", + Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} {self.Identifier} {self.AccessorsDeclaration()}", Access = self.Access(), Comment = self.Comment(), DeclaringType = self.DeclaringType(), Deprecation = self.AttributeLists.Deprecation(), + Accessors = self.Accessors(), Generated = false, Event = false, }; @@ -44,11 +47,12 @@ public static DocProperty Property(this ParameterSyntax self) => Type = self.Type!.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{self.AttributeLists.Attributes()}public {self.Type} {self.Identifier} {{ get; }}", + Declaration = $"{self.AttributeLists.AttributesDeclaration()}public {self.Type} {self.Identifier} {{ get; }}", Access = AccessModifier.Public, Comment = DocComment.Empty, DeclaringType = self.DeclaringType(), Deprecation = self.AttributeLists.Deprecation(), + Accessors = DocPropertyAccessor.Defaults(), Generated = true, Event = false, }; @@ -62,11 +66,12 @@ public static DocProperty Property(this EventDeclarationSyntax self) => Type = self.Type!.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{self.Attributes()}{self.Modifiers} {self.Type} {self.Identifier} {self.Accessors()}", + Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} {self.Identifier} {self.AccessorsDeclaration()}", Access = self.Access(), Comment = self.Comment(), DeclaringType = self.DeclaringType(), Deprecation = self.AttributeLists.Deprecation(), + Accessors = self.Accessors(), Generated = false, Event = true, }; @@ -89,14 +94,15 @@ public static DocIndexer Indexer(this IndexerDeclarationSyntax self) => Type = self.Type.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{self.Attributes()}{self.Modifiers} {self.Type} this{self.ParameterList} {self.Accessors()}", + Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} this{self.ParameterList} {self.AccessorsDeclaration()}", Access = self.Access(), Comment = self.Comment(), DeclaringType = self.DeclaringType(), Deprecation = self.AttributeLists.Deprecation(), + Accessors = self.Accessors(), + Params = self.ParameterList.Params(), Generated = false, Event = false, - Params = self.ParameterList.Params(), }; private static DocProperty Property(this VariableDeclaratorSyntax self, EventFieldDeclarationSyntax field) => @@ -105,24 +111,67 @@ private static DocProperty Property(this VariableDeclaratorSyntax self, EventFie Type = field.Declaration.Type.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{field.Attributes()}{field.Modifiers} event {field.Declaration.Type} {self.Identifier}", + Declaration = $"{field.AttributesDeclaration()}{field.Modifiers} event {field.Declaration.Type} {self.Identifier}", Access = field.Access(), Comment = field.Comment(), DeclaringType = self.DeclaringType(), Deprecation = field.AttributeLists.Deprecation(), + // TODO: Fix. + Accessors = Array.Empty(), Generated = false, Event = true, }; - private static string Accessors(this PropertyDeclarationSyntax self) => - self.AccessorList?.Accessors() ?? "{ get; }"; + private static DocPropertyAccessor[] Accessors(this PropertyDeclarationSyntax self) => + self.AccessorList?.Accessors.Select(x => x.Accessor(self)).ToArray() ?? DocPropertyAccessor.Defaults(); + + private static DocPropertyAccessor[] Accessors(this IndexerDeclarationSyntax self) => + self.AccessorList?.Accessors.Select(x => x.Accessor(self)).ToArray() ?? DocPropertyAccessor.Defaults(); + + private static DocPropertyAccessor[] Accessors(this EventDeclarationSyntax self) => + self.AccessorList?.Accessors.Select(x => x.Accessor(self)).ToArray() ?? DocPropertyAccessor.Defaults(); + + private static DocPropertyAccessor Accessor(this AccessorDeclarationSyntax self, MemberDeclarationSyntax parent) => + new() + { + Access = self.Access() ?? parent.Access(), + Kind = Kind(self), + }; + + private static AccessModifier? Access(this AccessorDeclarationSyntax self) + { + if (self.Modifiers.Any(SyntaxKind.PublicKeyword)) + return AccessModifier.Public; + if (self.Modifiers.Any(SyntaxKind.ProtectedKeyword)) + return AccessModifier.Protected; + if (self.Modifiers.Any(SyntaxKind.InternalKeyword)) + return AccessModifier.Internal; + if (self.Modifiers.Any(SyntaxKind.PrivateKeyword)) + return AccessModifier.Private; + + return null; + } + + private static AccessorKind Kind(this AccessorDeclarationSyntax self) => self.Keyword.Kind() switch + { + SyntaxKind.GetKeyword => AccessorKind.Get, + SyntaxKind.SetKeyword => AccessorKind.Set, + SyntaxKind.InitKeyword => AccessorKind.Init, + SyntaxKind.AddKeyword => AccessorKind.Add, + SyntaxKind.RemoveKeyword => AccessorKind.Remove, + + _ => throw new InvalidOperationException($"Unrecognized accessor: {self}"), + }; + + private static string AccessorsDeclaration(this PropertyDeclarationSyntax self) => + self.AccessorList?.AccessorsDeclaration() ?? "{ get; }"; - private static string Accessors(this IndexerDeclarationSyntax self) => - self.AccessorList?.Accessors() ?? "{ get; }"; + private static string AccessorsDeclaration(this IndexerDeclarationSyntax self) => + self.AccessorList?.AccessorsDeclaration() ?? "{ get; }"; - private static string Accessors(this EventDeclarationSyntax self) => - self.AccessorList?.Accessors() ?? "{ add; remove; }"; + private static string AccessorsDeclaration(this EventDeclarationSyntax self) => + self.AccessorList?.AccessorsDeclaration() ?? "{ add; remove; }"; - private static string Accessors(this AccessorListSyntax self) => + private static string AccessorsDeclaration(this AccessorListSyntax self) => $"{{ {self.Accessors.Select(x => $"{x.Modifiers.ToString().Space()}{x.Keyword}; ").Separated("")}}}"; } \ No newline at end of file diff --git a/src/Plugins/Roslyn/CSharp/Extensions/SyntaxExtensions.cs b/src/Plugins/Roslyn/CSharp/Extensions/SyntaxExtensions.cs index f2bbae0..0b39d22 100644 --- a/src/Plugins/Roslyn/CSharp/Extensions/SyntaxExtensions.cs +++ b/src/Plugins/Roslyn/CSharp/Extensions/SyntaxExtensions.cs @@ -137,13 +137,13 @@ static bool Error(AttributeSyntax attribute) /// /// A list of attributes of the specified member formatted as a string. /// - public static string Attributes(this MemberDeclarationSyntax self) => - self.AttributeLists.Attributes(); + public static string AttributesDeclaration(this MemberDeclarationSyntax self) => + self.AttributeLists.AttributesDeclaration(); /// /// Formats the specified list of attributes. /// - public static string Attributes(this SyntaxList self) => + public static string AttributesDeclaration(this SyntaxList self) => self .Select(x => $"{x}") .Separated(NewLine) is { } attributes and not "" diff --git a/src/Plugins/Roslyn/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs b/src/Plugins/Roslyn/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs index f79804e..1d1ec00 100644 --- a/src/Plugins/Roslyn/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs +++ b/src/Plugins/Roslyn/CSharp/Extensions/TypeDeclarationSyntaxExtensions.cs @@ -50,10 +50,10 @@ private static DocTypeParam[] TypeParams(this TypeDeclarationSyntax self) => private static string Declaration(this TypeDeclarationSyntax self) => self switch { RecordDeclarationSyntax record => - $"{self.Attributes()}{self.Modifiers} {record.Keyword()} {self.Identifier}{self.TypeParameterList}{record.ParameterList} {self.BaseList}" + $"{self.AttributesDeclaration()}{self.Modifiers} {record.Keyword()} {self.Identifier}{self.TypeParameterList}{record.ParameterList} {self.BaseList}" .TrimEnd(), _ => - $"{self.Attributes()}{self.Modifiers} {self.Keyword} {self.Identifier}{self.TypeParameterList} {self.BaseList}" + $"{self.AttributesDeclaration()}{self.Modifiers} {self.Keyword} {self.Identifier}{self.TypeParameterList} {self.BaseList}" .TrimEnd(), }; From 3cc7424a1baedc3fe7b2fbcfef7526b84f62bbcb Mon Sep 17 00:00:00 2001 From: joshua-light Date: Sun, 10 Dec 2023 15:02:40 +0200 Subject: [PATCH 2/4] Implement filtering based on access modifier of property accessors --- docs/DocProperty.md | 7 ++ docs/DocPropertyAccessor.md | 3 +- docs/FilterMemberPipe.md | 3 +- docs/FilteringExtensions.md | 61 ++++++++++++++++ docs/Sample{T0,T1}.md | 6 +- docs/SummaryPipelineExtensions.md | 46 ------------ src/Core/AccessorKind.cs | 10 --- src/Core/DocProperty.cs | 16 ++++- src/Core/DocPropertyAccessor.cs | 3 +- .../Pipelines/SummaryPipelineExtensions.cs | 46 ------------ .../SummaryPipelineFilteringExtensions.cs | 72 +++++++++++++++++++ src/Core/Pipes/Filters/FilterMemberPipe.cs | 12 +++- src/Plugins/Markdown/MdRenderer.cs | 8 ++- .../Extensions/PropertySyntaxExtensions.cs | 18 ++--- 14 files changed, 187 insertions(+), 124 deletions(-) create mode 100644 docs/FilteringExtensions.md create mode 100644 src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs diff --git a/docs/DocProperty.md b/docs/DocProperty.md index 6495ab0..8866f27 100644 --- a/docs/DocProperty.md +++ b/docs/DocProperty.md @@ -34,3 +34,10 @@ public required bool Event { get; init; } Whether this property represents an event. +### AccessorsDeclaration +```cs +public string AccessorsDeclaration { get; } +``` + +The declaration of property accessors as they declared in the C# source code. + diff --git a/docs/DocPropertyAccessor.md b/docs/DocPropertyAccessor.md index 8c0a99c..0eda9ff 100644 --- a/docs/DocPropertyAccessor.md +++ b/docs/DocPropertyAccessor.md @@ -8,10 +8,11 @@ One of the [`DocProperty`](./DocProperty.md) accessors (e.g., `get`, `set`, `ini ## Fields ### Access ```cs -public AccessModifier Access +public AccessModifier? Access ``` The access modifier of the accessor. +If the value is `null`, then the access modifier is inherited from the property declaration. ### Kind ```cs diff --git a/docs/FilterMemberPipe.md b/docs/FilterMemberPipe.md index e1f3612..d278267 100644 --- a/docs/FilterMemberPipe.md +++ b/docs/FilterMemberPipe.md @@ -3,7 +3,8 @@ public class FilterMemberPipe : IPipe ``` -A simple pipe that filters all members inside the document using the specified predicate. +A simple pipe that filters all members inside the document using the specified predicate +and then applies the given map function on them. ## Methods ### Run(Doc) diff --git a/docs/FilteringExtensions.md b/docs/FilteringExtensions.md new file mode 100644 index 0000000..5f845dc --- /dev/null +++ b/docs/FilteringExtensions.md @@ -0,0 +1,61 @@ +# Summary.Pipelines.FilteringExtensions +```cs +public static class FilteringExtensions +``` + +A set of extensions for [`SummaryPipeline`](./SummaryPipeline.md) that add support for filtering functionality. + +## Methods +### UseDefaultFilters(SummaryPipeline) +```cs +public static SummaryPipeline UseDefaultFilters(this SummaryPipeline self) +``` + +Enables default filters for the given pipeline (i.e. a filter that removes all non-public members). + +### IncludeAtLeast(SummaryPipeline, AccessModifier) +```cs +public static SummaryPipeline IncludeAtLeast(this SummaryPipeline self, AccessModifier access) +``` + +Includes only members that have at least the given access modifier. + +#### Example +In order to include both `internal` and `public` members in the generated docs, +you can call this method as follows: +```cs +var pipeline = ...; + +pipeline.IncludeAtLeast(AccessModifier.Internal); +``` + +### IncludeOnly(SummaryPipeline, AccessModifier) +```cs +public static SummaryPipeline IncludeOnly(this SummaryPipeline self, AccessModifier access) +``` + +Includes only members that have at least the given access modifier. + +#### Example +In order to include onl `internal` members in the generated docs, +you can call this method as follows: +```cs +var pipeline = ...; + +pipeline.IncludeOnly(AccessModifier.Internal); +``` + +### WithAccess(SummaryPipeline, Func) +```cs +public static SummaryPipeline WithAccess(this SummaryPipeline self, Func p) +``` + +Includes only members that have the access modifier that satisfies the given predicate. + +### UseFilter(SummaryPipeline, IPipe) +```cs +public static SummaryPipeline UseFilter(this SummaryPipeline self, IPipe filter) +``` + +Adds the given filter into the pipeline. + diff --git a/docs/Sample{T0,T1}.md b/docs/Sample{T0,T1}.md index 40f253c..2891a67 100644 --- a/docs/Sample{T0,T1}.md +++ b/docs/Sample{T0,T1}.md @@ -39,7 +39,7 @@ A sample field event. ### Event2 ```cs -public Action Event2 { add; remove; } +public Action Event2 ``` A sample property event. @@ -87,14 +87,14 @@ A sample property. ### Property2 ```cs -public int Property2 { private get; set; } +public int Property2 { set; } ``` A sample property with custom visibility. ### Property3 ```cs -public int Property3 { get; protected set; } +public int Property3 { get; } ``` A sample property with custom visibility (2). diff --git a/docs/SummaryPipelineExtensions.md b/docs/SummaryPipelineExtensions.md index 5021214..d2fe903 100644 --- a/docs/SummaryPipelineExtensions.md +++ b/docs/SummaryPipelineExtensions.md @@ -16,49 +16,3 @@ Specifies the logger factory to use for pipes inside the pipeline. _This method should be called _before_ anything else so that_ _given logger factory is passed into all subsequent calls._ -### UseDefaultFilters(SummaryPipeline) -```cs -public static SummaryPipeline UseDefaultFilters(this SummaryPipeline self) -``` - -Enables default filters for the given pipeline (i.e. a filter that removes all non-public members). - -### IncludeAtLeast(SummaryPipeline, AccessModifier) -```cs -public static SummaryPipeline IncludeAtLeast(this SummaryPipeline self, AccessModifier access) -``` - -Includes only members that have at least the given access modifier. - -#### Example -In order to include both `internal` and `public` members in the generated docs, -you can call this method as follows: -```cs -var pipeline = ...; - -pipeline.IncludeAtLeast(AccessModifier.Internal); -``` - -### IncludeOnly(SummaryPipeline, AccessModifier) -```cs -public static SummaryPipeline IncludeOnly(this SummaryPipeline self, AccessModifier access) -``` - -Includes only members that have at least the given access modifier. - -#### Example -In order to include onl `internal` members in the generated docs, -you can call this method as follows: -```cs -var pipeline = ...; - -pipeline.IncludeOnly(AccessModifier.Internal); -``` - -### UseFilter(SummaryPipeline, IPipe) -```cs -public static SummaryPipeline UseFilter(this SummaryPipeline self, IPipe filter) -``` - -Adds the given filter into the pipeline. - diff --git a/src/Core/AccessorKind.cs b/src/Core/AccessorKind.cs index ea2ccd6..16c0107 100644 --- a/src/Core/AccessorKind.cs +++ b/src/Core/AccessorKind.cs @@ -19,15 +19,5 @@ public enum AccessorKind /// It's a init accessor. /// Init, - - /// - /// It's an event add accessor. - /// - Add, - - /// - /// It's an event remove accessor. - /// - Remove, } diff --git a/src/Core/DocProperty.cs b/src/Core/DocProperty.cs index 6b1d403..fe23a19 100644 --- a/src/Core/DocProperty.cs +++ b/src/Core/DocProperty.cs @@ -1,4 +1,6 @@ -namespace Summary; +using Summary.Extensions; + +namespace Summary; /// /// A that represents a documented property in the parsed source code. @@ -20,8 +22,20 @@ public record DocProperty : DocMember /// public required bool Generated { get; init; } + // TODO: Consider having a separate `DocEvent` type since events are more specialized properties (@j.light). /// /// Whether this property represents an event. /// public required bool Event { get; init; } + + /// + /// The declaration of property accessors as they declared in the C# source code. + /// + public string AccessorsDeclaration => Accessors + .Select(x => $"{AccessDeclaration(x).ToLower().Space() ?? ""}{x.Kind.ToString().ToLower()};") + .Separated(with: " ") + .Surround("{ ", " }"); + + private string AccessDeclaration(DocPropertyAccessor x) => + x.Access is null || x.Access == Access ? "" : x.Access.Value.ToString(); } \ No newline at end of file diff --git a/src/Core/DocPropertyAccessor.cs b/src/Core/DocPropertyAccessor.cs index 811c2a7..dc7ca65 100644 --- a/src/Core/DocPropertyAccessor.cs +++ b/src/Core/DocPropertyAccessor.cs @@ -24,8 +24,9 @@ public static DocPropertyAccessor[] Defaults() => new[] /// /// The access modifier of the accessor. + /// If the value is null, then the access modifier is inherited from the property declaration. /// - public AccessModifier Access; + public AccessModifier? Access; /// /// The kind of the accessor. diff --git a/src/Core/Pipelines/SummaryPipelineExtensions.cs b/src/Core/Pipelines/SummaryPipelineExtensions.cs index 25c34f6..7666090 100644 --- a/src/Core/Pipelines/SummaryPipelineExtensions.cs +++ b/src/Core/Pipelines/SummaryPipelineExtensions.cs @@ -18,50 +18,4 @@ public static class SummaryPipelineExtensions /// public static SummaryPipeline UseLoggerFactory(this SummaryPipeline self, ILoggerFactory factory) => self.Customize(options => options.UseLoggerFactory(factory)); - - /// - /// Enables default filters for the given pipeline (i.e. a filter that removes all non-public members). - /// - public static SummaryPipeline UseDefaultFilters(this SummaryPipeline self) => self - .IncludeOnly(AccessModifier.Public); - - /// - /// Includes only members that have at least the given access modifier. - /// - /// - /// In order to include both internal and public members in the generated docs, - /// you can call this method as follows: - /// - /// var pipeline = ...; - /// - /// pipeline.IncludeAtLeast(AccessModifier.Internal); - /// - /// - public static SummaryPipeline IncludeAtLeast(this SummaryPipeline self, AccessModifier access) => self - .UseFilter(new FilterMemberPipe(x => x.Access >= access)); - - /// - /// Includes only members that have at least the given access modifier. - /// - /// - /// In order to include onl internal members in the generated docs, - /// you can call this method as follows: - /// - /// var pipeline = ...; - /// - /// pipeline.IncludeOnly(AccessModifier.Internal); - /// - /// - public static SummaryPipeline IncludeOnly(this SummaryPipeline self, AccessModifier access) => self - .UseFilter(new FilterMemberPipe(x => x.Access == access)); - - /// - /// Adds the given filter into the pipeline. - /// - /// - public static SummaryPipeline UseFilter(this SummaryPipeline self, IPipe filter) - { - self.Filters.Add(filter); - return self; - } } \ No newline at end of file diff --git a/src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs b/src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs new file mode 100644 index 0000000..35b4b94 --- /dev/null +++ b/src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs @@ -0,0 +1,72 @@ +using Summary.Pipes; +using Summary.Pipes.Filters; + +namespace Summary.Pipelines; + +/// +/// A set of extensions for that add support for filtering functionality. +/// +public static class FilteringExtensions +{ + /// + /// Enables default filters for the given pipeline (i.e. a filter that removes all non-public members). + /// + public static SummaryPipeline UseDefaultFilters(this SummaryPipeline self) => self + .IncludeOnly(AccessModifier.Public); + + /// + /// Includes only members that have at least the given access modifier. + /// + /// + /// In order to include both internal and public members in the generated docs, + /// you can call this method as follows: + /// + /// var pipeline = ...; + /// + /// pipeline.IncludeAtLeast(AccessModifier.Internal); + /// + /// + public static SummaryPipeline IncludeAtLeast(this SummaryPipeline self, AccessModifier access) => self + .WithAccess(x => x >= access); + + /// + /// Includes only members that have at least the given access modifier. + /// + /// + /// In order to include onl internal members in the generated docs, + /// you can call this method as follows: + /// + /// var pipeline = ...; + /// + /// pipeline.IncludeOnly(AccessModifier.Internal); + /// + /// + public static SummaryPipeline IncludeOnly(this SummaryPipeline self, AccessModifier access) => self + .WithAccess(x => x == access); + + /// + /// Includes only members that have the access modifier that satisfies the given predicate. + /// + public static SummaryPipeline WithAccess(this SummaryPipeline self, Func p) => self + .UseFilter(new FilterMemberPipe(x => p(x.Access), x => x.WithAccess(p))); + + private static DocMember WithAccess(this DocMember member, Func p) => member switch + { + DocProperty property => property with + { + Accessors = property.Accessors.Where(x => x.Access is not null && p(x.Access.Value)).ToArray(), + }, + + _ => member, + }; + + /// + /// Adds the given filter into the pipeline. + /// + /// + public static SummaryPipeline UseFilter(this SummaryPipeline self, IPipe filter) + { + self.Filters.Add(filter); + return self; + } +} \ No newline at end of file diff --git a/src/Core/Pipes/Filters/FilterMemberPipe.cs b/src/Core/Pipes/Filters/FilterMemberPipe.cs index 3611571..b1f78ed 100644 --- a/src/Core/Pipes/Filters/FilterMemberPipe.cs +++ b/src/Core/Pipes/Filters/FilterMemberPipe.cs @@ -1,17 +1,23 @@ +using Summary.Samples; + namespace Summary.Pipes.Filters; /// -/// A simple pipe that filters all members inside the document using the specified predicate. +/// A simple pipe that filters all members inside the document using the specified predicate +/// and then applies the given map function on them. /// -public class FilterMemberPipe(Predicate p) : IPipe +public class FilterMemberPipe(Func predicate, Func? map = null) : IPipe { + private readonly Func _map = map ?? (static x => x); + public Task Run(Doc input) => Task.FromResult(new Doc(Filtered(input.Members))); private DocMember[] Filtered(DocMember[] members) => members - .Where(x => p(x)) + .Where(predicate) .Select(Filtered) + .Select(_map) .ToArray(); private DocMember Filtered(DocMember member) => member switch diff --git a/src/Plugins/Markdown/MdRenderer.cs b/src/Plugins/Markdown/MdRenderer.cs index c6da41c..996d2f5 100644 --- a/src/Plugins/Markdown/MdRenderer.cs +++ b/src/Plugins/Markdown/MdRenderer.cs @@ -48,6 +48,7 @@ public string Text() => DocTypeDeclaration type => TypeDeclaration(type), DocMethod method => Method(method), DocProperty property => Property(parent!, property), + _ => Header(member), }; @@ -128,7 +129,12 @@ private MdRenderer Deprecation(DocDeprecation? deprecation) private MdRenderer Declaration(DocMember member) => this .Line("```cs") - .Line(member.Declaration) + .Line(member switch + { + DocProperty property => $"{property.Declaration}{property.AccessorsDeclaration.Surround(" ", "")}", + + _ => member.Declaration, + }) .Line("```") .Line(); diff --git a/src/Plugins/Roslyn/CSharp/Extensions/PropertySyntaxExtensions.cs b/src/Plugins/Roslyn/CSharp/Extensions/PropertySyntaxExtensions.cs index 19e5bb2..5859bf6 100644 --- a/src/Plugins/Roslyn/CSharp/Extensions/PropertySyntaxExtensions.cs +++ b/src/Plugins/Roslyn/CSharp/Extensions/PropertySyntaxExtensions.cs @@ -25,7 +25,7 @@ public static DocProperty Property(this PropertyDeclarationSyntax self) => Type = self.Type.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} {self.Identifier} {self.AccessorsDeclaration()}", + Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} {self.Identifier}", Access = self.Access(), Comment = self.Comment(), DeclaringType = self.DeclaringType(), @@ -47,7 +47,7 @@ public static DocProperty Property(this ParameterSyntax self) => Type = self.Type!.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{self.AttributeLists.AttributesDeclaration()}public {self.Type} {self.Identifier} {{ get; }}", + Declaration = $"{self.AttributeLists.AttributesDeclaration()}public {self.Type} {self.Identifier}", Access = AccessModifier.Public, Comment = DocComment.Empty, DeclaringType = self.DeclaringType(), @@ -66,12 +66,13 @@ public static DocProperty Property(this EventDeclarationSyntax self) => Type = self.Type!.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} {self.Identifier} {self.AccessorsDeclaration()}", + Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} {self.Identifier}", Access = self.Access(), Comment = self.Comment(), DeclaringType = self.DeclaringType(), Deprecation = self.AttributeLists.Deprecation(), - Accessors = self.Accessors(), + // All events have `add` and `remove` accessors by default. + Accessors = Array.Empty(), Generated = false, Event = true, }; @@ -94,7 +95,7 @@ public static DocIndexer Indexer(this IndexerDeclarationSyntax self) => Type = self.Type.Type(), FullyQualifiedName = self.FullyQualifiedName(), Name = self.Name()!, - Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} this{self.ParameterList} {self.AccessorsDeclaration()}", + Declaration = $"{self.AttributesDeclaration()}{self.Modifiers} {self.Type} this{self.ParameterList}", Access = self.Access(), Comment = self.Comment(), DeclaringType = self.DeclaringType(), @@ -116,7 +117,7 @@ private static DocProperty Property(this VariableDeclaratorSyntax self, EventFie Comment = field.Comment(), DeclaringType = self.DeclaringType(), Deprecation = field.AttributeLists.Deprecation(), - // TODO: Fix. + // All events have `add` and `remove` accessors by default. Accessors = Array.Empty(), Generated = false, Event = true, @@ -128,9 +129,6 @@ private static DocPropertyAccessor[] Accessors(this PropertyDeclarationSyntax se private static DocPropertyAccessor[] Accessors(this IndexerDeclarationSyntax self) => self.AccessorList?.Accessors.Select(x => x.Accessor(self)).ToArray() ?? DocPropertyAccessor.Defaults(); - private static DocPropertyAccessor[] Accessors(this EventDeclarationSyntax self) => - self.AccessorList?.Accessors.Select(x => x.Accessor(self)).ToArray() ?? DocPropertyAccessor.Defaults(); - private static DocPropertyAccessor Accessor(this AccessorDeclarationSyntax self, MemberDeclarationSyntax parent) => new() { @@ -157,8 +155,6 @@ private static DocPropertyAccessor Accessor(this AccessorDeclarationSyntax self, SyntaxKind.GetKeyword => AccessorKind.Get, SyntaxKind.SetKeyword => AccessorKind.Set, SyntaxKind.InitKeyword => AccessorKind.Init, - SyntaxKind.AddKeyword => AccessorKind.Add, - SyntaxKind.RemoveKeyword => AccessorKind.Remove, _ => throw new InvalidOperationException($"Unrecognized accessor: {self}"), }; From a330316396a3ad0d805ab650b50bc9fcba27b6c2 Mon Sep 17 00:00:00 2001 From: joshua-light Date: Sun, 10 Dec 2023 15:04:56 +0200 Subject: [PATCH 3/4] Docs --- src/Core/AccessorKind.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Core/AccessorKind.cs b/src/Core/AccessorKind.cs index 16c0107..69114f0 100644 --- a/src/Core/AccessorKind.cs +++ b/src/Core/AccessorKind.cs @@ -3,6 +3,10 @@ namespace Summary; /// /// The kind of accessor. /// +/// +/// We intentionally omit event accessors like add or remove since +/// each event has both, and the modifiers are not supported by event accessors. +/// public enum AccessorKind { /// From 7d4078237ac18060b961a1de0f3c0ced46855df8 Mon Sep 17 00:00:00 2001 From: joshua-light Date: Mon, 11 Dec 2023 01:20:40 +0200 Subject: [PATCH 4/4] Update docs --- docs/DocEvent.md | 4 +-- docs/DocProperty.md | 22 ++++++++++++--- docs/DocPropertyAccessor.md | 10 +++---- docs/FilterMemberPipe.md | 4 +-- docs/FilteringExtensions.md | 12 ++++---- docs/GlobalDelegate.md | 2 +- docs/Sample{T0,T1}.Child.md | 4 +-- docs/Sample{T0,T1}.md | 30 ++++++++++---------- docs/SummaryPipelineExtensions.md | 46 ------------------------------- 9 files changed, 51 insertions(+), 83 deletions(-) diff --git a/docs/DocEvent.md b/docs/DocEvent.md index 3947730..bf9218c 100644 --- a/docs/DocEvent.md +++ b/docs/DocEvent.md @@ -1,4 +1,4 @@ -# Summary.DocEvent +# [Summary.DocEvent](../src/Core/DocEvent.cs#L9) ```cs public record DocEvent : DocMember ``` @@ -8,7 +8,7 @@ A [`DocMember`](./DocMember.md) that represents a documented event in the parsed _Similar to [`DocProperty`](./DocProperty.md) but with its own set of accessors._ ## Properties -### Type +### [Type](../src/Core/DocEvent.cs#L14) ```cs public required DocType Type { get; init; } ``` diff --git a/docs/DocProperty.md b/docs/DocProperty.md index 906a50d..549843c 100644 --- a/docs/DocProperty.md +++ b/docs/DocProperty.md @@ -1,4 +1,4 @@ -# [Summary.DocProperty](../src/Core/DocProperty.cs#L6) +# [Summary.DocProperty](../src/Core/DocProperty.cs#L8) ```cs public record DocProperty : DocMember ``` @@ -6,24 +6,38 @@ public record DocProperty : DocMember A [`DocMember`](./DocMember.md) that represents a documented property in the parsed source code. ## Properties -### [Type](../src/Core/DocProperty.cs#L11) +### [Type](../src/Core/DocProperty.cs#L13) ```cs public required DocType Type { get; init; } ``` The type of the property. -### [Generated](../src/Core/DocProperty.cs#L16) +### [Accessors](../src/Core/DocProperty.cs#L18) +```cs +public required DocPropertyAccessor[] Accessors { get; init; } +``` + +The accessors of the property (e.g., `get`, `set`, `init`). + +### [Generated](../src/Core/DocProperty.cs#L23) ```cs public required bool Generated { get; init; } ``` Whether this property was generated by compiler (e.g., it's a property of a record). -### [Event](../src/Core/DocProperty.cs#L21) +### [Event](../src/Core/DocProperty.cs#L29) ```cs public required bool Event { get; init; } ``` Whether this property represents an event. +### [AccessorsDeclaration](../src/Core/DocProperty.cs#L34) +```cs +public string AccessorsDeclaration { get; } +``` + +The declaration of property accessors as they declared in the C# source code. + diff --git a/docs/DocPropertyAccessor.md b/docs/DocPropertyAccessor.md index 0eda9ff..08fb626 100644 --- a/docs/DocPropertyAccessor.md +++ b/docs/DocPropertyAccessor.md @@ -1,4 +1,4 @@ -# Summary.DocPropertyAccessor +# [Summary.DocPropertyAccessor](../src/Core/DocPropertyAccessor.cs#L6) ```cs public record DocPropertyAccessor ``` @@ -6,7 +6,7 @@ public record DocPropertyAccessor One of the [`DocProperty`](./DocProperty.md) accessors (e.g., `get`, `set`, `init`). ## Fields -### Access +### [Access](../src/Core/DocPropertyAccessor.cs#L29) ```cs public AccessModifier? Access ``` @@ -14,7 +14,7 @@ public AccessModifier? Access The access modifier of the accessor. If the value is `null`, then the access modifier is inherited from the property declaration. -### Kind +### [Kind](../src/Core/DocPropertyAccessor.cs#L34) ```cs public AccessorKind Kind ``` @@ -22,14 +22,14 @@ public AccessorKind Kind The kind of the accessor. ## Methods -### Defaults() +### [Defaults()](../src/Core/DocPropertyAccessor.cs#L11) ```cs public static DocPropertyAccessor[] Defaults() ``` The sequence that consists only of a default `public get` property accessor. -### Default() +### [Default()](../src/Core/DocPropertyAccessor.cs#L19) ```cs public static DocPropertyAccessor Default() ``` diff --git a/docs/FilterMemberPipe.md b/docs/FilterMemberPipe.md index f0348af..3bc27df 100644 --- a/docs/FilterMemberPipe.md +++ b/docs/FilterMemberPipe.md @@ -1,4 +1,4 @@ -# [Summary.Pipes.Filters.FilterMemberPipe](../src/Core/Pipes/Filters/FilterMemberPipe.cs#L6) +# [Summary.Pipes.Filters.FilterMemberPipe](../src/Core/Pipes/Filters/FilterMemberPipe.cs#L7) ```cs public class FilterMemberPipe : IPipe ``` @@ -7,7 +7,7 @@ A simple pipe that filters all members inside the document using the specified p and then applies the given map function on them. ## Methods -### [Run(Doc)](../src/Core/Pipes/Filters/FilterMemberPipe.cs#L9) +### [Run(Doc)](../src/Core/Pipes/Filters/FilterMemberPipe.cs#L12) ```cs public Task Run(Doc input) ``` diff --git a/docs/FilteringExtensions.md b/docs/FilteringExtensions.md index 5f845dc..44f7aff 100644 --- a/docs/FilteringExtensions.md +++ b/docs/FilteringExtensions.md @@ -1,4 +1,4 @@ -# Summary.Pipelines.FilteringExtensions +# [Summary.Pipelines.FilteringExtensions](../src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs#L9) ```cs public static class FilteringExtensions ``` @@ -6,14 +6,14 @@ public static class FilteringExtensions A set of extensions for [`SummaryPipeline`](./SummaryPipeline.md) that add support for filtering functionality. ## Methods -### UseDefaultFilters(SummaryPipeline) +### [UseDefaultFilters(SummaryPipeline)](../src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs#L14) ```cs public static SummaryPipeline UseDefaultFilters(this SummaryPipeline self) ``` Enables default filters for the given pipeline (i.e. a filter that removes all non-public members). -### IncludeAtLeast(SummaryPipeline, AccessModifier) +### [IncludeAtLeast(SummaryPipeline, AccessModifier)](../src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs#L29) ```cs public static SummaryPipeline IncludeAtLeast(this SummaryPipeline self, AccessModifier access) ``` @@ -29,7 +29,7 @@ var pipeline = ...; pipeline.IncludeAtLeast(AccessModifier.Internal); ``` -### IncludeOnly(SummaryPipeline, AccessModifier) +### [IncludeOnly(SummaryPipeline, AccessModifier)](../src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs#L44) ```cs public static SummaryPipeline IncludeOnly(this SummaryPipeline self, AccessModifier access) ``` @@ -45,14 +45,14 @@ var pipeline = ...; pipeline.IncludeOnly(AccessModifier.Internal); ``` -### WithAccess(SummaryPipeline, Func) +### [WithAccess(SummaryPipeline, Func)](../src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs#L50) ```cs public static SummaryPipeline WithAccess(this SummaryPipeline self, Func p) ``` Includes only members that have the access modifier that satisfies the given predicate. -### UseFilter(SummaryPipeline, IPipe) +### [UseFilter(SummaryPipeline, IPipe)](../src/Core/Pipelines/SummaryPipelineFilteringExtensions.cs#L67) ```cs public static SummaryPipeline UseFilter(this SummaryPipeline self, IPipe filter) ``` diff --git a/docs/GlobalDelegate.md b/docs/GlobalDelegate.md index 6db43ba..fab48f5 100644 --- a/docs/GlobalDelegate.md +++ b/docs/GlobalDelegate.md @@ -1,4 +1,4 @@ -# [GlobalDelegate(int, int)](../src/Core/Samples/Sample.cs#L6) +# [GlobalDelegate(int, int)](../src/Core/Samples/Sample.cs#L15) ```cs public void GlobalDelegate(int x, int y) ``` diff --git a/docs/Sample{T0,T1}.Child.md b/docs/Sample{T0,T1}.Child.md index 57bf81e..7d55859 100644 --- a/docs/Sample{T0,T1}.Child.md +++ b/docs/Sample{T0,T1}.Child.md @@ -1,4 +1,4 @@ -# [~~Summary.Samples.Sample.Child~~](../src/Core/Samples/Sample.cs#L33) +# [~~Summary.Samples.Sample.Child~~](../src/Core/Samples/Sample.cs#L42) > [!WARNING] > The type is deprecated. @@ -10,7 +10,7 @@ public class Child A child of the [`Sample{T0,T1}`](./Sample{T0,T1}.md) class. ## Fields -### [Field](../src/Core/Samples/Sample.cs#L38) +### [Field](../src/Core/Samples/Sample.cs#L47) ```cs public int Field ``` diff --git a/docs/Sample{T0,T1}.md b/docs/Sample{T0,T1}.md index c5ec383..54570d2 100644 --- a/docs/Sample{T0,T1}.md +++ b/docs/Sample{T0,T1}.md @@ -1,4 +1,4 @@ -# [Summary.Samples.Sample](../src/Core/Samples/Sample.cs#L26) +# [Summary.Samples.Sample](../src/Core/Samples/Sample.cs#L35) ```cs public class Sample ``` @@ -22,7 +22,7 @@ _Btw, this type has a child: [`Sample{T0,T1}.Child`](./Sample{T0,T1}.Child.md)._ - `T1`: A second type parameter. ## Delegates -### [Delegate1(int, int)](../src/Core/Samples/Sample.cs#L44) +### [Delegate1(int, int)](../src/Core/Samples/Sample.cs#L53) ```cs public void Delegate1(int x, int y) ``` @@ -30,14 +30,14 @@ public void Delegate1(int x, int y) A sample delegate. ## Events -### [Event1](../src/Core/Samples/Sample.cs#L92) +### [Event1](../src/Core/Samples/Sample.cs#L101) ```cs public event Action Event1 ``` A sample field event. -### [Event2](../src/Core/Samples/Sample.cs#L97) +### [Event2](../src/Core/Samples/Sample.cs#L106) ```cs public Action Event2 ``` @@ -45,14 +45,14 @@ public Action Event2 A sample property event. ## Fields -### [Field](../src/Core/Samples/Sample.cs#L38) +### [Field](../src/Core/Samples/Sample.cs#L47) ```cs public int Field ``` A field of the child class. -### [~~Field1~~](../src/Core/Samples/Sample.cs#L50) +### [~~Field1~~](../src/Core/Samples/Sample.cs#L59) > [!WARNING] > The field is deprecated. @@ -63,14 +63,14 @@ public int Field1 A sample field. -### [Field2](../src/Core/Samples/Sample.cs#L55) +### [Field2](../src/Core/Samples/Sample.cs#L64) ```cs public int Field2 ``` A pair of fields. -### [Field3](../src/Core/Samples/Sample.cs#L55) +### [Field3](../src/Core/Samples/Sample.cs#L64) ```cs public int Field3 ``` @@ -78,21 +78,21 @@ public int Field3 A pair of fields. ## Properties -### [Property1](../src/Core/Samples/Sample.cs#L60) +### [Property1](../src/Core/Samples/Sample.cs#L69) ```cs public int Property1 { get; set; } ``` A sample property. -### [Property2](../src/Core/Samples/Sample.cs#L65) +### [Property2](../src/Core/Samples/Sample.cs#L74) ```cs public int Property2 { set; } ``` A sample property with custom visibility. -### [Property3](../src/Core/Samples/Sample.cs#L71) +### [Property3](../src/Core/Samples/Sample.cs#L80) ```cs public int Property3 { get; } ``` @@ -102,7 +102,7 @@ A sample property with custom visibility and an exception. #### Exceptions - `ArithmeticException`: Invalid number. -### [Property4](../src/Core/Samples/Sample.cs#L76) +### [Property4](../src/Core/Samples/Sample.cs#L85) ```cs public int Property4 { get; set; } ``` @@ -110,7 +110,7 @@ public int Property4 { get; set; } A sample property with custom accessors. ## Indexers -### [this[int]](../src/Core/Samples/Sample.cs#L87) +### [this[int]](../src/Core/Samples/Sample.cs#L96) ```cs public int this[int i] { get; } ``` @@ -124,7 +124,7 @@ A sample indexer. What indexer returns. ## Methods -### [Method(int, string)](../src/Core/Samples/Sample.cs#L121) +### [Method(int, string)](../src/Core/Samples/Sample.cs#L130) ```cs public TimeSpan Method(int x, string y) ``` @@ -154,7 +154,7 @@ The `TimeSpan` instance. - `ArgumentException`: The argument is incorrect. - `ApplicationException`: Something went wrong. -### [Method(short, string)](../src/Core/Samples/Sample.cs#L128) +### [Method(short, string)](../src/Core/Samples/Sample.cs#L137) ```cs public TimeSpan Method(short x, string y) ``` diff --git a/docs/SummaryPipelineExtensions.md b/docs/SummaryPipelineExtensions.md index c09ae03..61305e5 100644 --- a/docs/SummaryPipelineExtensions.md +++ b/docs/SummaryPipelineExtensions.md @@ -16,49 +16,3 @@ Specifies the logger factory to use for pipes inside the pipeline. _This method should be called _before_ anything else so that_ _given logger factory is passed into all subsequent calls._ -### [UseDefaultFilters(SummaryPipeline)](../src/Core/Pipelines/SummaryPipelineExtensions.cs#L25) -```cs -public static SummaryPipeline UseDefaultFilters(this SummaryPipeline self) -``` - -Enables default filters for the given pipeline (i.e. a filter that removes all non-public members). - -### [IncludeAtLeast(SummaryPipeline, AccessModifier)](../src/Core/Pipelines/SummaryPipelineExtensions.cs#L40) -```cs -public static SummaryPipeline IncludeAtLeast(this SummaryPipeline self, AccessModifier access) -``` - -Includes only members that have at least the given access modifier. - -#### Example -In order to include both `internal` and `public` members in the generated docs, -you can call this method as follows: -```cs -var pipeline = ...; - -pipeline.IncludeAtLeast(AccessModifier.Internal); -``` - -### [IncludeOnly(SummaryPipeline, AccessModifier)](../src/Core/Pipelines/SummaryPipelineExtensions.cs#L55) -```cs -public static SummaryPipeline IncludeOnly(this SummaryPipeline self, AccessModifier access) -``` - -Includes only members that have at least the given access modifier. - -#### Example -In order to include onl `internal` members in the generated docs, -you can call this method as follows: -```cs -var pipeline = ...; - -pipeline.IncludeOnly(AccessModifier.Internal); -``` - -### [UseFilter(SummaryPipeline, IPipe)](../src/Core/Pipelines/SummaryPipelineExtensions.cs#L62) -```cs -public static SummaryPipeline UseFilter(this SummaryPipeline self, IPipe filter) -``` - -Adds the given filter into the pipeline. -