rustdoc: Inline argument names of foreign methods
This commit is contained in:
parent
ec4f79ff6c
commit
6ee9109c8b
@ -206,6 +206,9 @@ pub static tag_crate_triple: uint = 0x66;
|
||||
|
||||
pub static tag_dylib_dependency_formats: uint = 0x67;
|
||||
|
||||
pub static tag_method_argument_names: uint = 0x8e;
|
||||
pub static tag_method_argument_name: uint = 0x8f;
|
||||
|
||||
#[deriving(Clone, Show)]
|
||||
pub struct LinkMeta {
|
||||
pub crateid: CrateId,
|
||||
|
@ -306,3 +306,10 @@ pub fn get_missing_lang_items(cstore: &cstore::CStore, cnum: ast::CrateNum)
|
||||
let cdata = cstore.get_crate_data(cnum);
|
||||
decoder::get_missing_lang_items(&*cdata)
|
||||
}
|
||||
|
||||
pub fn get_method_arg_names(cstore: &cstore::CStore, did: ast::DefId)
|
||||
-> Vec<StrBuf>
|
||||
{
|
||||
let cdata = cstore.get_crate_data(did.krate);
|
||||
decoder::get_method_arg_names(&*cdata, did.node)
|
||||
}
|
||||
|
@ -1309,3 +1309,18 @@ pub fn get_missing_lang_items(cdata: Cmd)
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn get_method_arg_names(cdata: Cmd, id: ast::NodeId) -> Vec<StrBuf> {
|
||||
let mut ret = Vec::new();
|
||||
let method_doc = lookup_item(id, cdata.data());
|
||||
match reader::maybe_get_doc(method_doc, tag_method_argument_names) {
|
||||
Some(args_doc) => {
|
||||
reader::tagged_docs(args_doc, tag_method_argument_name, |name_doc| {
|
||||
ret.push(name_doc.as_str_slice().to_strbuf());
|
||||
true
|
||||
});
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -774,6 +774,21 @@ fn encode_info_for_method(ecx: &EncodeContext,
|
||||
} else {
|
||||
encode_symbol(ecx, ebml_w, m.def_id.node);
|
||||
}
|
||||
|
||||
ebml_w.start_tag(tag_method_argument_names);
|
||||
for arg in ast_method.decl.inputs.iter() {
|
||||
ebml_w.start_tag(tag_method_argument_name);
|
||||
match arg.pat.node {
|
||||
ast::PatIdent(_, ref name, _) => {
|
||||
let name = name.segments.last().unwrap().identifier;
|
||||
let name = token::get_ident(name);
|
||||
ebml_w.writer.write(name.get().as_bytes());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
ebml_w.end_tag();
|
||||
|
@ -488,7 +488,7 @@ impl Clean<Option<Vec<TyParamBound>>> for ty::substs {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, Encodable, Decodable)]
|
||||
#[deriving(Clone, Encodable, Decodable, Eq)]
|
||||
pub struct Lifetime(String);
|
||||
|
||||
impl Lifetime {
|
||||
@ -629,7 +629,7 @@ impl Clean<Item> for ast::TypeMethod {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, Encodable, Decodable)]
|
||||
#[deriving(Clone, Encodable, Decodable, Eq)]
|
||||
pub enum SelfTy {
|
||||
SelfStatic,
|
||||
SelfValue,
|
||||
@ -868,6 +868,16 @@ impl Clean<TraitMethod> for ty::Method {
|
||||
(s, sig)
|
||||
}
|
||||
};
|
||||
let mut names = csearch::get_method_arg_names(&tcx.sess.cstore,
|
||||
self.def_id).move_iter();
|
||||
if self_ != SelfStatic {
|
||||
names.next();
|
||||
}
|
||||
let mut decl = sig.clean();
|
||||
for (name, slot) in names.zip(decl.inputs.values.mut_iter()) {
|
||||
slot.name = name;
|
||||
}
|
||||
|
||||
m(Item {
|
||||
name: Some(self.ident.clean()),
|
||||
visibility: Some(ast::Inherited),
|
||||
@ -878,7 +888,7 @@ impl Clean<TraitMethod> for ty::Method {
|
||||
fn_style: self.fty.fn_style,
|
||||
generics: self.generics.clean(),
|
||||
self_: self_,
|
||||
decl: sig.clean(),
|
||||
decl: decl,
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -1437,7 +1447,7 @@ impl Clean<Item> for doctree::Static {
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Show, Clone, Encodable, Decodable)]
|
||||
#[deriving(Show, Clone, Encodable, Decodable, Eq)]
|
||||
pub enum Mutability {
|
||||
Mutable,
|
||||
Immutable,
|
||||
|
Loading…
Reference in New Issue
Block a user