GeezerVison is showing github.com — [3.13] gh-121035: Improve logging flow diagram for dark/light modes. … · vsajip/cpython@845d861
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Doc/howto/logging.rst +38Lines changed: 38 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -385,6 +385,44 @@ following diagram. |
385 | 385 | .. raw:: html |
386 | 386 | :file: logging_flow.svg |
387 | 387 |
|
| 388 | +.. raw:: html |
| 389 | + |
| 390 | + <script> |
| 391 | + /* |
| 392 | + * This snippet is needed to handle the case where a light or dark theme is |
| 393 | + * chosen via the theme is selected in the page. We call the existing handler |
| 394 | + * and then add a dark-theme class to the body when the dark theme is selected. |
| 395 | + * The SVG styling (above) then does the rest. |
| 396 | + * |
| 397 | + * If the pydoc theme is updated to set the dark-theme class, this snippet |
| 398 | + * won't be needed any more. |
| 399 | + */ |
| 400 | + (function() { |
| 401 | + var oldActivateTheme = activateTheme; |
| 402 | +
|
| 403 | + function updateBody(theme) { |
| 404 | + let elem = document.body; |
| 405 | +
|
| 406 | + if (theme === 'dark') { |
| 407 | + elem.classList.add('dark-theme'); |
| 408 | + } |
| 409 | + else { |
| 410 | + elem.classList.remove('dark-theme'); |
| 411 | + } |
| 412 | + } |
| 413 | +
|
| 414 | + activateTheme = function(theme) { |
| 415 | + oldActivateTheme(theme); |
| 416 | + updateBody(theme); |
| 417 | + }; |
| 418 | + /* |
| 419 | + * If the page is refreshed, make sure we update the body - the overriding |
| 420 | + * of activateTheme won't have taken effect yet. |
| 421 | + */ |
| 422 | + updateBody(localStorage.getItem('currentTheme') || 'auto'); |
| 423 | + })(); |
| 424 | + </script> |
| 425 | + |
388 | 426 | Loggers |
389 | 427 | ^^^^^^^ |
390 | 428 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: Doc/howto/logging_flow.svg +24-11Lines changed: 24 additions & 11 deletions - Display the source diff
- Display the rich diff