From 70bb8b682d5514ea9d4fcf7ca6fddfb9b943b456 Mon Sep 17 00:00:00 2001 From: spookydonut Date: Wed, 22 Jan 2020 11:03:47 +0800 Subject: [PATCH] Add option for dmdoc to always use typepath names (#149) Closes #94. --- CONFIGURING.md | 6 ++++++ src/dmdoc/main.rs | 24 ++++++++++++++++-------- src/dreammaker/config.rs | 6 ++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/CONFIGURING.md b/CONFIGURING.md index 15d23306..d399a46e 100644 --- a/CONFIGURING.md +++ b/CONFIGURING.md @@ -72,6 +72,12 @@ The `[langserver]` section has the following options: * `dreamchecker` - Set to `true` to run dreamchecker within the language server. +### DM Doc + +The `[dmdoc]` section has the following options: + +* `use_typepath_names` - Set to `true` to have dmdoc use the true typepath name instead of the value of the `name` var for types + ## Example ```toml diff --git a/src/dmdoc/main.rs b/src/dmdoc/main.rs index 0eeeb6fc..6f20a49a 100644 --- a/src/dmdoc/main.rs +++ b/src/dmdoc/main.rs @@ -218,14 +218,22 @@ fn main() -> Result<(), Box> { progress.update(&ty.path); let mut parsed_type = ParsedType::default(); - parsed_type.name = ty - .get() - .vars - .get("name") - .and_then(|v| v.value.constant.as_ref()) - .and_then(|c| c.as_str()) - .unwrap_or("") - .into(); + if context.config().dmdoc.use_typepath_names { + parsed_type.name = ty + .get() + .name + .as_str() + .into(); + } else { + parsed_type.name = ty + .get() + .vars + .get("name") + .and_then(|v| v.value.constant.as_ref()) + .and_then(|c| c.as_str()) + .unwrap_or("") + .into(); + } let mut anything = false; let mut substance = false; diff --git a/src/dreammaker/config.rs b/src/dreammaker/config.rs index 8667ed8c..83490e5a 100644 --- a/src/dreammaker/config.rs +++ b/src/dreammaker/config.rs @@ -16,6 +16,7 @@ pub struct Config { display: WarningDisplay, pub langserver: Langserver, diagnostics: HashMap, + pub dmdoc: DMDoc, } #[derive(Deserialize, Default, Debug, Clone)] @@ -29,6 +30,11 @@ pub struct Langserver { pub dreamchecker: bool, } +#[derive(Deserialize, Default, Debug, Clone)] +pub struct DMDoc { + pub use_typepath_names: bool, +} + #[derive(Debug, Deserialize, Clone, Copy, PartialEq)] #[serde(rename_all(deserialize = "lowercase"))] pub enum WarningLevel {