Add option for dmdoc to always use typepath names (#149)

Closes #94.
This commit is contained in:
spookydonut 2020-01-22 11:03:47 +08:00 committed by Tad Hardesty
parent 8f1fda64ee
commit 70bb8b682d
3 changed files with 28 additions and 8 deletions

View file

@ -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

View file

@ -218,14 +218,22 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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;

View file

@ -16,6 +16,7 @@ pub struct Config {
display: WarningDisplay,
pub langserver: Langserver,
diagnostics: HashMap<String, WarningLevel>,
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 {