Skip to content

Commit

Permalink
minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Nov 15, 2024
1 parent a048fb6 commit de46a52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/datamodel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ use crate::json::parser::parse_json_schema;
use crate::markdown::frontmatter::FrontMatter;
use crate::markdown::parser::parse_markdown;
use crate::object::{Enumeration, Object};
use crate::{markdown, schema};
use crate::schema;
use colored::Colorize;

#[cfg(feature = "python")]
use pyo3::pyclass;
use crate::validation::Validator;

// Data model
//
Expand Down Expand Up @@ -68,7 +69,7 @@ pub struct DataModel {
pub objects: Vec<Object>,
pub enums: Vec<Enumeration>,
#[serde(skip_serializing_if = "Option::is_none")]
pub config: Option<markdown::frontmatter::FrontMatter>,
pub config: Option<FrontMatter>,
}

impl DataModel {
Expand Down Expand Up @@ -288,8 +289,8 @@ impl DataModel {
/// ```
/// # Returns
/// A data model
pub fn from_markdown(path: &Path) -> Result<Self, Box<dyn Error>> {
let content = fs::read_to_string(path)?;
pub fn from_markdown(path: &Path) -> Result<Self, Validator> {
let content = fs::read_to_string(path).expect("Could not read file");
parse_markdown(&content)
}

Expand All @@ -310,7 +311,7 @@ impl DataModel {
/// ```
/// # Returns
/// A data model
pub fn from_markdown_string(content: &str) -> Result<Self, Box<dyn Error>> {
pub fn from_markdown_string(content: &str) -> Result<Self, Validator> {
parse_markdown(content)
}

Expand Down
3 changes: 2 additions & 1 deletion src/markdown/frontmatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
use std::collections::HashMap;

use gray_matter::{engine::YAML, Matter};
use serde::{Deserialize, Serialize};

#[cfg(feature = "python")]
use pyo3::pyclass;
use serde::{Deserialize, Serialize};

/// Represents the front matter data of a markdown file.
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
Expand Down

0 comments on commit de46a52

Please sign in to comment.