Skip to content

rustdoc: Fix some more assorted broken links #14592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mk/docs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ HTML_DEPS += doc/version_info.html
doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \
$(wildcard $(D)/*.*) | doc/
@$(call E, version-info: $@)
sed -e "s/VERSION/$(CFG_RELEASE)/; s/SHORT_HASH/$(shell echo \
$(Q)sed -e "s/VERSION/$(CFG_RELEASE)/; s/SHORT_HASH/$(shell echo \
$(CFG_VER_HASH) | head -c 8)/;\
s/STAMP/$(CFG_VER_HASH)/;" $< >$@

Expand Down Expand Up @@ -156,15 +156,17 @@ doc/footer.tex: $(D)/footer.inc | doc/
# HTML (rustdoc)
DOC_TARGETS += doc/not_found.html
doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css http://doc.rust-lang.org/rust.css $<
@$(call E, rustdoc: $@)
$(Q)$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) \
--markdown-css http://doc.rust-lang.org/rust.css $<

define DEF_DOC

# HTML (rustdoc)
DOC_TARGETS += doc/$(1).html
doc/$(1).html: $$(D)/$(1).md $$(HTML_DEPS) $$(RUSTDOC_DEPS_$(1)) | doc/
@$$(call E, rustdoc: $$@)
$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) $$<
$$(Q)$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) $$<

ifneq ($(ONLY_HTML_DOCS),1)

Expand Down
1 change: 0 additions & 1 deletion src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ li {list-style-type: none; }
* [The `time` library](time/index.html)
* [The `uuid` 128-bit universally unique identifier library](uuid/index.html)
* [The `url` library](url/index.html)
* [The `workcache` library](workcache/index.html)
* [The `log` library](log/index.html)

# Tooling
Expand Down
30 changes: 27 additions & 3 deletions src/libcore/fmt/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
//! These definitions are similar to their `ct` equivalents, but differ in that
//! these can be statically allocated and are slightly optimized for the runtime

#![allow(missing_doc)]
#![doc(hidden)]

use option::Option;

#[doc(hidden)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these hidden but Alignment etc not hidden?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alignment is publicly available in the Formatter struct, but all these other bits are just internals of the fmt bytecode essentially. They all need to be public to be constructed anywhere.

pub enum Piece<'a> {
String(&'a str),
// FIXME(#8259): this shouldn't require the unit-value here
CurrentArgument(()),
Argument(Argument<'a>),
}

#[doc(hidden)]
pub struct Argument<'a> {
pub position: Position,
pub format: FormatSpec,
pub method: Option<&'a Method<'a>>
}

#[doc(hidden)]
pub struct FormatSpec {
pub fill: char,
pub align: Alignment,
Expand All @@ -40,38 +40,60 @@ pub struct FormatSpec {
pub width: Count,
}

/// Possible alignments that can be requested as part of a formatting directive.
#[deriving(PartialEq)]
pub enum Alignment {
/// Indication that contents should be left-aligned.
AlignLeft,
/// Indication that contents should be right-aligned.
AlignRight,
/// No alignment was requested.
AlignUnknown,
}

#[doc(hidden)]
pub enum Count {
CountIs(uint), CountIsParam(uint), CountIsNextParam, CountImplied,
}

#[doc(hidden)]
pub enum Position {
ArgumentNext, ArgumentIs(uint)
}

/// Flags which can be passed to formatting via a directive.
///
/// These flags are discovered through the `flags` field of the `Formatter`
/// structure. The flag in that structure is a union of these flags into a
/// `uint` where each flag's discriminant is the corresponding bit.
pub enum Flag {
/// A flag which enables number formatting to always print the sign of a
/// number.
FlagSignPlus,
/// Currently not a used flag
FlagSignMinus,
/// Indicates that the "alternate formatting" for a type should be used.
///
/// The meaning of this flag is type-specific.
FlagAlternate,
/// Indicates that padding should be done with a `0` character as well as
/// being aware of the sign to be printed.
FlagSignAwareZeroPad,
}

#[doc(hidden)]
pub enum Method<'a> {
Plural(Option<uint>, &'a [PluralArm<'a>], &'a [Piece<'a>]),
Select(&'a [SelectArm<'a>], &'a [Piece<'a>]),
}

#[doc(hidden)]
pub enum PluralSelector {
Keyword(PluralKeyword),
Literal(uint),
}

#[doc(hidden)]
pub enum PluralKeyword {
Zero,
One,
Expand All @@ -80,11 +102,13 @@ pub enum PluralKeyword {
Many,
}

#[doc(hidden)]
pub struct PluralArm<'a> {
pub selector: PluralSelector,
pub result: &'a [Piece<'a>],
}

#[doc(hidden)]
pub struct SelectArm<'a> {
pub selector: &'a str,
pub result: &'a [Piece<'a>],
Expand Down
55 changes: 36 additions & 19 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub fn record_extern_fqn(cx: &core::DocContext,
match cx.maybe_typed {
core::Typed(ref tcx) => {
let fqn = csearch::get_item_path(tcx, did);
let fqn = fqn.move_iter().map(|i| i.to_str().to_string()).collect();
let fqn = fqn.move_iter().map(|i| i.to_str()).collect();
cx.external_paths.borrow_mut().get_mut_ref().insert(did, (fqn, kind));
}
core::NotTyped(..) => {}
Expand All @@ -138,10 +138,18 @@ pub fn record_extern_fqn(cx: &core::DocContext,

pub fn build_external_trait(tcx: &ty::ctxt, did: ast::DefId) -> clean::Trait {
let def = ty::lookup_trait_def(tcx, did);
let methods = ty::trait_methods(tcx, did);
let methods = ty::trait_methods(tcx, did).clean();
let provided = ty::provided_trait_methods(tcx, did);
let mut methods = methods.move_iter().map(|meth| {
if provided.iter().any(|a| a.def_id == meth.def_id) {
clean::Provided(meth)
} else {
clean::Required(meth)
}
});
clean::Trait {
generics: def.generics.clean(),
methods: methods.iter().map(|i| i.clean()).collect(),
methods: methods.collect(),
parents: Vec::new(), // FIXME: this is likely wrong
}
}
Expand Down Expand Up @@ -207,7 +215,7 @@ fn build_impls(cx: &core::DocContext,
match tcx.inherent_impls.borrow().find(&did) {
None => {}
Some(i) => {
impls.extend(i.borrow().iter().map(|&did| { build_impl(tcx, did) }));
impls.extend(i.borrow().iter().map(|&did| { build_impl(cx, tcx, did) }));
}
}

Expand All @@ -223,38 +231,47 @@ fn build_impls(cx: &core::DocContext,
csearch::each_top_level_item_of_crate(&tcx.sess.cstore,
did.krate,
|def, _, _| {
populate_impls(tcx, def, &mut impls)
populate_impls(cx, tcx, def, &mut impls)
});

fn populate_impls(tcx: &ty::ctxt,
fn populate_impls(cx: &core::DocContext,
tcx: &ty::ctxt,
def: decoder::DefLike,
impls: &mut Vec<clean::Item>) {
impls: &mut Vec<Option<clean::Item>>) {
match def {
decoder::DlImpl(did) => impls.push(build_impl(tcx, did)),
decoder::DlImpl(did) => impls.push(build_impl(cx, tcx, did)),
decoder::DlDef(ast::DefMod(did)) => {
csearch::each_child_of_item(&tcx.sess.cstore,
did,
|def, _, _| {
populate_impls(tcx, def, impls)
populate_impls(cx, tcx, def, impls)
})
}
_ => {}
}
}
}

impls
impls.move_iter().filter_map(|a| a).collect()
}

fn build_impl(tcx: &ty::ctxt, did: ast::DefId) -> clean::Item {
fn build_impl(cx: &core::DocContext,
tcx: &ty::ctxt,
did: ast::DefId) -> Option<clean::Item> {
if !cx.inlined.borrow_mut().get_mut_ref().insert(did) {
return None
}

let associated_trait = csearch::get_impl_trait(tcx, did);
let attrs = load_attrs(tcx, did);
let ty = ty::lookup_item_type(tcx, did);
let methods = csearch::get_impl_methods(&tcx.sess.cstore, did).iter().map(|did| {
let mut item = match ty::method(tcx, *did).clean() {
clean::Provided(item) => item,
clean::Required(item) => item,
};
let methods = csearch::get_impl_methods(&tcx.sess.cstore,
did).iter().filter_map(|did| {
let method = ty::method(tcx, *did);
if method.vis != ast::Public && associated_trait.is_none() {
return None
}
let mut item = ty::method(tcx, *did).clean();
item.inner = match item.inner.clone() {
clean::TyMethodItem(clean::TyMethod {
fn_style, decl, self_, generics
Expand All @@ -268,9 +285,9 @@ fn build_impl(tcx: &ty::ctxt, did: ast::DefId) -> clean::Item {
}
_ => fail!("not a tymethod"),
};
item
Some(item)
}).collect();
clean::Item {
Some(clean::Item {
inner: clean::ImplItem(clean::Impl {
derived: clean::detect_derived(attrs.as_slice()),
trait_: associated_trait.clean().map(|bound| {
Expand All @@ -288,7 +305,7 @@ fn build_impl(tcx: &ty::ctxt, did: ast::DefId) -> clean::Item {
attrs: attrs,
visibility: Some(ast::Inherited),
def_id: did,
}
})
}

fn build_module(cx: &core::DocContext, tcx: &ty::ctxt,
Expand Down
37 changes: 23 additions & 14 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl<'a> Clean<Crate> for visit_ast::RustdocVisitor<'a> {
cx.sess().cstore.iter_crate_data(|n, meta| {
externs.push((n, meta.clean()));
});
externs.sort_by(|&(a, _), &(b, _)| a.cmp(&b));

// Figure out the name of this crate
let input = driver::FileInput(cx.src.clone());
Expand Down Expand Up @@ -132,24 +133,33 @@ impl<'a> Clean<Crate> for visit_ast::RustdocVisitor<'a> {
_ => unreachable!(),
};
let mut tmp = Vec::new();
for child in m.items.iter() {
match child.inner {
ModuleItem(..) => {},
for child in m.items.mut_iter() {
let inner = match child.inner {
ModuleItem(ref mut m) => m,
_ => continue,
}
};
let prim = match Primitive::find(child.attrs.as_slice()) {
Some(prim) => prim,
None => continue,
};
primitives.push(prim);
tmp.push(Item {
let mut i = Item {
source: Span::empty(),
name: Some(prim.to_url_str().to_string()),
attrs: child.attrs.clone(),
visibility: Some(ast::Public),
attrs: Vec::new(),
visibility: None,
def_id: ast_util::local_def(prim.to_node_id()),
inner: PrimitiveItem(prim),
});
};
// Push one copy to get indexed for the whole crate, and push a
// another copy in the proper location which will actually get
// documented. The first copy will also serve as a redirect to
// the other copy.
tmp.push(i.clone());
i.visibility = Some(ast::Public);
i.attrs = child.attrs.clone();
inner.items.push(i);

}
m.items.extend(tmp.move_iter());
}
Expand Down Expand Up @@ -942,9 +952,8 @@ impl Clean<TraitMethod> for ast::TraitMethod {
}
}

impl Clean<TraitMethod> for ty::Method {
fn clean(&self) -> TraitMethod {
let m = if self.provided_source.is_some() {Provided} else {Required};
impl Clean<Item> for ty::Method {
fn clean(&self) -> Item {
let cx = super::ctxtkey.get().unwrap();
let tcx = match cx.maybe_typed {
core::Typed(ref tcx) => tcx,
Expand Down Expand Up @@ -972,7 +981,7 @@ impl Clean<TraitMethod> for ty::Method {
}
};

m(Item {
Item {
name: Some(self.ident.clean()),
visibility: Some(ast::Inherited),
def_id: self.def_id,
Expand All @@ -984,7 +993,7 @@ impl Clean<TraitMethod> for ty::Method {
self_: self_,
decl: (self.def_id, &sig).clean(),
})
})
}
}
}

Expand Down Expand Up @@ -1028,7 +1037,7 @@ pub enum Type {
// region, raw, other boxes, mutable
}

#[deriving(Clone, Encodable, Decodable, PartialEq, TotalEq, Hash)]
#[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash)]
pub enum Primitive {
Int, I8, I16, I32, I64,
Uint, U8, U16, U32, U64,
Expand Down
Loading