Fix warnings
This commit is contained in:
parent
68bb159dc3
commit
07e825bcd4
File diff suppressed because it is too large
Load Diff
|
@ -127,10 +127,6 @@ impl parser::ApiMethod {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name_camel(&self) -> Ident {
|
|
||||||
util::to_ident(&self.name.to_camel())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name_snake(&self) -> Ident {
|
fn name_snake(&self) -> Ident {
|
||||||
util::to_ident(&self.name.to_snake())
|
util::to_ident(&self.name.to_snake())
|
||||||
}
|
}
|
||||||
|
@ -169,10 +165,6 @@ impl types::Type {
|
||||||
self.get_type_info().name.clone()
|
self.get_type_info().name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name_camel(&self) -> Ident {
|
|
||||||
util::to_ident(&self.name().to_camel())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name_snake(&self) -> Ident {
|
fn name_snake(&self) -> Ident {
|
||||||
util::to_ident(&self.name().to_snake())
|
util::to_ident(&self.name().to_snake())
|
||||||
}
|
}
|
||||||
|
@ -218,10 +210,6 @@ impl parser::EnumValue {
|
||||||
fn name_camel(&self) -> Ident {
|
fn name_camel(&self) -> Ident {
|
||||||
util::to_ident(&self.value.to_camel())
|
util::to_ident(&self.value.to_camel())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name_snake(&self) -> Ident {
|
|
||||||
util::to_ident(&self.value.to_snake())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -13,33 +13,27 @@ ApiMethod {
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "id",
|
name: "id",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"ID of the search job",
|
"ID of the search job",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Number(
|
Number(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "limit",
|
name: "limit",
|
||||||
is_optional: true,
|
is_optional: true,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"max number of results to return. 0 or negative means no limit",
|
"max number of results to return. 0 or negative means no limit",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Number(
|
Number(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "offset",
|
name: "offset",
|
||||||
is_optional: true,
|
is_optional: true,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"result to start at. A negative number means count backwards (e.g. -2 returns the 2 most recent results)",
|
"result to start at. A negative number means count backwards (e.g. -2 returns the 2 most recent results)",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -53,77 +47,63 @@ ApiMethod {
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "descrLink",
|
name: "descrLink",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"URL of the torrent's description page",
|
"URL of the torrent's description page",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
String(
|
String(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "fileName",
|
name: "fileName",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"Name of the file",
|
"Name of the file",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Number(
|
Number(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "fileSize",
|
name: "fileSize",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"Size of the file in Bytes",
|
"Size of the file in Bytes",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
String(
|
String(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "fileUrl",
|
name: "fileUrl",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"Torrent download link (usually either .torrent file or magnet link)",
|
"Torrent download link (usually either .torrent file or magnet link)",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Number(
|
Number(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "nbLeechers",
|
name: "nbLeechers",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"Number of leechers",
|
"Number of leechers",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Number(
|
Number(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "nbSeeders",
|
name: "nbSeeders",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"Number of seeders",
|
"Number of seeders",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
String(
|
String(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "siteUrl",
|
name: "siteUrl",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"URL of the torrent site",
|
"URL of the torrent site",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -137,11 +117,9 @@ ApiMethod {
|
||||||
type_info: TypeInfo {
|
type_info: TypeInfo {
|
||||||
name: "results",
|
name: "results",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"Array of result objects- see table below",
|
"Array of result objects- see table below",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
ref_type: "Result",
|
ref_type: "Result",
|
||||||
},
|
},
|
||||||
|
@ -150,22 +128,18 @@ ApiMethod {
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "status",
|
name: "status",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"Current status of the search job (either Running or Stopped)",
|
"Current status of the search job (either Running or Stopped)",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Number(
|
Number(
|
||||||
TypeInfo {
|
TypeInfo {
|
||||||
name: "total",
|
name: "total",
|
||||||
is_optional: false,
|
is_optional: false,
|
||||||
is_list: false,
|
|
||||||
description: Some(
|
description: Some(
|
||||||
"Total number of results. If the status is Running this number may continue to increase",
|
"Total number of results. If the status is Running this number may continue to increase",
|
||||||
),
|
),
|
||||||
type_description: None,
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -5,7 +5,7 @@ mod url;
|
||||||
use crate::{md_parser, types};
|
use crate::{md_parser, types};
|
||||||
use case::CaseExt;
|
use case::CaseExt;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ApiMethod {
|
pub struct ApiMethod {
|
||||||
|
@ -312,13 +312,6 @@ impl md_parser::Table {
|
||||||
|
|
||||||
impl md_parser::TableRow {
|
impl md_parser::TableRow {
|
||||||
fn to_type(&self) -> Option<types::Type> {
|
fn to_type(&self) -> Option<types::Type> {
|
||||||
self.to_types_with_types(&HashMap::new())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_types_with_types(
|
|
||||||
&self,
|
|
||||||
type_map: &HashMap<String, types::TypeDescription>,
|
|
||||||
) -> Option<types::Type> {
|
|
||||||
let columns = &self.columns;
|
let columns = &self.columns;
|
||||||
let description = columns.get(2).cloned();
|
let description = columns.get(2).cloned();
|
||||||
|
|
||||||
|
@ -327,9 +320,9 @@ impl md_parser::TableRow {
|
||||||
Some(desc) if desc.contains("default: ") => {
|
Some(desc) if desc.contains("default: ") => {
|
||||||
// type defines a variable as default if it contains: _optional_
|
// type defines a variable as default if it contains: _optional_
|
||||||
let name_with_optional = format!("{} {}", columns[0], types::OPTIONAL);
|
let name_with_optional = format!("{} {}", columns[0], types::OPTIONAL);
|
||||||
types::Type::from(&columns[1], &name_with_optional, description, type_map)
|
types::Type::from(&columns[1], &name_with_optional, description)
|
||||||
}
|
}
|
||||||
_ => types::Type::from(&columns[1], &columns[0], description, type_map),
|
_ => types::Type::from(&columns[1], &columns[0], description),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use case::CaseExt;
|
use case::CaseExt;
|
||||||
use regex::RegexBuilder;
|
use regex::RegexBuilder;
|
||||||
|
|
||||||
|
@ -18,25 +16,17 @@ pub struct TypeDescription {
|
||||||
pub struct TypeInfo {
|
pub struct TypeInfo {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub is_optional: bool,
|
pub is_optional: bool,
|
||||||
is_list: bool,
|
// is_list: bool,
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
pub type_description: Option<TypeDescription>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TypeInfo {
|
impl TypeInfo {
|
||||||
pub fn new(
|
pub fn new(name: &str, is_optional: bool, description: Option<String>) -> Self {
|
||||||
name: &str,
|
|
||||||
is_optional: bool,
|
|
||||||
is_list: bool,
|
|
||||||
description: Option<String>,
|
|
||||||
type_description: Option<TypeDescription>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
Self {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
is_optional,
|
is_optional,
|
||||||
is_list,
|
// is_list,
|
||||||
description,
|
description,
|
||||||
type_description,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,9 +74,9 @@ impl Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_list(&self) -> bool {
|
// pub fn is_list(&self) -> bool {
|
||||||
self.get_type_info().is_list || matches!(self, Type::StringArray(_))
|
// self.get_type_info().is_list || matches!(self, Type::StringArray(_))
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn to_borrowed_type(&self) -> String {
|
pub fn to_borrowed_type(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
|
@ -118,13 +108,7 @@ impl Type {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from(
|
pub fn from(type_as_str: &str, name: &str, description: Option<String>) -> Option<Type> {
|
||||||
type_as_str: &str,
|
|
||||||
name: &str,
|
|
||||||
description: Option<String>,
|
|
||||||
types: &HashMap<String, TypeDescription>,
|
|
||||||
) -> Option<Type> {
|
|
||||||
let available_types = types.get(name).cloned();
|
|
||||||
let type_name = match name.split_once(OPTIONAL) {
|
let type_name = match name.split_once(OPTIONAL) {
|
||||||
Some((split, _)) => split,
|
Some((split, _)) => split,
|
||||||
None => name,
|
None => name,
|
||||||
|
@ -132,15 +116,7 @@ impl Type {
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
let is_optional = name.contains(OPTIONAL);
|
let is_optional = name.contains(OPTIONAL);
|
||||||
let create_type_info = || {
|
let create_type_info = || TypeInfo::new(type_name, is_optional, description.clone());
|
||||||
TypeInfo::new(
|
|
||||||
type_name,
|
|
||||||
is_optional,
|
|
||||||
false,
|
|
||||||
description.clone(),
|
|
||||||
available_types.clone(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
let create_object_type = |name: &str| {
|
let create_object_type = |name: &str| {
|
||||||
Some(Type::Object(Object {
|
Some(Type::Object(Object {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user