Skip to content

Commit a8bf5e3

Browse files
committed
---
yaml --- r: 14683 b: refs/heads/try c: 29ac3c8 h: refs/heads/master i: 14681: b4aa8f1 14679: 7b5e03c v: v3
1 parent dcad716 commit a8bf5e3

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: a4ff220133128f7d4467f3919db579e7b50850c4
5+
refs/heads/try: 29ac3c811d0235b51e17519d7b212287ca27e626
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustdoc/doc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,14 @@ Fields:
131131
132132
* kind - The type of thing being indexed, e.g. 'Module'
133133
* name - The name of the thing
134+
* brief - The brief description
134135
* link - A format-specific string representing the link target
135136
136137
"]
137138
type index_entry = {
138139
kind: str,
139140
name: str,
141+
brief: option<str>,
140142
link: str
141143
};
142144

branches/try/src/rustdoc/markdown_index_pass.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ fn item_to_entry(
6363
{
6464
kind: markdown_pass::header_kind(doc),
6565
name: markdown_pass::header_name(doc),
66+
brief: doc.brief(),
6667
link: link
6768
}
6869
}
@@ -100,11 +101,13 @@ fn should_index_mod_contents() {
100101
assert option::get(doc.cratemod().index).entries[0] == {
101102
kind: "Module",
102103
name: "a",
104+
brief: none,
103105
link: "#module-a"
104106
};
105107
assert option::get(doc.cratemod().index).entries[1] == {
106108
kind: "Function",
107109
name: "b",
110+
brief: none,
108111
link: "#function-b"
109112
};
110113
}
@@ -118,15 +121,26 @@ fn should_index_mod_contents_multi_page() {
118121
assert option::get(doc.cratemod().index).entries[0] == {
119122
kind: "Module",
120123
name: "a",
124+
brief: none,
121125
link: "a.html"
122126
};
123127
assert option::get(doc.cratemod().index).entries[1] == {
124128
kind: "Function",
125129
name: "b",
130+
brief: none,
126131
link: "#function-b"
127132
};
128133
}
129134

135+
#[test]
136+
fn should_add_brief_desc_to_index() {
137+
let doc = test::mk_doc(
138+
config::doc_per_mod,
139+
"#[doc(brief = \"test\")] mod a { }"
140+
);
141+
assert option::get(doc.cratemod().index).entries[0].brief == some("test");
142+
}
143+
130144
#[cfg(test)]
131145
mod test {
132146
fn mk_doc(output_style: config::output_style, source: str) -> doc::doc {
@@ -136,6 +150,7 @@ mod test {
136150
with config::default_config("whatever")
137151
};
138152
let doc = extract::from_srv(srv, "");
153+
let doc = attr_pass::mk_pass().f(srv, doc);
139154
let doc = path_pass::mk_pass().f(srv, doc);
140155
run(srv, doc, config)
141156
}

branches/try/src/rustdoc/markdown_pass.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,12 @@ fn write_index(ctxt: ctxt, index: doc::index) {
283283
for entry in index.entries {
284284
let header = header_text_(entry.kind, entry.name);
285285
let id = entry.link;
286-
ctxt.w.write_line(#fmt("* [%s](%s)", header, id));
286+
if option::is_some(entry.brief) {
287+
ctxt.w.write_line(#fmt("* [%s](%s) - %s",
288+
header, id, option::get(entry.brief)));
289+
} else {
290+
ctxt.w.write_line(#fmt("* [%s](%s)", header, id));
291+
}
287292
}
288293
ctxt.w.write_line("");
289294
}
@@ -298,6 +303,12 @@ fn should_write_index() {
298303
);
299304
}
300305

306+
#[test]
307+
fn should_write_index_brief() {
308+
let markdown = test::render("#[doc(brief = \"test\")] mod a { }");
309+
assert str::contains(markdown, "(#module-a) - test\n");
310+
}
311+
301312
#[test]
302313
fn should_not_write_index_if_no_entries() {
303314
let markdown = test::render("");

0 commit comments

Comments
 (0)