From 43e4bbdaaaad1c606a1ad2ea5dbf7e1dc975af74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Sat, 19 Mar 2022 23:51:33 +0100 Subject: [PATCH 1/5] =?UTF-8?q?rustdoc:=20add=20=F0=9F=94=92=20to=20indica?= =?UTF-8?q?te=20restricted=20visibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/librustdoc/html/render/print_item.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index e6c7745c6e10f..dcf7d68ab87d4 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -376,17 +376,24 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl let stab = myitem.stability_class(cx.tcx()); let add = if stab.is_some() { " " } else { "" }; + let visibility_emoji = match myitem.visibility { + clean::Visibility::Restricted(_) => "🔒 ", + _ => "" + }; + let doc_value = myitem.doc_value().unwrap_or_default(); w.write_str(ITEM_TABLE_ROW_OPEN); write!( w, "
\ - {name}\ - {unsafety_flag}\ - {stab_tags}\ + {visibility_emoji}\ + {name}\ + {unsafety_flag}\ + {stab_tags}\
\
{docs}
", name = myitem.name.unwrap(), + visibility_emoji = visibility_emoji, stab_tags = extra_info_tags(myitem, item, cx.tcx()), docs = MarkdownSummaryLine(&doc_value, &myitem.links(cx)).into_string(), class = myitem.type_(), From 1fec0fbb2c42f9cf41b04d9323139e9c82e9b963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Sat, 19 Mar 2022 23:54:42 +0100 Subject: [PATCH 2/5] apply rustfmt --- src/librustdoc/html/render/print_item.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index dcf7d68ab87d4..8aa052dca0100 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -377,8 +377,10 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl let add = if stab.is_some() { " " } else { "" }; let visibility_emoji = match myitem.visibility { - clean::Visibility::Restricted(_) => "🔒 ", - _ => "" + clean::Visibility::Restricted(_) => { + "🔒 " + } + _ => "", }; let doc_value = myitem.doc_value().unwrap_or_default(); From 03ddfa3087fbce431309a7453769db35e7104839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Mon, 21 Mar 2022 11:03:02 +0100 Subject: [PATCH 3/5] =?UTF-8?q?move=20the=20=F0=9F=94=92=20after=20the=20n?= =?UTF-8?q?ame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/librustdoc/html/render/print_item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 8aa052dca0100..088500c7179de 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -388,8 +388,8 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl write!( w, "
\ - {visibility_emoji}\ {name}\ +  {visibility_emoji} \ {unsafety_flag}\ {stab_tags}\
\ From 4df867c4a3d6d5e05b0193bf43e888673d5b64a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Mon, 21 Mar 2022 11:25:05 +0100 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20add=20a=20space=20only=20in=20front?= =?UTF-8?q?=20of=20=F0=9F=94=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/librustdoc/html/render/print_item.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 088500c7179de..efeb2e0d463af 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -378,7 +378,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl let visibility_emoji = match myitem.visibility { clean::Visibility::Restricted(_) => { - "🔒 " + " ðŸ”’ " } _ => "", }; @@ -389,7 +389,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl w, "
\ {name}\ -  {visibility_emoji} \ + {visibility_emoji}\ {unsafety_flag}\ {stab_tags}\
\ From 1c523ba772490088ed4b5cd9345a8f46d2f7bf42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Mon, 21 Mar 2022 11:40:25 +0100 Subject: [PATCH 5/5] =?UTF-8?q?add=20tests=20for=20=F0=9F=94=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/rustdoc/visibility.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/rustdoc/visibility.rs b/src/test/rustdoc/visibility.rs index cd284dad390e7..c573e1b77f901 100644 --- a/src/test/rustdoc/visibility.rs +++ b/src/test/rustdoc/visibility.rs @@ -4,42 +4,68 @@ #![crate_name = "foo"] +// @!has 'foo/index.html' '//a[@href="struct.FooPublic.html"]/..' 'FooPublic 🔒' // @has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic' pub struct FooPublic; +// @has 'foo/index.html' '//a[@href="struct.FooJustCrate.html"]/..' 'FooJustCrate 🔒' // @has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate' crate struct FooJustCrate; +// @has 'foo/index.html' '//a[@href="struct.FooPubCrate.html"]/..' 'FooPubCrate 🔒' // @has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate' pub(crate) struct FooPubCrate; +// @has 'foo/index.html' '//a[@href="struct.FooSelf.html"]/..' 'FooSelf 🔒' // @has 'foo/struct.FooSelf.html' '//pre' 'pub(crate) struct FooSelf' pub(self) struct FooSelf; +// @has 'foo/index.html' '//a[@href="struct.FooInSelf.html"]/..' 'FooInSelf 🔒' // @has 'foo/struct.FooInSelf.html' '//pre' 'pub(crate) struct FooInSelf' pub(in self) struct FooInSelf; +// @has 'foo/index.html' '//a[@href="struct.FooPriv.html"]/..' 'FooPriv 🔒' // @has 'foo/struct.FooPriv.html' '//pre' 'pub(crate) struct FooPriv' struct FooPriv; +// @!has 'foo/index.html' '//a[@href="pub_mod/index.html"]/..' 'pub_mod 🔒' +pub mod pub_mod {} + +// @has 'foo/index.html' '//a[@href="pub_crate_mod/index.html"]/..' 'pub_crate_mod 🔒' +pub(crate) mod pub_crate_mod {} + +// @has 'foo/index.html' '//a[@href="a/index.html"]/..' 'a 🔒' mod a { + // @has 'foo/a/index.html' '//a[@href="struct.FooASuper.html"]/..' 'FooASuper 🔒' // @has 'foo/a/struct.FooASuper.html' '//pre' 'pub(crate) struct FooASuper' pub(super) struct FooASuper; + // @has 'foo/a/index.html' '//a[@href="struct.FooAInSuper.html"]/..' 'FooAInSuper 🔒' // @has 'foo/a/struct.FooAInSuper.html' '//pre' 'pub(crate) struct FooAInSuper' pub(in super) struct FooAInSuper; + // @has 'foo/a/index.html' '//a[@href="struct.FooAInA.html"]/..' 'FooAInA 🔒' // @has 'foo/a/struct.FooAInA.html' '//pre' 'struct FooAInA' // @!has 'foo/a/struct.FooAInA.html' '//pre' 'pub' pub(in a) struct FooAInA; + // @has 'foo/a/index.html' '//a[@href="struct.FooAPriv.html"]/..' 'FooAPriv 🔒' // @has 'foo/a/struct.FooAPriv.html' '//pre' 'struct FooAPriv' // @!has 'foo/a/struct.FooAPriv.html' '//pre' 'pub' struct FooAPriv; + // @has 'foo/a/index.html' '//a[@href="b/index.html"]/..' 'b 🔒' mod b { + // @has 'foo/a/b/index.html' '//a[@href="struct.FooBSuper.html"]/..' 'FooBSuper 🔒' // @has 'foo/a/b/struct.FooBSuper.html' '//pre' 'pub(super) struct FooBSuper' pub(super) struct FooBSuper; + // @has 'foo/a/b/index.html' '//a[@href="struct.FooBInSuperSuper.html"]/..' 'FooBInSuperSuper 🔒' // @has 'foo/a/b/struct.FooBInSuperSuper.html' '//pre' 'pub(crate) struct FooBInSuperSuper' pub(in super::super) struct FooBInSuperSuper; + // @has 'foo/a/b/index.html' '//a[@href="struct.FooBInAB.html"]/..' 'FooBInAB 🔒' // @has 'foo/a/b/struct.FooBInAB.html' '//pre' 'struct FooBInAB' // @!has 'foo/a/b/struct.FooBInAB.html' '//pre' 'pub' pub(in a::b) struct FooBInAB; + // @has 'foo/a/b/index.html' '//a[@href="struct.FooBPriv.html"]/..' 'FooBPriv 🔒' // @has 'foo/a/b/struct.FooBPriv.html' '//pre' 'struct FooBPriv' // @!has 'foo/a/b/struct.FooBPriv.html' '//pre' 'pub' struct FooBPriv; + + // @!has 'foo/a/b/index.html' '//a[@href="struct.FooBPub.html"]/..' 'FooBPub 🔒' + // @has 'foo/a/b/struct.FooBPub.html' '//pre' 'pub struct FooBPub' + pub struct FooBPub; } } @@ -53,6 +79,8 @@ mod a { // // @has 'foo/trait.PubTrait.html' '//pre' 'fn function();' // @!has 'foo/trait.PubTrait.html' '//pre' 'pub fn function();' +// +// @!has 'foo/index.html' '//a[@href="trait.PubTrait.html"]/..' 'PubTrait 🔒' pub trait PubTrait { type Type; @@ -60,6 +88,9 @@ pub trait PubTrait { fn function(); } +// @has 'foo/index.html' '//a[@href="trait.PrivTrait.html"]/..' 'PrivTrait 🔒' +trait PrivTrait {} + // @has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'type Type' // @!has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub type Type' //