From 4e74a174c5bddd9196e4590bb407a59029341313 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 2 Aug 2025 15:21:03 +0100 Subject: [PATCH] Enable the doc_markdown Clippy lint in libloot --- clippy.toml | 1 + src/database/mod.rs | 2 +- src/error.rs | 4 ++-- src/game.rs | 8 ++++---- src/lib.rs | 1 - src/metadata/error.rs | 2 +- src/metadata/file.rs | 6 +++--- src/metadata/group.rs | 4 ++-- src/metadata/location.rs | 2 +- src/metadata/message.rs | 22 ++++++++++------------ src/metadata/plugin_cleaning_data.rs | 7 +++---- src/metadata/plugin_metadata.rs | 9 ++++----- src/metadata/tag.rs | 2 +- src/metadata/yaml/parse.rs | 4 ++-- src/sorting/vertex.rs | 2 +- 15 files changed, 36 insertions(+), 40 deletions(-) create mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 00000000..49ee3823 --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +doc-valid-idents = ["CommonMark", "FormIDs", "OpenMW", ".."] diff --git a/src/database/mod.rs b/src/database/mod.rs index 24661ecd..d907d9cd 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -207,7 +207,7 @@ impl Database { /// user metadata involved while minimising the amount of masterlist /// metadata involved. It's not the path involving the fewest groups. /// - /// If there is no path between the two groups, the returned [Vec] will be + /// If there is no path between the two groups, the returned `Vec` will be /// empty. pub fn groups_path( &self, diff --git a/src/error.rs b/src/error.rs index e25a8580..a64c9217 100644 --- a/src/error.rs +++ b/src/error.rs @@ -11,7 +11,7 @@ use crate::sorting::error::{ }; use crate::{Vertex, escape_ascii}; -/// Represents an error that occurred while trying to create a [Game][crate::Game]. +/// Represents an error that occurred while trying to create a [`Game`]. #[derive(Debug)] #[non_exhaustive] pub enum GameHandleCreationError { @@ -71,7 +71,7 @@ impl From for LoadOrderError { } } -/// Indicates that the Database's RwLock wrapper has been poisoned and as such +/// Indicates that the Database's `RwLock` wrapper has been poisoned and as such /// the Database may be in an invalid state. #[derive(Clone, Copy, Default, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct DatabaseLockPoisonError; diff --git a/src/game.rs b/src/game.rs index 596bae07..bb6970e9 100644 --- a/src/game.rs +++ b/src/game.rs @@ -158,7 +158,7 @@ impl Game { /// /// This function will attempt to look up the game's local data path, which /// may fail in some situations (e.g. when running libloot natively on Linux - /// for a game other than Morrowind or OpenMW). [Game::with_local_path] + /// for a game other than Morrowind or OpenMW). [`Game::with_local_path`] /// can be used to provide the local path instead. pub fn new(game_type: GameType, game_path: &Path) -> Result { logging::info!( @@ -415,8 +415,8 @@ impl Game { Ok(()) } - /// Clears the plugins loaded by previous calls to [Game::load_plugins] or - /// [Game::load_plugin_headers]. + /// Clears the plugins loaded by previous calls to [`Game::load_plugins`] or + /// [`Game::load_plugin_headers`]. pub fn clear_loaded_plugins(&mut self) { self.cache.clear_plugins(); } @@ -441,7 +441,7 @@ impl Game { /// /// The order in which plugins are listed in `plugin_filenames` is used as /// their current load order. All given plugins must have been already been - /// loaded using [Game::load_plugins] or [Game::load_plugin_headers]. + /// loaded using [`Game::load_plugins`] or [`Game::load_plugin_headers`]. pub fn sort_plugins(&self, plugin_names: &[&str]) -> Result, SortPluginsError> { let plugins = plugin_names .iter() diff --git a/src/lib.rs b/src/lib.rs index 69d0c1e5..90cca294 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ // Allow some lints that are denied at the workspace level. #![allow( - clippy::doc_markdown, clippy::filetype_is_file, clippy::must_use_candidate, clippy::missing_errors_doc, diff --git a/src/metadata/error.rs b/src/metadata/error.rs index b7f26b89..058f11f9 100644 --- a/src/metadata/error.rs +++ b/src/metadata/error.rs @@ -9,7 +9,7 @@ use crate::{escape_ascii, metadata::MessageContent}; use super::yaml::{YamlObjectType, to_unmarked_yaml}; /// Represents an error that occurred when validating a collection of -/// [MessageContent] objects. +/// [`MessageContent`] objects. #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct MultilingualMessageContentsError; diff --git a/src/metadata/file.rs b/src/metadata/file.rs index e33d10f2..baec1192 100644 --- a/src/metadata/file.rs +++ b/src/metadata/file.rs @@ -25,7 +25,7 @@ pub struct File { } impl File { - /// Construct a [File] with the given name. This can also be a relative path. + /// Create a value with the given name. This can also be a relative path. #[must_use] pub fn new(name: String) -> Self { Self { @@ -51,7 +51,7 @@ impl File { /// Set the detail message content, which may be appended to any messages /// generated for this file. If multilingual, one language must be - /// [MessageContent::DEFAULT_LANGUAGE]. + /// [`MessageContent::DEFAULT_LANGUAGE`]. pub fn with_detail( mut self, detail: Vec, @@ -103,7 +103,7 @@ impl File { pub struct Filename(Box); impl Filename { - /// Construct a Filename using the given string. + /// Create a value using the given string. #[must_use] pub fn new(s: String) -> Self { Filename(s.into()) diff --git a/src/metadata/group.rs b/src/metadata/group.rs index 02d09d86..af4e5dfd 100644 --- a/src/metadata/group.rs +++ b/src/metadata/group.rs @@ -20,7 +20,7 @@ impl Group { /// The name of the group to which all plugins belong by default. pub const DEFAULT_NAME: &'static str = "default"; - /// Construct a [Group] with the given name. + /// Create a value with the given name. #[must_use] pub fn new(name: String) -> Self { Self { @@ -60,7 +60,7 @@ impl Group { } impl std::default::Default for Group { - /// Construct a Group with the default name and an empty set of groups to + /// Create a value with the default name and an empty set of groups to /// load after. fn default() -> Self { Self { diff --git a/src/metadata/location.rs b/src/metadata/location.rs index 86348ddf..380b32e5 100644 --- a/src/metadata/location.rs +++ b/src/metadata/location.rs @@ -13,7 +13,7 @@ pub struct Location { } impl Location { - /// Construct a [Location] with the given URL. + /// Create a value with the given URL. #[must_use] pub fn new(url: String) -> Self { Location { diff --git a/src/metadata/message.rs b/src/metadata/message.rs index bbc1024c..0c396b3e 100644 --- a/src/metadata/message.rs +++ b/src/metadata/message.rs @@ -52,8 +52,7 @@ impl MessageContent { /// The code for the default language assumed for message content. pub const DEFAULT_LANGUAGE: &'static str = "en"; - /// Construct a [MessageContent] object with the given text in the default - /// language. + /// Create a value with the given text in the default language. #[must_use] pub fn new(text: String) -> Self { MessageContent { @@ -81,8 +80,7 @@ impl MessageContent { } impl std::default::Default for MessageContent { - /// Construct a [MessageContent] object with an empty message string and the - /// default language. + /// Create a value with an empty message string and the default language. fn default() -> Self { Self { text: Box::default(), @@ -91,8 +89,8 @@ impl std::default::Default for MessageContent { } } -/// Choose a [MessageContent] object from those given in `content` based on the -/// given `language`. +/// Choose a `MessageContent` object from those given in `content` based on +/// the given `language`. /// /// Language strings are expected to have the form /// `[language code]` or `[language code]_[country code]`, where @@ -110,7 +108,7 @@ impl std::default::Default for MessageContent { /// returned. /// * If no matches are found and content in the default language is present, /// that content is returned. -/// * Otherwise, an empty [Option] is returned. +/// * Otherwise, an empty `Option` is returned. pub fn select_message_content<'a>( content: &'a [MessageContent], language: &str, @@ -164,8 +162,8 @@ pub struct Message { } impl Message { - /// Construct a [Message] with the given type and a content string in the - /// language given by [MessageContent::DEFAULT_LANGUAGE]. + /// Create a value with the given type and a content string in the language + /// given by [`MessageContent::DEFAULT_LANGUAGE`]. #[must_use] pub fn new(message_type: MessageType, content: String) -> Self { Self { @@ -175,9 +173,9 @@ impl Message { } } - /// Construct a [Message] with the given type and content. If more than one - /// [MessageContent] object is given, one must use - /// the language given by [MessageContent::DEFAULT_LANGUAGE]. + /// Create a value with the given type and content. If more than one + /// `MessageContent` object is given, one must use + /// the language given by [`MessageContent::DEFAULT_LANGUAGE`]. pub fn multilingual( message_type: MessageType, content: Vec, diff --git a/src/metadata/plugin_cleaning_data.rs b/src/metadata/plugin_cleaning_data.rs index 07cc9c3e..7081f0a6 100644 --- a/src/metadata/plugin_cleaning_data.rs +++ b/src/metadata/plugin_cleaning_data.rs @@ -25,9 +25,8 @@ pub struct PluginCleaningData { } impl PluginCleaningData { - /// Construct a [PluginCleaningData] object with the given CRC and cleaning - /// utility, no detail and the ITM, deleted reference and deleted navmesh - /// counts set to zero. + /// Create a value with the given CRC and cleaning utility, no detail and + /// the ITM, deleted reference and deleted navmesh counts set to zero. #[must_use] pub fn new(crc: u32, cleaning_utility: String) -> Self { Self { @@ -60,7 +59,7 @@ impl PluginCleaningData { /// Set the detail message content, which may be appended to any messages /// generated for this cleaning data. If multilingual, one language must be - /// [MessageContent::DEFAULT_LANGUAGE]. + /// [`MessageContent::DEFAULT_LANGUAGE`]. pub fn with_detail( mut self, detail: Vec, diff --git a/src/metadata/plugin_metadata.rs b/src/metadata/plugin_metadata.rs index 544e73e3..cc403a16 100644 --- a/src/metadata/plugin_metadata.rs +++ b/src/metadata/plugin_metadata.rs @@ -36,8 +36,7 @@ pub struct PluginMetadata { } impl PluginMetadata { - /// Construct a [PluginMetadata] object with no metadata for a plugin with - /// the given filename. + /// Create a value with no metadata for a plugin with the given filename. pub fn new(name: &str) -> Result { Ok(Self { name: PluginName::new(name)?, @@ -59,7 +58,7 @@ impl PluginMetadata { /// Get the plugin's group. /// - /// The [Option] is `None` if no group is explicitly set. + /// The `Option` is `None` if no group is explicitly set. pub fn group(&self) -> Option<&str> { self.group.as_deref() } @@ -155,9 +154,9 @@ impl PluginMetadata { self.locations = locations.into_boxed_slice(); } - /// Merge metadata from the given [PluginMetadata] object into this object. + /// Merge metadata from the given `PluginMetadata` object into this object. /// - /// If an equal metadata object already exists in this PluginMetadata + /// If an equal metadata object already exists in this `PluginMetadata` /// object, it is not duplicated. This object's group is replaced by the /// given object's group if the latter is explicit. pub fn merge_metadata(&mut self, plugin: &PluginMetadata) { diff --git a/src/metadata/tag.rs b/src/metadata/tag.rs index 0b8bb2e7..feb80c19 100644 --- a/src/metadata/tag.rs +++ b/src/metadata/tag.rs @@ -26,7 +26,7 @@ pub struct Tag { } impl Tag { - /// Create a [Tag] suggestion for the given tag name. + /// Create a Bash Tag suggestion for the given tag name. #[must_use] pub fn new(name: String, suggestion: TagSuggestion) -> Self { Self { diff --git a/src/metadata/yaml/parse.rs b/src/metadata/yaml/parse.rs index 83538a3f..1d31efcf 100644 --- a/src/metadata/yaml/parse.rs +++ b/src/metadata/yaml/parse.rs @@ -196,8 +196,8 @@ pub(in crate::metadata) fn parse_condition( } } -/// This is effectively TryFrom<&MarkedYaml>, but implementing it doesn't make -/// MarkedYaml part of the crate's public API. +// This is effectively TryFrom<&MarkedYaml>, but implementing it doesn't make +// MarkedYaml part of the crate's public API. pub(in crate::metadata) trait TryFromYaml: Sized { fn try_from_yaml(value: &MarkedYaml) -> Result; } diff --git a/src/sorting/vertex.rs b/src/sorting/vertex.rs index 0c4b8f38..6886831c 100644 --- a/src/sorting/vertex.rs +++ b/src/sorting/vertex.rs @@ -47,7 +47,7 @@ pub struct Vertex { } impl Vertex { - /// Construct a Vertex with the given name and no out edge. + /// Create a value with the given name and no out edge. #[must_use] pub fn new(name: String) -> Self { Self {