MCPcopy Create free account
hub / github.com/apache/datafusion / print_docs

Function print_docs

datafusion/core/src/bin/print_functions_docs.rs:93–245  ·  view source on GitHub ↗
(
    providers: Vec<Box<dyn DocProvider>>,
    doc_sections: Vec<DocSection>,
)

Source from the content-addressed store, hash-verified

91
92#[expect(clippy::needless_pass_by_value)]
93fn print_docs(
94 providers: Vec<Box<dyn DocProvider>>,
95 doc_sections: Vec<DocSection>,
96) -> Result<String> {
97 let mut docs = "".to_string();
98
99 // Ensure that all providers have documentation
100 let mut providers_with_no_docs = HashSet::new();
101
102 // doc sections only includes sections that have 'include' == true
103 for doc_section in doc_sections {
104 // make sure there is at least one function that is in this doc section
105 if !&providers.iter().any(|f| {
106 if let Some(documentation) = f.get_documentation() {
107 documentation.doc_section == doc_section
108 } else {
109 false
110 }
111 }) {
112 continue;
113 }
114
115 // filter out functions that are not in this doc section
116 let providers: Vec<&Box<dyn DocProvider>> = providers
117 .iter()
118 .filter(|&f| {
119 if let Some(documentation) = f.get_documentation() {
120 documentation.doc_section == doc_section
121 } else {
122 providers_with_no_docs.insert(f.get_name());
123 false
124 }
125 })
126 .collect::<Vec<_>>();
127
128 // write out section header
129 let _ = writeln!(docs, "\n## {} \n", doc_section.label);
130
131 if let Some(description) = doc_section.description {
132 let _ = writeln!(docs, "{description}");
133 }
134
135 // names is a sorted list of function names and aliases since we display
136 // both in the documentation
137 let names = get_names_and_aliases(&providers);
138
139 // write out the list of function names and aliases
140 names.iter().for_each(|name| {
141 let _ = writeln!(docs, "- [{name}](#{name})");
142 });
143
144 // write out each function and alias in the order of the sorted name list
145 for name in names {
146 let f = providers
147 .iter()
148 .find(|f| f.get_name() == name || f.get_aliases().contains(&name))
149 .unwrap();
150

Callers 3

print_aggregate_docsFunction · 0.85
print_scalar_docsFunction · 0.85
print_window_docsFunction · 0.85

Calls 12

newFunction · 0.85
get_names_and_aliasesFunction · 0.85
get_documentationMethod · 0.80
get_nameMethod · 0.80
get_aliasesMethod · 0.80
to_stringMethod · 0.45
anyMethod · 0.45
iterMethod · 0.45
filterMethod · 0.45
insertMethod · 0.45
containsMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…