aboutsummaryrefslogtreecommitdiff
path: root/docs/dev
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/lsp-extensions.md12
-rw-r--r--docs/dev/style.md29
2 files changed, 40 insertions, 1 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index f0f981802..8fcd72d5d 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -1,5 +1,5 @@
1<!--- 1<!---
2lsp_ext.rs hash: 28a9d5a24b7ca396 2lsp_ext.rs hash: 6e57fc1b345b00e9
3 3
4If you need to change the above hash to make the test pass, please check if you 4If you need to change the above hash to make the test pass, please check if you
5need to adjust this doc as well and ping this issue: 5need to adjust this doc as well and ping this issue:
@@ -486,6 +486,16 @@ Primarily for debugging, but very useful for all people working on rust-analyzer
486Returns a textual representation of the HIR of the function containing the cursor. 486Returns a textual representation of the HIR of the function containing the cursor.
487For debugging or when working on rust-analyzer itself. 487For debugging or when working on rust-analyzer itself.
488 488
489## View Crate Graph
490
491**Method:** `rust-analyzer/viewCrateGraph`
492
493**Request:** `null`
494
495**Response:** `string`
496
497Renders rust-analyzer's crate graph as an SVG image.
498
489## Expand Macro 499## Expand Macro
490 500
491**Method:** `rust-analyzer/expandMacro` 501**Method:** `rust-analyzer/expandMacro`
diff --git a/docs/dev/style.md b/docs/dev/style.md
index d24a5952e..f22b69768 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -636,6 +636,10 @@ use crate::{}
636 636
637// Finally, parent and child modules, but prefer `use crate::`. 637// Finally, parent and child modules, but prefer `use crate::`.
638use super::{} 638use super::{}
639
640// Re-exports are treated as item definitions rather than imports, so they go
641// after imports and modules. Use them sparingly.
642pub use crate::x::Z;
639``` 643```
640 644
641**Rationale:** consistency. 645**Rationale:** consistency.
@@ -694,6 +698,9 @@ Avoid local `use MyEnum::*` imports.
694Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`. 698Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`.
695**Rationale:** consistency, this is the style which works in all cases. 699**Rationale:** consistency, this is the style which works in all cases.
696 700
701By default, avoid re-exports.
702**Rationale:** for non-library code, re-exports introduce two ways to use something and allow for inconsistency.
703
697## Order of Items 704## Order of Items
698 705
699Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. 706Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on.
@@ -944,6 +951,28 @@ match p.current() {
944 951
945## Documentation 952## Documentation
946 953
954Style inline code comments as proper sentences.
955Start with a capital letter, end with a dot.
956
957```rust
958// GOOD
959
960// Only simple single segment paths are allowed.
961MergeBehavior::Last => {
962 tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1)
963}
964
965// BAD
966
967// only simple single segment paths are allowed
968MergeBehavior::Last => {
969 tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1)
970}
971```
972
973**Rationale:** writing a sentence (or maybe even a paragraph) rather just "a comment" creates a more appropriate frame of mind.
974It tricks you into writing down more of the context you keep in your head while coding.
975
947For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines. 976For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines.
948If the line is too long, you want to split the sentence in two :-) 977If the line is too long, you want to split the sentence in two :-)
949 978