mirror of
https://github.com/CompeyDev/lune-packaging.git
synced 2025-01-09 12:19:09 +00:00
Fix docs gen test
This commit is contained in:
parent
1bee0986c7
commit
b6f0f90ac5
3 changed files with 10 additions and 8 deletions
|
@ -9,7 +9,8 @@ mod doc;
|
|||
|
||||
const GENERATED_COMMENT_TAG: &str = "@generated with lune-cli";
|
||||
|
||||
use self::doc::{DocsFunctionParamLink, DocumentationVisitor};
|
||||
use self::doc::DocsFunctionParamLink;
|
||||
pub use self::doc::DocumentationVisitor;
|
||||
|
||||
pub fn generate_docs_json_from_definitions(contents: &str, namespace: &str) -> Result<String> {
|
||||
let visitor = DocumentationVisitor::from_definitions(contents)?;
|
||||
|
|
|
@ -31,7 +31,7 @@ async fn inner(file_name: &str, desired_type: FileType) -> Result<()> {
|
|||
fmt_path_relative_to_workspace_root(file_name)
|
||||
)
|
||||
})?;
|
||||
let parsed_type = FileType::from_contents(&file_contents);
|
||||
let parsed_type = FileType::sniff(&file_contents);
|
||||
if parsed_type != Some(desired_type) {
|
||||
bail!(
|
||||
"Generating definitions file at '{}' created '{}', expected '{}'",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use serde_json::Value;
|
||||
use serde_json::Value as JsonValue;
|
||||
use serde_yaml::Value as YamlValue;
|
||||
|
||||
use crate::gen::parse_definitions;
|
||||
use crate::gen::DocumentationVisitor;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum FileType {
|
||||
|
@ -10,12 +11,12 @@ pub enum FileType {
|
|||
}
|
||||
|
||||
impl FileType {
|
||||
pub fn from_contents(contents: &str) -> Option<Self> {
|
||||
if serde_json::from_str::<Value>(contents).is_ok() {
|
||||
pub fn sniff(contents: &str) -> Option<Self> {
|
||||
if serde_json::from_str::<JsonValue>(contents).is_ok() {
|
||||
Some(Self::Json)
|
||||
} else if serde_yaml::from_str::<Value>(contents).is_ok() {
|
||||
} else if serde_yaml::from_str::<YamlValue>(contents).is_ok() {
|
||||
Some(Self::Yaml)
|
||||
} else if parse_definitions(contents).is_ok() {
|
||||
} else if DocumentationVisitor::from_definitions(contents).is_ok() {
|
||||
Some(Self::Luau)
|
||||
} else {
|
||||
None
|
||||
|
|
Loading…
Reference in a new issue