Skip to content

Commit 192a490

Browse files
committed
---
yaml --- r: 11471 b: refs/heads/master c: 396540f h: refs/heads/master i: 11469: c58c61c 11467: b90840f 11463: 52c8d02 11455: fae8814 v: v3
1 parent c75e9b2 commit 192a490

File tree

6 files changed

+43
-15
lines changed

6 files changed

+43
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9b009ea23d761d4cd7c0297289c6d3bb10c7cca7
2+
refs/heads/master: 396540f19d37e4d8ad87a8d9db179c6b05263aff
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustdoc/doc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ type itemdoc = {
2727
path: [str],
2828
brief: option<str>,
2929
desc: option<str>,
30+
// Indicates that this node is a reexport of a different item
31+
reexport: bool
3032
};
3133

3234
type moddoc = {

trunk/src/rustdoc/extract.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ fn mk_itemdoc(id: ast::node_id, name: ast::ident) -> doc::itemdoc {
4040
path: [],
4141
brief: none,
4242
desc: none,
43+
reexport: false
4344
}
4445
}
4546

trunk/src/rustdoc/prune_unexported_pass.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ fn exported_items_from(
7777
}
7878
_ { itemtag }
7979
};
80-
if is_exported(srv, itemtag.name()) {
80+
81+
if itemtag.item().reexport || is_exported(srv, itemtag.name()) {
8182
some(itemtag)
8283
} else {
8384
none
@@ -226,6 +227,21 @@ fn should_prune_unexported_types() {
226227
assert vec::is_empty(doc.topmod.types());
227228
}
228229

230+
#[test]
231+
fn should_not_prune_reexports() {
232+
fn mk_doc(source: str) -> doc::cratedoc {
233+
astsrv::from_str(source) {|srv|
234+
let doc = extract::from_srv(srv, "");
235+
let doc = reexport_pass::mk_pass()(srv, doc);
236+
run(srv, doc)
237+
}
238+
}
239+
let doc = mk_doc("import a::b; \
240+
export b; \
241+
mod a { fn b() { } }");
242+
assert vec::is_not_empty(doc.topmod.fns());
243+
}
244+
229245
#[cfg(test)]
230246
mod test {
231247
fn mk_doc(source: str) -> doc::cratedoc {

trunk/src/rustdoc/reexport_pass.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,70 +212,71 @@ fn merge_reexports(
212212
some(name_docs) {
213213
vec::foldl([], name_docs) {|v, name_doc|
214214
let (name, doc) = name_doc;
215-
v + [rename_doc(doc, name)]
215+
v + [reexport_doc(doc, name)]
216216
}
217217
}
218218
none { [] }
219219
}
220220
}
221221

222-
fn rename_doc(doc: doc::itemtag, name: str) -> doc::itemtag {
222+
fn reexport_doc(doc: doc::itemtag, name: str) -> doc::itemtag {
223223
alt doc {
224224
doc::modtag(doc @ {item, _}) {
225225
doc::modtag({
226-
item: rename(item, name)
226+
item: reexport(item, name)
227227
with doc
228228
})
229229
}
230230
doc::nmodtag(_) { fail }
231231
doc::consttag(doc @ {item, _}) {
232232
doc::consttag({
233-
item: rename(item, name)
233+
item: reexport(item, name)
234234
with doc
235235
})
236236
}
237237
doc::fntag(doc @ {item, _}) {
238238
doc::fntag({
239-
item: rename(item, name)
239+
item: reexport(item, name)
240240
with doc
241241
})
242242
}
243243
doc::enumtag(doc @ {item, _}) {
244244
doc::enumtag({
245-
item: rename(item, name)
245+
item: reexport(item, name)
246246
with doc
247247
})
248248
}
249249
doc::restag(doc @ {item, _}) {
250250
doc::restag({
251-
item: rename(item, name)
251+
item: reexport(item, name)
252252
with doc
253253
})
254254
}
255255
doc::ifacetag(doc @ {item, _}) {
256256
doc::ifacetag({
257-
item: rename(item, name)
257+
item: reexport(item, name)
258258
with doc
259259
})
260260
}
261261
doc::impltag(doc @ {item, _}) {
262262
doc::impltag({
263-
item: rename(item, name)
263+
item: reexport(item, name)
264264
with doc
265265
})
266266
}
267267
doc::tytag(doc @ {item, _}) {
268268
doc::tytag({
269-
item: rename(item, name)
269+
item: reexport(item, name)
270270
with doc
271271
})
272272
}
273273
}
274274
}
275275

276-
fn rename(doc: doc::itemdoc, name: str) -> doc::itemdoc {
276+
fn reexport(doc: doc::itemdoc, name: str) -> doc::itemdoc {
277277
{
278-
name: name
278+
name: name,
279+
reexport: true
279280
with doc
280281
}
281282
}
@@ -289,6 +290,14 @@ fn should_duplicate_reexported_items() {
289290
assert doc.topmod.mods()[1].fns()[0].name() == "b";
290291
}
291292

293+
#[test]
294+
fn should_mark_reepxorts_as_such() {
295+
let source = "mod a { export b; fn b() { } } \
296+
mod c { import a::b; export b; }";
297+
let doc = test::mk_doc(source);
298+
assert doc.topmod.mods()[1].fns()[0].item.reexport == true;
299+
}
300+
292301
#[test]
293302
fn should_duplicate_multiple_reexported_items() {
294303
let source = "mod a { \

trunk/src/rustdoc/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ fn run(source_file: str) {
9797
astsrv::from_file(source_file) {|srv|
9898
let doc = extract::from_srv(srv, default_name);
9999
run_passes(srv, doc, [
100+
reexport_pass::mk_pass(),
100101
prune_unexported_pass::mk_pass(),
101102
tystr_pass::mk_pass(),
102103
path_pass::mk_pass(),
@@ -107,7 +108,6 @@ fn run(source_file: str) {
107108
desc_to_brief_pass::mk_pass(),
108109
trim_pass::mk_pass(),
109110
unindent_pass::mk_pass(),
110-
reexport_pass::mk_pass(),
111111
sort_item_name_pass::mk_pass(),
112112
sort_item_type_pass::mk_pass(),
113113
markdown_pass::mk_pass {|f| f(std::io:: stdout()) }

0 commit comments

Comments
 (0)