Skip to content

Commit 8fd792f

Browse files
authored
Restore DocBuilder::new() to avoid breaking API change (#13870)
* Fix build * Restore DocBuilder::new(), deprecate * cmt * clippy
1 parent a7ff7a5 commit 8fd792f

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

datafusion/doc/src/lib.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
#[allow(rustdoc::broken_intra_doc_links)]
1919
/// Documentation for use by [`ScalarUDFImpl`](ScalarUDFImpl),
20-
/// [`AggregateUDFImpl`](AggregateUDFImpl) and [`WindowUDFImpl`](WindowUDFImpl) functions
21-
/// that will be used to generate public documentation.
20+
/// [`AggregateUDFImpl`](AggregateUDFImpl) and [`WindowUDFImpl`](WindowUDFImpl) functions.
2221
///
22+
/// See the [`DocumentationBuilder`] to create a new [`Documentation`] struct.
23+
///
24+
/// The DataFusion [SQL function documentation] is automatically generated from these structs.
2325
/// The name of the udf will be pulled from the [`ScalarUDFImpl::name`](ScalarUDFImpl::name),
2426
/// [`AggregateUDFImpl::name`](AggregateUDFImpl::name) or [`WindowUDFImpl::name`](WindowUDFImpl::name)
2527
/// function as appropriate.
@@ -29,6 +31,8 @@
2931
///
3032
/// Currently, documentation only supports a single language
3133
/// thus all text should be in English.
34+
///
35+
/// [SQL function documentation]: https://datafusion.apache.org/user-guide/sql/index.html
3236
#[derive(Debug, Clone)]
3337
pub struct Documentation {
3438
/// The section in the documentation where the UDF will be documented
@@ -61,7 +65,7 @@ impl Documentation {
6165
description: impl Into<String>,
6266
syntax_example: impl Into<String>,
6367
) -> DocumentationBuilder {
64-
DocumentationBuilder::new(doc_section, description, syntax_example)
68+
DocumentationBuilder::new_with_details(doc_section, description, syntax_example)
6569
}
6670

6771
/// Output the `Documentation` struct in form of custom Rust documentation attributes
@@ -160,7 +164,21 @@ pub struct DocSection {
160164
pub description: Option<&'static str>,
161165
}
162166

163-
/// A builder to be used for building [`Documentation`]'s.
167+
impl Default for DocSection {
168+
/// Returns a "default" Doc section.
169+
///
170+
/// This is suitable for user defined functions that do not appear in the
171+
/// DataFusion documentation.
172+
fn default() -> Self {
173+
Self {
174+
include: true,
175+
label: "Default",
176+
description: None,
177+
}
178+
}
179+
}
180+
181+
/// A builder for [`Documentation`]'s.
164182
///
165183
/// Example:
166184
///
@@ -189,7 +207,17 @@ pub struct DocumentationBuilder {
189207
}
190208

191209
impl DocumentationBuilder {
192-
pub fn new(
210+
#[allow(clippy::new_without_default)]
211+
#[deprecated(
212+
since = "44.0.0",
213+
note = "please use `DocumentationBuilder::new_with_details` instead"
214+
)]
215+
pub fn new() -> Self {
216+
Self::new_with_details(DocSection::default(), "<no description>", "<no example>")
217+
}
218+
219+
/// Creates a new [`DocumentationBuilder`] with all required fields
220+
pub fn new_with_details(
193221
doc_section: DocSection,
194222
description: impl Into<String>,
195223
syntax_example: impl Into<String>,

0 commit comments

Comments
 (0)