Refactor project to two crates for easier publishing.
This commit is contained in:
parent
a56c99a45a
commit
d68a1249c5
52
Cargo.lock
generated
52
Cargo.lock
generated
|
@ -17,25 +17,6 @@ version = "1.0.58"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
|
checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "api-gen"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"case",
|
|
||||||
"parser",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"regex",
|
|
||||||
"reqwest",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"syn",
|
|
||||||
"thiserror",
|
|
||||||
"tokio",
|
|
||||||
"trybuild",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -393,10 +374,6 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "md-parser"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
|
@ -533,15 +510,6 @@ dependencies = [
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "parser"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"case",
|
|
||||||
"md-parser",
|
|
||||||
"regex",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
@ -579,7 +547,7 @@ dependencies = [
|
||||||
name = "qbittorrent-web-api"
|
name = "qbittorrent-web-api"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"api-gen",
|
"qbittorrent-web-api-gen",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -587,6 +555,24 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qbittorrent-web-api-gen"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"case",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"regex",
|
||||||
|
"reqwest",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"syn",
|
||||||
|
"thiserror",
|
||||||
|
"tokio",
|
||||||
|
"trybuild",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.20"
|
version = "1.0.20"
|
||||||
|
|
|
@ -10,14 +10,12 @@ path = "src/lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reqwest = { version = "0.11.11", features = ["json", "multipart"] }
|
reqwest = { version = "0.11.11", features = ["json", "multipart"] }
|
||||||
tokio = { version = "1.19.2", features = ["full"] }
|
tokio = { version = "1.19.2", features = ["full"] }
|
||||||
api-gen = { path = "./api-gen", version = "*" }
|
qbittorrent-web-api-gen = { path = "./qbittorrent-web-api-gen", version = "0.1.0" }
|
||||||
serde = { version = "1.0.138", features = ["derive"] }
|
serde = { version = "1.0.138", features = ["derive"] }
|
||||||
serde_json = "1.0.82"
|
serde_json = "1.0.82"
|
||||||
thiserror = "1.0.31"
|
thiserror = "1.0.31"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"api-gen",
|
"qbittorrent-web-api-gen",
|
||||||
"parser",
|
|
||||||
"md-parser",
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "md-parser"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
|
@ -1,9 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "parser"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
md-parser = { path = "../md-parser" }
|
|
||||||
case = "1.0.0"
|
|
||||||
regex = "1.6.0"
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "api-gen"
|
name = "qbittorrent-web-api-gen"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ edition = "2021"
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parser = { path = "../parser" }
|
|
||||||
syn = { version = "1.0.98", features = ["extra-traits"]}
|
syn = { version = "1.0.98", features = ["extra-traits"]}
|
||||||
quote = "1.0.20"
|
quote = "1.0.20"
|
||||||
proc-macro2 = "1.0.40"
|
proc-macro2 = "1.0.40"
|
|
@ -1,11 +1,10 @@
|
||||||
use std::{collections::HashMap, vec::Vec};
|
use std::{collections::HashMap, vec::Vec};
|
||||||
|
|
||||||
use case::CaseExt;
|
use case::CaseExt;
|
||||||
use parser::types::TypeInfo;
|
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::{skeleton::auth_ident, util};
|
use crate::{parser::{self, types::TypeInfo}, skeleton::auth_ident, util};
|
||||||
|
|
||||||
pub fn generate_groups(groups: Vec<parser::ApiGroup>) -> proc_macro2::TokenStream {
|
pub fn generate_groups(groups: Vec<parser::ApiGroup>) -> proc_macro2::TokenStream {
|
||||||
let gr = groups
|
let gr = groups
|
|
@ -1,6 +1,8 @@
|
||||||
mod group;
|
mod group;
|
||||||
mod skeleton;
|
mod skeleton;
|
||||||
mod util;
|
mod util;
|
||||||
|
mod parser;
|
||||||
|
mod md_parser;
|
||||||
|
|
||||||
use case::CaseExt;
|
use case::CaseExt;
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
|
@ -10,7 +12,7 @@ use syn::parse_macro_input;
|
||||||
|
|
||||||
use crate::group::generate_groups;
|
use crate::group::generate_groups;
|
||||||
|
|
||||||
const API_CONTENT: &str = include_str!("api-4_1.md");
|
const API_CONTENT: &str = include_str!("../api-4_1.md");
|
||||||
|
|
||||||
#[proc_macro_derive(QBittorrentApiGen, attributes(api_gen))]
|
#[proc_macro_derive(QBittorrentApiGen, attributes(api_gen))]
|
||||||
pub fn derive(input: TokenStream) -> TokenStream {
|
pub fn derive(input: TokenStream) -> TokenStream {
|
|
@ -1,4 +1,4 @@
|
||||||
use md_parser::MdContent;
|
use crate::md_parser::MdContent;
|
||||||
|
|
||||||
pub fn get_group_description(content: &[MdContent]) -> Option<String> {
|
pub fn get_group_description(content: &[MdContent]) -> Option<String> {
|
||||||
let return_desc = content
|
let return_desc = content
|
|
@ -1,14 +1,14 @@
|
||||||
|
use crate::md_parser::TokenTree;
|
||||||
|
|
||||||
|
use self::{return_type::get_return_type, parameters::get_parameters};
|
||||||
|
|
||||||
|
use super::{ApiGroup, ApiMethod, util};
|
||||||
|
|
||||||
mod description;
|
mod description;
|
||||||
mod parameters;
|
mod parameters;
|
||||||
mod return_type;
|
mod return_type;
|
||||||
mod url_parser;
|
mod url_parser;
|
||||||
|
|
||||||
use md_parser::TokenTree;
|
|
||||||
|
|
||||||
use crate::{util, ApiGroup, ApiMethod};
|
|
||||||
|
|
||||||
use self::{parameters::get_parameters, return_type::get_return_type};
|
|
||||||
|
|
||||||
pub fn parse_groups(trees: Vec<TokenTree>) -> Vec<ApiGroup> {
|
pub fn parse_groups(trees: Vec<TokenTree>) -> Vec<ApiGroup> {
|
||||||
trees.into_iter().map(parse_api_group).collect()
|
trees.into_iter().map(parse_api_group).collect()
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use md_parser::MdContent;
|
use crate::{
|
||||||
|
md_parser::MdContent,
|
||||||
use crate::types::{Type, OPTIONAL};
|
parser::types::{Type, OPTIONAL},
|
||||||
|
};
|
||||||
|
|
||||||
pub fn get_parameters(content: &[MdContent]) -> Option<Vec<Type>> {
|
pub fn get_parameters(content: &[MdContent]) -> Option<Vec<Type>> {
|
||||||
let mut it = content
|
let mut it = content
|
|
@ -1,6 +1,4 @@
|
||||||
use md_parser::MdContent;
|
use crate::{md_parser::MdContent, parser::{ReturnType, object_types::get_object_types, ReturnTypeParameter, types::Type}};
|
||||||
|
|
||||||
use crate::{object_types::get_object_types, types::Type, ReturnType, ReturnTypeParameter};
|
|
||||||
|
|
||||||
pub fn get_return_type(content: &[MdContent]) -> Option<ReturnType> {
|
pub fn get_return_type(content: &[MdContent]) -> Option<ReturnType> {
|
||||||
let table = content
|
let table = content
|
|
@ -1,7 +1,6 @@
|
||||||
use md_parser::MdContent;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::util;
|
use crate::{md_parser::MdContent, parser::util};
|
||||||
|
|
||||||
pub fn get_group_url(content: &[MdContent]) -> String {
|
pub fn get_group_url(content: &[MdContent]) -> String {
|
||||||
let row = util::find_content_contains(content, "API methods are under")
|
let row = util::find_content_contains(content, "API methods are under")
|
5696
qbittorrent-web-api-gen/src/parser/groups.txt
Normal file
5696
qbittorrent-web-api-gen/src/parser/groups.txt
Normal file
File diff suppressed because one or more lines are too long
|
@ -4,9 +4,10 @@ pub mod types;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
use group_parser::parse_groups;
|
use group_parser::parse_groups;
|
||||||
use md_parser::{self, TokenTree};
|
|
||||||
use types::Type;
|
use types::Type;
|
||||||
|
|
||||||
|
use crate::md_parser::{self, TokenTree};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ApiGroup {
|
pub struct ApiGroup {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
@ -66,7 +67,7 @@ mod tests {
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
fn parse() -> TokenTree {
|
fn parse() -> TokenTree {
|
||||||
let content = include_str!("api-4_1.md");
|
let content = include_str!("../../api-4_1.md");
|
||||||
let md_tree = md_parser::TokenTreeFactory::create(content);
|
let md_tree = md_parser::TokenTreeFactory::create(content);
|
||||||
|
|
||||||
let output = format!("{:#?}", md_tree);
|
let output = format!("{:#?}", md_tree);
|
|
@ -1,8 +1,8 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use md_parser::MdContent;
|
use crate::{md_parser::MdContent, parser::types::TypeDescriptions};
|
||||||
|
|
||||||
use crate::types::{TypeDescription, TypeDescriptions};
|
use super::types::TypeDescription;
|
||||||
|
|
||||||
pub fn get_object_types(content: &[MdContent]) -> HashMap<String, TypeDescription> {
|
pub fn get_object_types(content: &[MdContent]) -> HashMap<String, TypeDescription> {
|
||||||
let mut output = HashMap::new();
|
let mut output = HashMap::new();
|
|
@ -1,4 +1,4 @@
|
||||||
use md_parser::MdContent;
|
use crate::md_parser::MdContent;
|
||||||
|
|
||||||
pub fn find_content_starts_with(content: &[MdContent], starts_with: &str) -> Option<String> {
|
pub fn find_content_starts_with(content: &[MdContent], starts_with: &str) -> Option<String> {
|
||||||
content.iter().find_map(|row| match row {
|
content.iter().find_map(|row| match row {
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
const PASSWORD: &str = "adminadmin";
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
const PASSWORD: &str = "adminadmin";
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
const PASSWORD: &str = "adminadmin";
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
const PASSWORD: &str = "adminadmin";
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
const PASSWORD: &str = "adminadmin";
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
const PASSWORD: &str = "adminadmin";
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
const PASSWORD: &str = "adminadmin";
|
13793
qbittorrent-web-api-gen/token_tree.txt
Normal file
13793
qbittorrent-web-api-gen/token_tree.txt
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
||||||
use api_gen::QBittorrentApiGen;
|
use qbittorrent_web_api_gen::QBittorrentApiGen;
|
||||||
|
|
||||||
#[derive(QBittorrentApiGen)]
|
#[derive(QBittorrentApiGen)]
|
||||||
pub struct Api;
|
pub struct Api;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user