|
17 | 17 |
|
18 | 18 | #[allow(rustdoc::broken_intra_doc_links)]
|
19 | 19 | /// 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. |
22 | 21 | ///
|
| 22 | +/// See the [`DocumentationBuilder`] to create a new [`Documentation`] struct. |
| 23 | +/// |
| 24 | +/// The DataFusion [SQL function documentation] is automatically generated from these structs. |
23 | 25 | /// The name of the udf will be pulled from the [`ScalarUDFImpl::name`](ScalarUDFImpl::name),
|
24 | 26 | /// [`AggregateUDFImpl::name`](AggregateUDFImpl::name) or [`WindowUDFImpl::name`](WindowUDFImpl::name)
|
25 | 27 | /// function as appropriate.
|
|
29 | 31 | ///
|
30 | 32 | /// Currently, documentation only supports a single language
|
31 | 33 | /// thus all text should be in English.
|
| 34 | +/// |
| 35 | +/// [SQL function documentation]: https://datafusion.apache.org/user-guide/sql/index.html |
32 | 36 | #[derive(Debug, Clone)]
|
33 | 37 | pub struct Documentation {
|
34 | 38 | /// The section in the documentation where the UDF will be documented
|
@@ -61,7 +65,7 @@ impl Documentation {
|
61 | 65 | description: impl Into<String>,
|
62 | 66 | syntax_example: impl Into<String>,
|
63 | 67 | ) -> DocumentationBuilder {
|
64 |
| - DocumentationBuilder::new(doc_section, description, syntax_example) |
| 68 | + DocumentationBuilder::new_with_details(doc_section, description, syntax_example) |
65 | 69 | }
|
66 | 70 |
|
67 | 71 | /// Output the `Documentation` struct in form of custom Rust documentation attributes
|
@@ -160,7 +164,21 @@ pub struct DocSection {
|
160 | 164 | pub description: Option<&'static str>,
|
161 | 165 | }
|
162 | 166 |
|
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. |
164 | 182 | ///
|
165 | 183 | /// Example:
|
166 | 184 | ///
|
@@ -189,7 +207,17 @@ pub struct DocumentationBuilder {
|
189 | 207 | }
|
190 | 208 |
|
191 | 209 | 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( |
193 | 221 | doc_section: DocSection,
|
194 | 222 | description: impl Into<String>,
|
195 | 223 | syntax_example: impl Into<String>,
|
|
0 commit comments