未验证 提交 cde119db 编写于 作者: K kennytm 提交者: GitHub

Rollup merge of #47496 - QuietMisdreavus:rls-doc-include, r=estebank

add documentation from doc(include) to analysis data

cc #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.
......@@ -870,6 +870,17 @@ fn docs_for_attrs(&self, attrs: &[Attribute]) -> String {
result.push_str(&val.as_str());
}
result.push('\n');
} else if let Some(meta_list) = attr.meta_item_list() {
meta_list.into_iter()
.filter(|it| it.check_name("include"))
.filter_map(|it| it.meta_item_list().map(|l| l.to_owned()))
.flat_map(|it| it)
.filter(|meta| meta.check_name("contents"))
.filter_map(|meta| meta.value_str())
.for_each(|val| {
result.push_str(&val.as_str());
result.push('\n');
});
}
}
}
......
......@@ -12,6 +12,7 @@
#![feature(box_syntax)]
#![feature(rustc_private)]
#![feature(associated_type_defaults)]
#![feature(external_doc)]
extern crate graphviz;
// A simple rust project
......@@ -461,3 +462,6 @@ fn next(&mut self) -> Option<Self::Item> {
trait Foo {
type Bar = FrameBuffer;
}
#[doc(include="extra-docs.md")]
struct StructWithDocs;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册