Skip to content

Commit cde119d

Browse files
authored
Rollup merge of rust-lang#47496 - QuietMisdreavus:rls-doc-include, r=estebank
add documentation from doc(include) to analysis data cc rust-lang#44732 Currently save-analysis only loads docs from plain doc comments and doc attributes. Since `#[doc(include="filename.md")]` doesn't create a plain doc attribute when it loads the file, we need to be sure to pick up this info for the analysis data.
2 parents eb5a461 + 5a350c1 commit cde119d

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/librustc_save_analysis/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,17 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
870870
result.push_str(&val.as_str());
871871
}
872872
result.push('\n');
873+
} else if let Some(meta_list) = attr.meta_item_list() {
874+
meta_list.into_iter()
875+
.filter(|it| it.check_name("include"))
876+
.filter_map(|it| it.meta_item_list().map(|l| l.to_owned()))
877+
.flat_map(|it| it)
878+
.filter(|meta| meta.check_name("contents"))
879+
.filter_map(|meta| meta.value_str())
880+
.for_each(|val| {
881+
result.push_str(&val.as_str());
882+
result.push('\n');
883+
});
873884
}
874885
}
875886
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Extra docs for this struct.

src/test/run-make/save-analysis/foo.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(box_syntax)]
1313
#![feature(rustc_private)]
1414
#![feature(associated_type_defaults)]
15+
#![feature(external_doc)]
1516

1617
extern crate graphviz;
1718
// A simple rust project
@@ -461,3 +462,6 @@ impl Iterator for SilenceGenerator {
461462
trait Foo {
462463
type Bar = FrameBuffer;
463464
}
465+
466+
#[doc(include="extra-docs.md")]
467+
struct StructWithDocs;

0 commit comments

Comments
 (0)