-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add a logo to the navigation bar of the HTML rendered book #3214
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
Open
Chocorean
wants to merge
29
commits into
rust-lang:main
Choose a base branch
from
Chocorean:dev_logo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
fa3870b
Add a config variable for a logo path
scattenlaeufer fb415da
Add a logo to the HTML template
scattenlaeufer db82eab
Add informations about the logo to the guide
scattenlaeufer 96de687
Fix a typo
scattenlaeufer f446322
Fix the link to the logo so it worked on every page
scattenlaeufer a2e36ae
fix tests
Chocorean 3c16f0f
add alt to book logo
Chocorean eafe563
change logo extension from png to svg in guide documentation
Chocorean 613e08e
fix display issue for logo ; it is now displayed in the center of the…
Chocorean f6ad728
add logo to guide
Chocorean 375fa9e
fix broken tests
Chocorean bfa235f
add logo path to complex test example
Chocorean c907143
add title next to logo to fill the space, rustdoc style
Chocorean ed6c150
fix gui test
Chocorean 4b35b3f
add missing double quote
Chocorean 9217acc
fix properties order
Chocorean 5c5d81a
add tests: display, position, src, across different nested chapters
Chocorean e6030ed
Address comments
Chocorean 0aeacff
crash after loading the config if the logo does not exist, add testca…
Chocorean 024fb96
replace logo copy with symlink
Chocorean 258cce2
move test case
Chocorean f59370d
Rewrite check: revise failure conditions for logo config
Chocorean 9edf1a4
attempt to fix gui tests
Chocorean 59b3fb5
fix swapped logo paths
Chocorean dcce71b
add logo absolute test variant for windows platforms
Chocorean 8e24b48
fix logo path for windows absolute logo path test
Chocorean ae508fa
last css adjustments: logo is 20% wide and max 8rem tall, title is 70…
Chocorean 08ef043
fix logo img tag
Chocorean 5caab23
minor tweaks for logo large/tall tests
Chocorean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../crates/mdbook-html/front-end/images/favicon.svg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [book] | ||
| title = "Large logo" | ||
| logo = "logo.svg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - [c1](c1.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # c1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [book] | ||
| title = "Tall logo" | ||
| logo = "logo.svg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - [c1](c1.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # c1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [book] | ||
| title = "sidebar-logo test" | ||
| language = "en" | ||
| logo = "logo.svg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Summary | ||
|
|
||
| - [Chapter 1](./chapter_1.md) | ||
| - [Chapter 2](./chapter_2.md) | ||
| - [Nested](./nested/chapter_nested.md) | ||
| - [Deeper](./nested/again/chapter_nested.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Chapter 1 | ||
|
|
||
| This is the first chapter to test logo display at root level. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Chapter 2 | ||
|
|
||
| This is the second chapter. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
tests/gui/books/sidebar-logo/src/nested/again/chapter_nested.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Deeper Chapter | ||
|
|
||
| This is a nested chapter to test logo display at different nesting levels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Nested Chapter | ||
|
|
||
| This is a nested chapter to test logo display at different nesting levels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // This GUI test checks that the logo is displayed when configured | ||
| // Test cases: | ||
| // - test if the logo is displayed when provided | ||
| // - test it is displayed above the toc | ||
| // - test if works in nested files (level 0, 1 and n > 1) | ||
| // - large pictures are properly displayed | ||
|
|
||
| define-function: ( | ||
| "load", | ||
| [path], | ||
| block { | ||
| go-to: |DOC_PATH| + |path| | ||
| set-window-size: (1100, 600) | ||
| reload: | ||
| // Wait for the TOC to be populated by JavaScript | ||
| wait-for: "mdbook-sidebar-scrollbox" | ||
| wait-for: "ol.chapter" | ||
| wait-for: "#sidebar-book-logo" | ||
| }, | ||
| ) | ||
|
|
||
| define-function: ( | ||
| "assert-logo", | ||
| [], | ||
| block { | ||
| assert-css: ("#sidebar-book-logo", {"display": "flex"}) | ||
| assert-css: ("#sidebar-book-logo img", {"display": "block"}) | ||
| }, | ||
| ) | ||
|
|
||
| define-function: ( | ||
| "assert-logo-src", | ||
| [prefix], | ||
| block { | ||
| assert-attribute: (".sidebar-book-logo img", {"src": |prefix| + "logo.svg"}) | ||
| assert-find-text-false: "sidebar-logo test logo" | ||
| }, | ||
| ) | ||
|
|
||
| define-function: ( | ||
| "assert-logo-position", | ||
| [], | ||
| block { | ||
| store-position: ("#sidebar-book-logo img", {"y": logo_y}) | ||
| store-position: ("ol.chapter", {"y": chapter_y}) | ||
| assert: |logo_y| < |chapter_y| | ||
| }, | ||
| ) | ||
|
|
||
| call-function: ("load", {"path": "sidebar-logo/index.html"}) | ||
|
|
||
| // The sidebar-book-logo should exist when logo is provided | ||
| call-function: ("assert-logo", {}) | ||
|
|
||
| // Logo image should have the correct src path and loaded | ||
| call-function: ("assert-logo-src", {"prefix": ""}) | ||
|
|
||
| // Logo should be above the TOC | ||
| call-function: ("assert-logo-position", {}) | ||
|
|
||
| // Test on chapter_2, nested, and deeper | ||
| click: ".chapter a[href='chapter_2.html']" | ||
| wait-for-text: (".header", "Chapter 2") | ||
| call-function: ("assert-logo", {}) | ||
| call-function: ("assert-logo-src", {"prefix": ""}) | ||
| call-function: ("assert-logo-position", {}) | ||
|
|
||
|
Chocorean marked this conversation as resolved.
|
||
| click: ".chapter a[href='nested/chapter_nested.html']" | ||
| wait-for-text: (".header", "Nested Chapter") | ||
| call-function: ("assert-logo", {}) | ||
| call-function: ("assert-logo-src", {"prefix": "../"}) | ||
| call-function: ("assert-logo-position", {}) | ||
|
|
||
| click: ".chapter a[href='../nested/again/chapter_nested.html']" | ||
| wait-for-text: (".header", "Deeper Chapter") | ||
| call-function: ("assert-logo", {}) | ||
| call-function: ("assert-logo-src", {"prefix": "../../"}) | ||
| call-function: ("assert-logo-position", {}) | ||
|
|
||
| // Large images checks | ||
| call-function: ("load", {"path": "sidebar-logo-large/index.html"}) | ||
| store-property : (".sidebar-book-logo img", {"width": logo_width}) | ||
| assert: |logo_width| <= 200 | ||
|
|
||
| call-function: ("load", {"path": "sidebar-logo-tall/index.html"}) | ||
| store-property : (".sidebar-book-logo img", {"height": logo_height}) | ||
| assert: |logo_height| <= 200 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [book] | ||
| title = "outside" | ||
| authors = ["Chocorean"] | ||
| language = "en" | ||
| logo = "/absolute/path/logo.svg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Summary | ||
|
|
||
| - [Chapter 1](./chapter_1.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Chapter 1 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.