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

Method from_dir

datafusion-examples/src/utils/example_metadata/model.rs:55–73  ·  view source on GitHub ↗

Parses an example group from its directory. The group name is derived from the directory name, and example entries are extracted from `main.rs`.

(dir: &Path, category: Category)

Source from the content-addressed store, hash-verified

53 /// The group name is derived from the directory name, and example
54 /// entries are extracted from `main.rs`.
55 pub fn from_dir(dir: &Path, category: Category) -> Result<Self> {
56 let raw_name = dir
57 .file_name()
58 .and_then(|s| s.to_str())
59 .ok_or_else(|| {
60 DataFusionError::Execution("Invalid example group dir".to_string())
61 })?
62 .to_string();
63
64 let name = GroupName::from_dir_name(raw_name);
65 let main_rs = dir.join("main.rs");
66 let examples = parse_main_rs_docs(&main_rs)?;
67
68 Ok(Self {
69 name,
70 examples,
71 category,
72 })
73 }
74}
75
76/// Represents an example group name in both raw and human-readable forms.

Callers

nothing calls this directly

Calls 3

parse_main_rs_docsFunction · 0.85
to_stringMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected