Rework DocFragment
This commit is contained in:
parent
90ccf4f5ad
commit
c4739bc920
1 changed files with 4 additions and 4 deletions
|
@ -481,7 +481,7 @@ crate enum DocFragmentKind {
|
||||||
RawDoc,
|
RawDoc,
|
||||||
/// A doc fragment created from a `#[doc(include="filename")]` attribute. Contains both the
|
/// A doc fragment created from a `#[doc(include="filename")]` attribute. Contains both the
|
||||||
/// given filename and the file contents.
|
/// given filename and the file contents.
|
||||||
Include { filename: String },
|
Include { filename: Symbol },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FromIterator<&'a DocFragment> for String {
|
impl<'a> FromIterator<&'a DocFragment> for String {
|
||||||
|
@ -565,7 +565,7 @@ impl Attributes {
|
||||||
/// Reads a `MetaItem` from within an attribute, looks for whether it is a
|
/// Reads a `MetaItem` from within an attribute, looks for whether it is a
|
||||||
/// `#[doc(include="file")]`, and returns the filename and contents of the file as loaded from
|
/// `#[doc(include="file")]`, and returns the filename and contents of the file as loaded from
|
||||||
/// its expansion.
|
/// its expansion.
|
||||||
crate fn extract_include(mi: &ast::MetaItem) -> Option<(String, String)> {
|
crate fn extract_include(mi: &ast::MetaItem) -> Option<(Symbol, String)> {
|
||||||
mi.meta_item_list().and_then(|list| {
|
mi.meta_item_list().and_then(|list| {
|
||||||
for meta in list {
|
for meta in list {
|
||||||
if meta.has_name(sym::include) {
|
if meta.has_name(sym::include) {
|
||||||
|
@ -573,13 +573,13 @@ impl Attributes {
|
||||||
// `#[doc(include(file="filename", contents="file contents")]` so we need to
|
// `#[doc(include(file="filename", contents="file contents")]` so we need to
|
||||||
// look for that instead
|
// look for that instead
|
||||||
return meta.meta_item_list().and_then(|list| {
|
return meta.meta_item_list().and_then(|list| {
|
||||||
let mut filename: Option<String> = None;
|
let mut filename: Option<Symbol> = None;
|
||||||
let mut contents: Option<String> = None;
|
let mut contents: Option<String> = None;
|
||||||
|
|
||||||
for it in list {
|
for it in list {
|
||||||
if it.has_name(sym::file) {
|
if it.has_name(sym::file) {
|
||||||
if let Some(name) = it.value_str() {
|
if let Some(name) = it.value_str() {
|
||||||
filename = Some(name.to_string());
|
filename = Some(name);
|
||||||
}
|
}
|
||||||
} else if it.has_name(sym::contents) {
|
} else if it.has_name(sym::contents) {
|
||||||
if let Some(docs) = it.value_str() {
|
if let Some(docs) = it.value_str() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue