nginx_lint_common/
docs.rs

1//! Rule documentation types for nginx-lint
2//!
3//! This module provides type definitions for lint rule documentation.
4
5/// Documentation for a lint rule (static version for native rules)
6pub struct RuleDoc {
7    /// Rule name (e.g., "server-tokens-enabled")
8    pub name: &'static str,
9    /// Category (e.g., "security")
10    pub category: &'static str,
11    /// Short description
12    pub description: &'static str,
13    /// Severity level
14    pub severity: &'static str,
15    /// Why this rule exists
16    pub why: &'static str,
17    /// Example of bad configuration
18    pub bad_example: &'static str,
19    /// Example of good configuration
20    pub good_example: &'static str,
21    /// References (URLs, documentation links)
22    pub references: &'static [&'static str],
23}
24
25/// Documentation for a lint rule (owned version, supports plugins)
26#[derive(Debug, Clone)]
27pub struct RuleDocOwned {
28    /// Rule name (e.g., "server-tokens-enabled")
29    pub name: String,
30    /// Category (e.g., "security")
31    pub category: String,
32    /// Short description
33    pub description: String,
34    /// Severity level
35    pub severity: String,
36    /// Why this rule exists
37    pub why: String,
38    /// Example of bad configuration
39    pub bad_example: String,
40    /// Example of good configuration
41    pub good_example: String,
42    /// References (URLs, documentation links)
43    pub references: Vec<String>,
44    /// Whether this is from a plugin
45    pub is_plugin: bool,
46}
47
48impl From<&RuleDoc> for RuleDocOwned {
49    fn from(doc: &RuleDoc) -> Self {
50        Self {
51            name: doc.name.to_string(),
52            category: doc.category.to_string(),
53            description: doc.description.to_string(),
54            severity: doc.severity.to_string(),
55            why: doc.why.to_string(),
56            bad_example: doc.bad_example.to_string(),
57            good_example: doc.good_example.to_string(),
58            references: doc.references.iter().map(|s| s.to_string()).collect(),
59            is_plugin: false,
60        }
61    }
62}