@@ -16,7 +16,6 @@ use ide_db::helpers::{
16
16
insert_use:: { InsertUseConfig , MergeBehavior } ,
17
17
SnippetCap ,
18
18
} ;
19
- use itertools:: Itertools ;
20
19
use lsp_types:: { ClientCapabilities , MarkupKind } ;
21
20
use project_model:: { CargoConfig , ProjectJson , ProjectJsonData , ProjectManifest , RustcSource } ;
22
21
use rustc_hash:: FxHashSet ;
@@ -98,13 +97,15 @@ config_data! {
98
97
diagnostics_enableExperimental: bool = "true" ,
99
98
/// List of rust-analyzer diagnostics to disable.
100
99
diagnostics_disabled: FxHashSet <String > = "[]" ,
101
- /// List of warnings that should be displayed with info severity.\n\nThe
102
- /// warnings will be indicated by a blue squiggly underline in code and
103
- /// a blue icon in the `Problems Panel`.
100
+ /// List of warnings that should be displayed with info severity.
101
+ ///
102
+ /// The warnings will be indicated by a blue squiggly underline in code
103
+ /// and a blue icon in the `Problems Panel`.
104
104
diagnostics_warningsAsHint: Vec <String > = "[]" ,
105
- /// List of warnings that should be displayed with hint severity.\n\nThe
106
- /// warnings will be indicated by faded text or three dots in code and
107
- /// will not show up in the `Problems Panel`.
105
+ /// List of warnings that should be displayed with hint severity.
106
+ ///
107
+ /// The warnings will be indicated by faded text or three dots in code
108
+ /// and will not show up in the `Problems Panel`.
108
109
diagnostics_warningsAsInfo: Vec <String > = "[]" ,
109
110
110
111
/// Controls file watching implementation.
@@ -158,7 +159,9 @@ config_data! {
158
159
lens_references: bool = "false" ,
159
160
160
161
/// Disable project auto-discovery in favor of explicitly specified set
161
- /// of projects.\n\nElements must be paths pointing to `Cargo.toml`,
162
+ /// of projects.
163
+ ///
164
+ /// Elements must be paths pointing to `Cargo.toml`,
162
165
/// `rust-project.json`, or JSON objects in `rust-project.json` format.
163
166
linkedProjects: Vec <ManifestOrProjectJson > = "[]" ,
164
167
@@ -177,7 +180,7 @@ config_data! {
177
180
/// Command to be executed instead of 'cargo' for runnables.
178
181
runnables_overrideCargo: Option <String > = "null" ,
179
182
/// Additional arguments to be passed to cargo for runnables such as
180
- /// tests or binaries.\nFor example, it may be `--release`.
183
+ /// tests or binaries. For example, it may be `--release`.
181
184
runnables_cargoExtraArgs: Vec <String > = "[]" ,
182
185
183
186
/// Path to the Cargo.toml of the rust compiler workspace, for usage in rustc_private
@@ -765,7 +768,8 @@ fn schema(fields: &[(&'static str, &'static str, &[&str], &str)]) -> serde_json:
765
768
}
766
769
767
770
fn field_props ( field : & str , ty : & str , doc : & [ & str ] , default : & str ) -> serde_json:: Value {
768
- let doc = doc. iter ( ) . map ( |it| it. trim ( ) ) . join ( " " ) ;
771
+ let doc = doc_comment_to_string ( doc) ;
772
+ let doc = doc. trim_end_matches ( '\n' ) ;
769
773
assert ! (
770
774
doc. ends_with( '.' ) && doc. starts_with( char :: is_uppercase) ,
771
775
"bad docs for {}: {:?}" ,
@@ -854,11 +858,16 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
854
858
. iter ( )
855
859
. map ( |( field, _ty, doc, default) | {
856
860
let name = format ! ( "rust-analyzer.{}" , field. replace( "_" , "." ) ) ;
857
- format ! ( "[[{}]]{} (default: `{}`)::\n {}\n " , name, name, default , doc. join( " " ) )
861
+ let doc = doc_comment_to_string ( * doc) ;
862
+ format ! ( "[[{}]]{} (default: `{}`)::\n +\n --\n {}--\n " , name, name, default , doc)
858
863
} )
859
864
. collect :: < String > ( )
860
865
}
861
866
867
+ fn doc_comment_to_string ( doc : & [ & str ] ) -> String {
868
+ doc. iter ( ) . map ( |it| it. strip_prefix ( ' ' ) . unwrap_or ( it) ) . map ( |it| format ! ( "{}\n " , it) ) . collect ( )
869
+ }
870
+
862
871
#[ cfg( test) ]
863
872
mod tests {
864
873
use std:: fs;
@@ -901,13 +910,8 @@ mod tests {
901
910
#[ test]
902
911
fn generate_config_documentation ( ) {
903
912
let docs_path = project_root ( ) . join ( "docs/user/generated_config.adoc" ) ;
904
- let current = fs:: read_to_string ( & docs_path) . unwrap ( ) ;
905
913
let expected = ConfigData :: manual ( ) ;
906
-
907
- if remove_ws ( & current) != remove_ws ( & expected) {
908
- fs:: write ( & docs_path, expected) . unwrap ( ) ;
909
- panic ! ( "updated config manual" ) ;
910
- }
914
+ ensure_file_contents ( & docs_path, & expected) ;
911
915
}
912
916
913
917
fn remove_ws ( text : & str ) -> String {
0 commit comments