Browse Source

Documentation: Component

Marcin Ziąbek 2 years ago
parent
commit
2026c2103e

+ 3 - 0
Source/QuestPDF/Fluent/ComponentExtentions.cs

@@ -41,11 +41,14 @@ namespace QuestPDF.Fluent
     
     
     public static class ComponentExtensions
     public static class ComponentExtensions
     {
     {
+        /// <include file='../Resources/Documentation.xml' path='documentation/doc[@for="component"]/*' />
+        /// <param name="component">Instance of the class implementing the <see cref="IComponent"></see> interface.</param>
         public static void Component<T>(this IContainer element, T component) where T : IComponent
         public static void Component<T>(this IContainer element, T component) where T : IComponent
         {
         {
             element.Component(component, null);
             element.Component(component, null);
         }
         }
         
         
+        /// <include file='../Resources/Documentation.xml' path='documentation/doc[@for="component"]/*' />
         public static void Component<T>(this IContainer element) where T : IComponent, new()
         public static void Component<T>(this IContainer element) where T : IComponent, new()
         {
         {
             element.Component(new T(), null);
             element.Component(new T(), null);

+ 16 - 0
Source/QuestPDF/Infrastructure/IComponent.cs

@@ -12,8 +12,24 @@ namespace QuestPDF.Infrastructure
         
         
     }
     }
     
     
+    /// <summary>
+    /// <para>This interface represents a reusable document fragment.</para>
+    ///
+    /// <para>
+    /// Components serve as modular building blocks for abstracting document layouts. 
+    /// They promote code reusability across multiple sections or types of documents. 
+    /// Using a component, you can generate content based on its internal state.
+    /// </para>
+    /// </summary>
+    /// <example>
+    /// Consider the scenario of a company-wide page header.
+    /// Instead of replicating the same header design across various documents, a single component can be created and referenced wherever needed.
+    /// </example>
     public interface IComponent
     public interface IComponent
     {
     {
+        /// <summary>
+        /// Method invoked by the library to compose document content. 
+        /// </summary>
         void Compose(IContainer container);
         void Compose(IContainer container);
     }
     }
 }
 }

+ 18 - 0
Source/QuestPDF/Resources/Documentation.xml

@@ -392,4 +392,22 @@
         
         
         <param name="port">This parameter is ignored.</param>
         <param name="port">This parameter is ignored.</param>
     </doc>
     </doc>
+    
+    <!-- COMPONENTS -->
+
+    <doc for="component">
+        <summary>
+            Components serve as modular building blocks for abstracting document layouts. 
+            They promote code reusability across multiple sections or types of documents. 
+            Using a component, you can generate content based on its internal state.
+            <a href="https://www.questpdf.com/concepts/components.html">Learn more</a>
+        </summary>
+        <example>
+            Consider the scenario of a company-wide page header. 
+            Instead of replicating the same header design across various documents, a single component can be created and referenced wherever needed.
+        </example>
+        <param name="component">An instance of the class implementing the <see cref="IComponent" /> interface.</param>
+    </doc>   
+    
+    
 </documentation>
 </documentation>