Entry point: render the schema rooted at `path` in the requested format.
(path: &str, fmt: ExplainFormat)
| 35 | |
| 36 | /// Entry point: render the schema rooted at `path` in the requested format. |
| 37 | pub fn explain(path: &str, fmt: ExplainFormat) -> Result<String> { |
| 38 | let (root, rest) = split_root(path)?; |
| 39 | let schema = root_schema_for(root); |
| 40 | let target = |
| 41 | navigate(&schema, &schema.schema, &rest).with_context(|| { |
| 42 | format!("path `{}` does not exist in `{}` schema", path, root) |
| 43 | })?; |
| 44 | Ok(match fmt { |
| 45 | ExplainFormat::Plaintext => render_plaintext(root, &rest, &schema, &target), |
| 46 | ExplainFormat::Example => render_example(&schema, &target), |
| 47 | ExplainFormat::Jsonschema => render_jsonschema(&schema, &target), |
| 48 | }) |
| 49 | } |
| 50 | |
| 51 | /// Split `reply.evidence.figure` into (`reply`, `["evidence", "figure"]`). |
| 52 | /// Errors with a hint if the root is unknown. |
searching dependent graphs…