Move files to correct dirs
This commit is contained in:
parent
aaf3153205
commit
11e40156e8
|
@ -1,4 +1,5 @@
|
||||||
mod skeleton;
|
mod skeleton;
|
||||||
|
mod util;
|
||||||
|
|
||||||
use std::{collections::HashMap, vec::Vec};
|
use std::{collections::HashMap, vec::Vec};
|
||||||
|
|
||||||
|
@ -7,7 +8,7 @@ use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::{md_parser, parser, types, util};
|
use crate::{md_parser, parser, types};
|
||||||
|
|
||||||
use self::skeleton::{auth_ident, generate_skeleton};
|
use self::skeleton::{auth_ident, generate_skeleton};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
|
||||||
use crate::util;
|
use super::util;
|
||||||
|
|
||||||
pub const AUTH_IDENT: &str = "Authenticated";
|
pub const AUTH_IDENT: &str = "Authenticated";
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ mod generate;
|
||||||
mod md_parser;
|
mod md_parser;
|
||||||
mod parser;
|
mod parser;
|
||||||
mod types;
|
mod types;
|
||||||
mod util;
|
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use syn::parse_macro_input;
|
use syn::parse_macro_input;
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
mod description;
|
mod description;
|
||||||
|
mod parameters;
|
||||||
mod return_type;
|
mod return_type;
|
||||||
mod url;
|
mod url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{md_parser, parser::util, types};
|
||||||
md_parser,
|
|
||||||
parser::{parameters::parse_parameters, util},
|
|
||||||
types,
|
|
||||||
};
|
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
description::parse_method_description,
|
description::parse_method_description,
|
||||||
|
parameters::parse_parameters,
|
||||||
return_type::{parse_return_type, ReturnType},
|
return_type::{parse_return_type, ReturnType},
|
||||||
url::get_method_url,
|
url::get_method_url,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
md_parser::MdContent,
|
md_parser::{self, MdContent},
|
||||||
parser::{object_types::parse_object_types, types, ReturnTypeParameter},
|
parser::{types, ReturnTypeParameter},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -56,3 +58,43 @@ pub fn parse_return_type(content: &[MdContent]) -> Option<ReturnType> {
|
||||||
is_list,
|
is_list,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parse_object_types(
|
||||||
|
content: &[md_parser::MdContent],
|
||||||
|
) -> HashMap<String, types::TypeDescription> {
|
||||||
|
let mut output = HashMap::new();
|
||||||
|
let mut content_it = content.iter();
|
||||||
|
|
||||||
|
while let Some(entry) = content_it.next() {
|
||||||
|
if let md_parser::MdContent::Text(content) = entry {
|
||||||
|
const POSSIBLE_VALUES_OF: &str = "Possible values of ";
|
||||||
|
if content.contains(POSSIBLE_VALUES_OF) {
|
||||||
|
// is empty
|
||||||
|
content_it.next();
|
||||||
|
if let Some(md_parser::MdContent::Table(table)) = content_it.next() {
|
||||||
|
let enum_types = to_type_descriptions(table);
|
||||||
|
|
||||||
|
let name = content
|
||||||
|
.trim_start_matches(POSSIBLE_VALUES_OF)
|
||||||
|
.replace('`', "")
|
||||||
|
.replace(':', "");
|
||||||
|
|
||||||
|
output.insert(name, types::TypeDescription { values: enum_types });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_type_descriptions(table: &md_parser::Table) -> Vec<types::TypeDescriptions> {
|
||||||
|
table
|
||||||
|
.rows
|
||||||
|
.iter()
|
||||||
|
.map(|row| types::TypeDescriptions {
|
||||||
|
value: row.columns[0].to_string(),
|
||||||
|
description: row.columns[1].to_string(),
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ use crate::{md_parser, types};
|
||||||
use self::group::parse_api_group;
|
use self::group::parse_api_group;
|
||||||
|
|
||||||
mod group;
|
mod group;
|
||||||
mod object_types;
|
|
||||||
mod parameters;
|
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use crate::{md_parser, parser::types};
|
|
||||||
|
|
||||||
pub fn parse_object_types(
|
|
||||||
content: &[md_parser::MdContent],
|
|
||||||
) -> HashMap<String, types::TypeDescription> {
|
|
||||||
let mut output = HashMap::new();
|
|
||||||
let mut content_it = content.iter();
|
|
||||||
|
|
||||||
while let Some(entry) = content_it.next() {
|
|
||||||
if let md_parser::MdContent::Text(content) = entry {
|
|
||||||
const POSSIBLE_VALUES_OF: &str = "Possible values of ";
|
|
||||||
if content.contains(POSSIBLE_VALUES_OF) {
|
|
||||||
// is empty
|
|
||||||
content_it.next();
|
|
||||||
if let Some(md_parser::MdContent::Table(table)) = content_it.next() {
|
|
||||||
let enum_types = to_type_descriptions(table);
|
|
||||||
|
|
||||||
let name = content
|
|
||||||
.trim_start_matches(POSSIBLE_VALUES_OF)
|
|
||||||
.replace('`', "")
|
|
||||||
.replace(':', "");
|
|
||||||
|
|
||||||
output.insert(name, types::TypeDescription { values: enum_types });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
output
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_type_descriptions(table: &md_parser::Table) -> Vec<types::TypeDescriptions> {
|
|
||||||
table
|
|
||||||
.rows
|
|
||||||
.iter()
|
|
||||||
.map(|row| types::TypeDescriptions {
|
|
||||||
value: row.columns[0].to_string(),
|
|
||||||
description: row.columns[1].to_string(),
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user