Move files to correct dirs
This commit is contained in:
parent
aaf3153205
commit
11e40156e8
|
@ -1,4 +1,5 @@
|
|||
mod skeleton;
|
||||
mod util;
|
||||
|
||||
use std::{collections::HashMap, vec::Vec};
|
||||
|
||||
|
@ -7,7 +8,7 @@ use proc_macro2::TokenStream;
|
|||
use quote::{format_ident, quote};
|
||||
use regex::Regex;
|
||||
|
||||
use crate::{md_parser, parser, types, util};
|
||||
use crate::{md_parser, parser, types};
|
||||
|
||||
use self::skeleton::{auth_ident, generate_skeleton};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use quote::quote;
|
||||
|
||||
use crate::util;
|
||||
use super::util;
|
||||
|
||||
pub const AUTH_IDENT: &str = "Authenticated";
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ mod generate;
|
|||
mod md_parser;
|
||||
mod parser;
|
||||
mod types;
|
||||
mod util;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use syn::parse_macro_input;
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
mod description;
|
||||
mod parameters;
|
||||
mod return_type;
|
||||
mod url;
|
||||
|
||||
use crate::{
|
||||
md_parser,
|
||||
parser::{parameters::parse_parameters, util},
|
||||
types,
|
||||
};
|
||||
use crate::{md_parser, parser::util, types};
|
||||
|
||||
use self::{
|
||||
description::parse_method_description,
|
||||
parameters::parse_parameters,
|
||||
return_type::{parse_return_type, ReturnType},
|
||||
url::get_method_url,
|
||||
};
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
md_parser::MdContent,
|
||||
parser::{object_types::parse_object_types, types, ReturnTypeParameter},
|
||||
md_parser::{self, MdContent},
|
||||
parser::{types, ReturnTypeParameter},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -56,3 +58,43 @@ pub fn parse_return_type(content: &[MdContent]) -> Option<ReturnType> {
|
|||
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;
|
||||
|
||||
mod group;
|
||||
mod object_types;
|
||||
mod parameters;
|
||||
mod util;
|
||||
|
||||
#[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