Rollup merge of #72771 - jyn514:rustdoc, r=Manishearth
Warn if linking to a private item Closes https://github.com/rust-lang/rust/issues/72769 r? @GuillaumeGomez
This commit is contained in:
commit
8adc781a1f
10 changed files with 98 additions and 23 deletions
|
|
@ -468,7 +468,7 @@ impl clean::Path {
|
|||
|
||||
pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
|
||||
let cache = cache();
|
||||
if !did.is_local() && !cache.access_levels.is_public(did) {
|
||||
if !did.is_local() && !cache.access_levels.is_public(did) && !cache.document_private {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -469,6 +469,7 @@ pub fn run(
|
|||
static_root_path,
|
||||
generate_search_filter,
|
||||
generate_redirect_pages,
|
||||
document_private,
|
||||
..
|
||||
} = options;
|
||||
|
||||
|
|
@ -546,7 +547,7 @@ pub fn run(
|
|||
scx.ensure_dir(&dst)?;
|
||||
krate = sources::render(&dst, &mut scx, krate)?;
|
||||
let (new_crate, index, cache) =
|
||||
Cache::from_krate(renderinfo, &extern_html_root_urls, &dst, krate);
|
||||
Cache::from_krate(renderinfo, document_private, &extern_html_root_urls, &dst, krate);
|
||||
krate = new_crate;
|
||||
let cache = Arc::new(cache);
|
||||
let mut cx = Context {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,10 @@ crate struct Cache {
|
|||
/// The version of the crate being documented, if given from the `--crate-version` flag.
|
||||
pub crate_version: Option<String>,
|
||||
|
||||
/// Whether to document private items.
|
||||
/// This is stored in `Cache` so it doesn't need to be passed through all rustdoc functions.
|
||||
pub document_private: bool,
|
||||
|
||||
// Private fields only used when initially crawling a crate to build a cache
|
||||
stack: Vec<String>,
|
||||
parent_stack: Vec<DefId>,
|
||||
|
|
@ -126,6 +130,7 @@ crate struct Cache {
|
|||
impl Cache {
|
||||
pub fn from_krate(
|
||||
renderinfo: RenderInfo,
|
||||
document_private: bool,
|
||||
extern_html_root_urls: &BTreeMap<String, String>,
|
||||
dst: &Path,
|
||||
mut krate: clean::Crate,
|
||||
|
|
@ -160,6 +165,7 @@ impl Cache {
|
|||
stripped_mod: false,
|
||||
access_levels,
|
||||
crate_version: krate.version.take(),
|
||||
document_private,
|
||||
orphan_impl_items: Vec::new(),
|
||||
orphan_trait_impls: Vec::new(),
|
||||
traits: krate.external_traits.replace(Default::default()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue