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";
|
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> {
|
pub fn generate_docs_json_from_definitions(contents: &str, namespace: &str) -> Result<String> {
|
||||||
let visitor = DocumentationVisitor::from_definitions(contents)?;
|
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)
|
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) {
|
if parsed_type != Some(desired_type) {
|
||||||
bail!(
|
bail!(
|
||||||
"Generating definitions file at '{}' created '{}', expected '{}'",
|
"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)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum FileType {
|
pub enum FileType {
|
||||||
|
@ -10,12 +11,12 @@ pub enum FileType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileType {
|
impl FileType {
|
||||||
pub fn from_contents(contents: &str) -> Option<Self> {
|
pub fn sniff(contents: &str) -> Option<Self> {
|
||||||
if serde_json::from_str::<Value>(contents).is_ok() {
|
if serde_json::from_str::<JsonValue>(contents).is_ok() {
|
||||||
Some(Self::Json)
|
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)
|
Some(Self::Yaml)
|
||||||
} else if parse_definitions(contents).is_ok() {
|
} else if DocumentationVisitor::from_definitions(contents).is_ok() {
|
||||||
Some(Self::Luau)
|
Some(Self::Luau)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in a new issue