Skip to content

Commit 6ecd445

Browse files
authored
Merge pull request #30 from magurotuna/doc_hidden
Add meta word `doc_hidden` to snippet attribute
2 parents 87bf5d6 + ecdd23b commit 6ecd445

File tree

3 files changed

+184
-35
lines changed

3 files changed

+184
-35
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ fn gcd_list(list: &[u64]) -> u64 {
7979
#[snippet(prefix = "use std::str::FromStr;")]
8080
fn foo() {}
8181

82+
// By default, doc comments associated with items will be output with the snippet.
83+
#[snippet]
84+
/// This is a document!
85+
fn documented() {
86+
//! Inner document also works.
87+
}
88+
89+
// If you want it to be hidden, append `doc_hidden` keyword.
90+
#[snippet(doc_hidden, prefix = "use std::collections::HashMap;")]
91+
/// This is a doc comment for `bar`.
92+
/// Since `doc_hidden` is specified, it won't be present in the snippet.
93+
fn bar() {
94+
//! And this is also a doc comment for `bar`, which will be removed.
95+
}
96+
8297
#[test]
8398
fn test_gcd() {
8499
assert_eq!(gcd(57, 3), 3);
@@ -105,6 +120,16 @@ snippet foo
105120
use std::str::FromStr;
106121
fn foo() {}
107122
123+
snippet documented
124+
/// This is a document!
125+
fn documented() {
126+
//! Inner document also works.
127+
}
128+
129+
snippet bar
130+
use std::collections::HashMap;
131+
fn bar() {}
132+
108133
snippet gcd
109134
fn gcd(a: u64, b: u64) -> u64 {
110135
if b == 0 {
@@ -156,4 +181,4 @@ My snippets [here](https://github.com/hatoo/competitive-rust-snippets.git).
156181
* Ultisnips
157182

158183
You can specify output format via `-t` option.
159-
See `cargo snippet -h`.
184+
See `cargo snippet -h`.

0 commit comments

Comments
 (0)