diff options
| author | kennytm <kennytm@gmail.com> | 2018-02-06 02:13:45 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-06 02:13:45 +0800 |
| commit | cde119db8e27da1b8e8be376449e71e62cc80e11 (patch) | |
| tree | 75fbe3e14e6188e6741a1e910534457392f79039 /src | |
| parent | eb5a4617a5ef4cb8840ae40a31cd56f9ed243ee5 (diff) | |
| parent | 5a350c137196f0a192b632f0380a8e3e5ab71fb3 (diff) | |
| download | rust-cde119db8e27da1b8e8be376449e71e62cc80e11.tar.gz rust-cde119db8e27da1b8e8be376449e71e62cc80e11.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_save_analysis/lib.rs | 11 | ||||
| -rw-r--r-- | src/test/run-make/save-analysis/extra-docs.md | 1 | ||||
| -rw-r--r-- | src/test/run-make/save-analysis/foo.rs | 4 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 2e494fdfad8..8232a8efd54 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -870,6 +870,17 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { 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'); + }); } } } diff --git a/src/test/run-make/save-analysis/extra-docs.md b/src/test/run-make/save-analysis/extra-docs.md new file mode 100644 index 00000000000..0605ca517ff --- /dev/null +++ b/src/test/run-make/save-analysis/extra-docs.md @@ -0,0 +1 @@ +Extra docs for this struct. diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index 834a7554a55..5b4e4802957 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -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 @@ impl Iterator for SilenceGenerator { trait Foo { type Bar = FrameBuffer; } + +#[doc(include="extra-docs.md")] +struct StructWithDocs; |
