start reworking annotate
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
craneLib = (crane.mkLib pkgs).overrideToolchain (
|
craneLib = (crane.mkLib pkgs).overrideToolchain (
|
||||||
p:
|
p:
|
||||||
p.rust-bin.stable.latest.default.override {
|
p.rust-bin.nightly.latest.default.override {
|
||||||
extensions = [ "llvm-tools-preview" ];
|
extensions = [ "llvm-tools-preview" ];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -150,6 +150,7 @@
|
|||||||
cargo-llvm-cov
|
cargo-llvm-cov
|
||||||
cargo-audit
|
cargo-audit
|
||||||
cargo-tarpaulin
|
cargo-tarpaulin
|
||||||
|
cargo-udeps
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
use super::{models::ModelsConfig, Module, ModulesContext};
|
use super::{discovery::DiscoveredSchema, models::ModelsConfig, Module, ModulesContext};
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
|
use minijinja::Environment;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
const HEADER: &str = r#"== Schema Information"#;
|
||||||
|
const COMMENTHEAD: &str = r#"/*"#;
|
||||||
|
const COMMENTBODY: &str = r#" *"#;
|
||||||
|
const COMMENTTAIL: &str = r#"*/"#;
|
||||||
|
const SETTINGSDELIMITER: &str = r#"```"#;
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct AnnotateConfig {
|
pub struct AnnotateConfig {
|
||||||
@@ -14,10 +20,7 @@ impl Default for AnnotateConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct AnnotateModule {
|
pub struct AnnotateModule;
|
||||||
pub models: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Module for AnnotateModule {
|
impl Module for AnnotateModule {
|
||||||
fn init(&mut self, ctx: &mut ModulesContext) -> Result<()> {
|
fn init(&mut self, ctx: &mut ModulesContext) -> Result<()> {
|
||||||
@@ -28,15 +31,23 @@ impl Module for AnnotateModule {
|
|||||||
async fn validate(&mut self, ctx: &mut ModulesContext) -> Result<bool> {
|
async fn validate(&mut self, ctx: &mut ModulesContext) -> Result<bool> {
|
||||||
let map = ctx.get_anymap();
|
let map = ctx.get_anymap();
|
||||||
|
|
||||||
if let (Some(config), Some(models_config)) =
|
if let Some(config) = map.get::<AnnotateConfig>() {
|
||||||
(map.get::<AnnotateConfig>(), map.get::<ModelsConfig>())
|
|
||||||
{
|
|
||||||
Ok(config.enable)
|
Ok(config.enable)
|
||||||
} else {
|
} else {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async fn execute(&mut self, ctx: &mut ModulesContext) -> Result<()> {
|
async fn execute(&mut self, ctx: &mut ModulesContext) -> Result<()> {
|
||||||
Ok(())
|
let map = ctx.get_anymap();
|
||||||
|
|
||||||
|
if let (Some(config), Some(environment), Some(schema)) = (
|
||||||
|
map.get::<AnnotateConfig>(),
|
||||||
|
map.get::<Environment<'static>>(),
|
||||||
|
map.get::<DiscoveredSchema>(),
|
||||||
|
) {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ impl Module for DiscoveryModule {
|
|||||||
if let (Some(config), Some(_)) = (map.get::<DiscoveryConfig>(), map.get::<DatabaseUrl>()) {
|
if let (Some(config), Some(_)) = (map.get::<DiscoveryConfig>(), map.get::<DatabaseUrl>()) {
|
||||||
Ok(config.enable)
|
Ok(config.enable)
|
||||||
} else {
|
} else {
|
||||||
// One or both keys are missing
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user