about summary refs log tree commit diff
path: root/src/test/rustdoc
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-04-21 23:06:20 +0200
committerGitHub <noreply@github.com>2021-04-21 23:06:20 +0200
commit2cddda3af1556fcebd4471c9ddaade92b7ac0024 (patch)
tree0fbced9c623d0f1d891c48e06eab3256dfaff7f9 /src/test/rustdoc
parente7f20335a66cb175a3754391b60c0a202410e5cf (diff)
parentdf147c718c5819631eefc774e6e40d4515f30c90 (diff)
downloadrust-2cddda3af1556fcebd4471c9ddaade92b7ac0024.tar.gz
rust-2cddda3af1556fcebd4471c9ddaade92b7ac0024.zip
Rollup merge of #84380 - Smittyvb:rdoc-title-order, r=jsha
Write Rustdoc titles like "x in crate::mod - Rust"

This makes Rustdoc titles for items be like "Widget in cratename::blah::foo - Rust". Titles for modules and other non-items are unchanged, and still read like "cratename::blah::foo - Rust". This makes managing several open Rustdoc tabs easier.

![A screenshot of several open Rustdoc tabs](https://user-images.githubusercontent.com/10530973/115457675-d608f180-a1f2-11eb-87a8-838a32b4e3f7.png)

This also adds some tests for the new title behavior.

Closes #84371.
Diffstat (limited to 'src/test/rustdoc')
-rw-r--r--src/test/rustdoc/prim-title.rs7
-rw-r--r--src/test/rustdoc/tab_title.rs44
2 files changed, 44 insertions, 7 deletions
diff --git a/src/test/rustdoc/prim-title.rs b/src/test/rustdoc/prim-title.rs
deleted file mode 100644
index fa3fd512fad..00000000000
--- a/src/test/rustdoc/prim-title.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#![crate_name = "foo"]
-
-// @has foo/primitive.u8.html '//head/title' 'u8 - Rust'
-// @!has - '//head/title' 'foo'
-#[doc(primitive = "u8")]
-/// `u8` docs
-mod u8 {}
diff --git a/src/test/rustdoc/tab_title.rs b/src/test/rustdoc/tab_title.rs
new file mode 100644
index 00000000000..7dce6092dea
--- /dev/null
+++ b/src/test/rustdoc/tab_title.rs
@@ -0,0 +1,44 @@
+#![crate_name = "foo"]
+#![feature(doc_keyword)]
+
+// tests for the html <title> element
+
+// @has foo/index.html '//head/title' 'foo - Rust'
+
+// @has foo/fn.widget_count.html '//head/title' 'widget_count in foo - Rust'
+/// blah
+pub fn widget_count() {}
+
+// @has foo/struct.Widget.html '//head/title' 'Widget in foo - Rust'
+pub struct Widget;
+
+// @has foo/constant.ANSWER.html '//head/title' 'ANSWER in foo - Rust'
+pub const ANSWER: u8 = 42;
+
+// @has foo/blah/index.html '//head/title' 'foo::blah - Rust'
+pub mod blah {
+    // @has foo/blah/struct.Widget.html '//head/title' 'Widget in foo::blah - Rust'
+    pub struct Widget;
+
+    // @has foo/blah/trait.Awesome.html '//head/title' 'Awesome in foo::blah - Rust'
+    pub trait Awesome {}
+
+    // @has foo/blah/fn.make_widget.html '//head/title' 'make_widget in foo::blah - Rust'
+    pub fn make_widget() {}
+
+    // @has foo/macro.cool_macro.html '//head/title' 'cool_macro in foo - Rust'
+    #[macro_export]
+    macro_rules! cool_macro {
+        ($t:tt) => { $t }
+    }
+}
+
+// @has foo/keyword.continue.html '//head/title' 'continue - Rust'
+#[doc(keyword = "continue")]
+mod continue_keyword {}
+
+// @has foo/primitive.u8.html '//head/title' 'u8 - Rust'
+// @!has - '//head/title' 'foo'
+#[doc(primitive = "u8")]
+/// `u8` docs
+mod u8 {}