Skip to content

Commit

Permalink
rustdoc-search: show types signatures in results
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Oct 30, 2024
1 parent 5973005 commit 20a4b4f
Show file tree
Hide file tree
Showing 10 changed files with 995 additions and 126 deletions.
21 changes: 16 additions & 5 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ a.anchor,
.mobile-topbar h2 a,
h1 a,
.search-results a,
.search-results li,
.stab,
.result-name i {
color: var(--main-color);
Expand Down Expand Up @@ -379,7 +380,7 @@ details:not(.toggle) summary {
margin-bottom: .6em;
}

code, pre, .code-header {
code, pre, .code-header, .type-signature {
font-family: "Source Code Pro", monospace;
}
.docblock code, .docblock-short code {
Expand Down Expand Up @@ -1205,22 +1206,28 @@ so that we can apply CSS-filters to change the arrow color in themes */

.search-results.active {
display: block;
margin: 0;
padding: 0;
}

.search-results > a {
display: flex;
display: grid;
grid-template-areas:
"search-result-name search-result-desc"
"search-result-type-signature search-result-type-signature";
grid-template-columns: .6fr .4fr;
/* A little margin ensures the browser's outlining of focused links has room to display. */
margin-left: 2px;
margin-right: 2px;
border-bottom: 1px solid var(--search-result-border-color);
gap: 1em;
column-gap: 1em;
}

.search-results > a > div.desc {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
flex: 2;
grid-area: search-result-desc;
}

.search-results a:hover,
Expand All @@ -1232,7 +1239,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
display: flex;
align-items: center;
justify-content: start;
flex: 3;
grid-area: search-result-name;
}
.search-results .result-name .alias {
color: var(--search-results-alias-color);
Expand All @@ -1253,6 +1260,10 @@ so that we can apply CSS-filters to change the arrow color in themes */
.search-results .result-name .path > * {
display: inline;
}
.search-results .type-signature {
grid-area: search-result-type-signature;
white-space: pre-wrap;
}

.popover {
position: absolute;
Expand Down
3 changes: 3 additions & 0 deletions src/librustdoc/html/static/js/externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ let Results;
* parent: (Object|undefined),
* path: string,
* ty: number,
* type: FunctionSearchType?,
* displayType: Promise<Array<Array<string>>>|null,
* displayTypeMappedNames: Promise<Array<[string, Array<string>]>>|null,
* }}
*/
let ResultObject;
Expand Down
Loading

0 comments on commit 20a4b4f

Please sign in to comment.