aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/display.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-09 09:19:37 +0100
committerAleksey Kladov <[email protected]>2020-07-09 09:19:37 +0100
commite7c47eb7f599da93f64c5a8d4f8e83ddd3fa1baa (patch)
treed52c87b544e9946d6e2d0ca307cf34d73dc1f635 /crates/ra_ide/src/display.rs
parent3a26752c665111499b01c34b90aadd94afcd8b28 (diff)
Streamline
Diffstat (limited to 'crates/ra_ide/src/display.rs')
-rw-r--r--crates/ra_ide/src/display.rs29
1 files changed, 0 insertions, 29 deletions
diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs
index 827c094e7..70d2a2dd1 100644
--- a/crates/ra_ide/src/display.rs
+++ b/crates/ra_ide/src/display.rs
@@ -6,13 +6,10 @@ mod navigation_target;
6mod structure; 6mod structure;
7mod short_label; 7mod short_label;
8 8
9use std::fmt::Display;
10
11use ra_syntax::{ 9use ra_syntax::{
12 ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner}, 10 ast::{self, AstNode, AttrsOwner, NameOwner, TypeParamsOwner},
13 SyntaxKind::{ATTR, COMMENT}, 11 SyntaxKind::{ATTR, COMMENT},
14}; 12};
15use stdx::format_to;
16 13
17pub use function_signature::FunctionSignature; 14pub use function_signature::FunctionSignature;
18pub use navigation_target::NavigationTarget; 15pub use navigation_target::NavigationTarget;
@@ -69,29 +66,3 @@ pub(crate) fn macro_label(node: &ast::MacroCall) -> String {
69 let vis = if node.has_atom_attr("macro_export") { "#[macro_export]\n" } else { "" }; 66 let vis = if node.has_atom_attr("macro_export") { "#[macro_export]\n" } else { "" };
70 format!("{}macro_rules! {}", vis, name) 67 format!("{}macro_rules! {}", vis, name)
71} 68}
72
73pub(crate) fn rust_code_markup(code: &impl Display) -> String {
74 rust_code_markup_with_doc(code, None, None)
75}
76
77pub(crate) fn rust_code_markup_with_doc(
78 code: &impl Display,
79 doc: Option<&str>,
80 mod_path: Option<&str>,
81) -> String {
82 let mut buf = String::new();
83
84 if let Some(mod_path) = mod_path {
85 if !mod_path.is_empty() {
86 format_to!(buf, "```rust\n{}\n```\n\n", mod_path);
87 }
88 }
89 format_to!(buf, "```rust\n{}\n```", code);
90
91 if let Some(doc) = doc {
92 format_to!(buf, "\n___");
93 format_to!(buf, "\n\n{}", doc);
94 }
95
96 buf
97}