1515// specific language governing permissions and limitations
1616// under the License.
1717
18- use datafusion_common:: exec_err;
19- use datafusion_common:: Result ;
20-
21- /// Documentation for use by [`ScalarUDFImpl`](crate::ScalarUDFImpl),
22- /// [`AggregateUDFImpl`](crate::AggregateUDFImpl) and [`WindowUDFImpl`](crate::WindowUDFImpl) functions
18+ #[ allow( rustdoc:: broken_intra_doc_links) ]
19+ /// Documentation for use by [`ScalarUDFImpl`](ScalarUDFImpl),
20+ /// [`AggregateUDFImpl`](AggregateUDFImpl) and [`WindowUDFImpl`](WindowUDFImpl) functions
2321/// that will be used to generate public documentation.
2422///
25- /// The name of the udf will be pulled from the [`ScalarUDFImpl::name`](crate:: ScalarUDFImpl::name),
26- /// [`AggregateUDFImpl::name`](crate:: AggregateUDFImpl::name) or [`WindowUDFImpl::name`](crate:: WindowUDFImpl::name)
23+ /// The name of the udf will be pulled from the [`ScalarUDFImpl::name`](ScalarUDFImpl::name),
24+ /// [`AggregateUDFImpl::name`](AggregateUDFImpl::name) or [`WindowUDFImpl::name`](WindowUDFImpl::name)
2725/// function as appropriate.
2826///
2927/// All strings in the documentation are required to be
@@ -79,18 +77,21 @@ pub struct DocSection {
7977/// Example:
8078///
8179/// ```rust
82- /// # use datafusion_expr::Documentation;
83- /// # use datafusion_expr::scalar_doc_sections::DOC_SECTION_MATH;
84- /// # use datafusion_common::Result;
85- /// #
86- /// # fn main() -> Result<()> {
87- /// let documentation = Documentation::builder()
88- /// .with_doc_section(DOC_SECTION_MATH)
80+ ///
81+ /// # fn main() {
82+ /// use datafusion_doc::{DocSection, Documentation};
83+ /// let doc_section = DocSection {
84+ /// include: true,
85+ /// label: "Display Label",
86+ /// description: None,
87+ /// };
88+ ///
89+ /// let documentation = Documentation::builder()
90+ /// .with_doc_section(doc_section)
8991/// .with_description("Add one to an int32")
9092/// .with_syntax_example("add_one(2)")
9193/// .with_argument("arg_1", "The int32 number to add one to")
92- /// .build()?;
93- /// Ok(())
94+ /// .build();
9495/// # }
9596pub struct DocumentationBuilder {
9697 pub doc_section : Option < DocSection > ,
@@ -190,7 +191,10 @@ impl DocumentationBuilder {
190191 self
191192 }
192193
193- pub fn build ( self ) -> Result < Documentation > {
194+ /// Build the documentation from provided components
195+ ///
196+ /// Panics if `doc_section`, `description` or `syntax_example` is not set
197+ pub fn build ( self ) -> Documentation {
194198 let Self {
195199 doc_section,
196200 description,
@@ -202,24 +206,24 @@ impl DocumentationBuilder {
202206 } = self ;
203207
204208 if doc_section. is_none ( ) {
205- return exec_err ! ( "Documentation must have a doc section" ) ;
209+ panic ! ( "Documentation must have a doc section" ) ;
206210 }
207211 if description. is_none ( ) {
208- return exec_err ! ( "Documentation must have a description" ) ;
212+ panic ! ( "Documentation must have a description" ) ;
209213 }
210214 if syntax_example. is_none ( ) {
211- return exec_err ! ( "Documentation must have a syntax_example" ) ;
215+ panic ! ( "Documentation must have a syntax_example" ) ;
212216 }
213217
214- Ok ( Documentation {
218+ Documentation {
215219 doc_section : doc_section. unwrap ( ) ,
216220 description : description. unwrap ( ) ,
217221 syntax_example : syntax_example. unwrap ( ) ,
218222 sql_example,
219223 arguments,
220224 alternative_syntax,
221225 related_udfs,
222- } )
226+ }
223227 }
224228}
225229
0 commit comments