Skip to content

Commit f587687

Browse files
parloughantfitch
andauthored
Individual pages for diagnostic docs (#6573)
Following the split we did for linter rule documentation, move all diagnostic docs to their own page at `/tools/diagnostics/<diagnostic_name>`. This allows for increased focus and improved loading time when a developer navigates to the documentation for a diagnostic from their IDE. As the docs are moved to individual pages, also introduce a new index of diagnostics at `/tools/diagnostics`. This shares some styles with the [linter rule index](https://dart.dev/tools/linter-rules#rules) and now includes diagnostics without extra documentation to serve as a more complete index. Each diagnostic is included as a card with: its name, its problem messages, a copy button, and a learn more button if it has a full page. Contributes to #4499 **Staged index:** https://dart-dev--pr6573-feat-diagnostic-message-pages-kre5no9y.web.app/tools/diagnostics **Staged non-lint diagnostic:** https://dart-dev--pr6573-feat-diagnostic-message-pages-kre5no9y.web.app/tools/diagnostics/definitely_unassigned_late_local_variable **Staged lint diagnostic:** https://dart-dev--pr6573-feat-diagnostic-message-pages-kre5no9y.web.app/tools/diagnostics/prefer_final_locals --------- Co-authored-by: Amanda Fitch <18406675+antfitch@users.noreply.github.com>
1 parent 6b36b80 commit f587687

File tree

731 files changed

+60222
-32877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

731 files changed

+60222
-32877
lines changed

firebase.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@
120120
{ "source": "/deprecated/sound-problems", "destination": "/language/type-system", "type": 301 },
121121
{ "source": "/devices", "destination": "/overview#platform", "type": 301 },
122122
{ "source": "/dev{,/**}", "destination": "https://api.dart.dev/dev", "type": 301 },
123-
{ "source": "/diagnostics", "destination": "/tools/diagnostic-messages", "type": 301 },
124-
{ "source": "/diagnostics/:code*", "destination": "/tools/diagnostic-messages?utm_source=dartdev&utm_medium=redir&utm_id=diagcode&utm_content=:code#:code", "type": 301 },
123+
{ "source": "/diagnostics", "destination": "/tools/diagnostics", "type": 301 },
124+
{ "source": "/diagnostics/:code*", "destination": "/tools/diagnostics/:code/?utm_source=dartdev&utm_medium=redir&utm_id=diagcode&utm_content=:code", "type": 301 },
125125
{ "source": "/docs/api{,/**}", "destination": "https://api.dart.dev", "type": 301 },
126126
{ "source": "/docs/cookbook", "destination": "/language", "type": 301 },
127127
{ "source": "/docs/dart-up-and-running/**/ch02", "destination": "/language", "type": 301 },
@@ -410,6 +410,8 @@
410410
{ "source": "/tools/dartium", "destination": "/tools#editors", "type": 301 },
411411
{ "source": "/tools/dartpad/dartpad-best-practices", "destination": "https://doi.org/10.1145/3397537.3397558", "type": 301 },
412412
{ "source": "/tools/debian", "destination": "/get-dart", "type": 301 },
413+
{ "source": "/tools/diagnostic-messages", "destination": "/tools/diagnostics", "type": 301 },
414+
{ "source": "/tools/diagnostic-messages/:code*", "destination": "/tools/diagnostics/:code", "type": 301 },
413415
{ "source": "/tools/docgen{,/**}", "destination": "/tools/dart-doc", "type": 301 },
414416
{ "source": "/tools/download-archive{,/**}", "destination": "/get-dart/archive", "type": 301 },
415417
{ "source": "/tools/download-editor", "destination": "/tools", "type": 301 },

src/_data/sidenav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
- title: Linter rules
323323
permalink: /tools/linter-rules
324324
- title: Diagnostic messages
325-
permalink: /tools/diagnostic-messages
325+
permalink: /tools/diagnostics
326326
- title: Testing & optimization
327327
children:
328328
- title: Testing

src/_includes/head.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
{% endfor -%}
7575
{% endif -%}
7676

77+
{% if redirectTo and redirectTo != '' -%}
78+
<script>window.location.replace('{{redirectTo}}');</script>
79+
{% endif -%}
80+
7781
<script src="{{ '/assets/js/os-tabs.js' | append: cache_bust }}"></script>
7882
<script src="{{ '/assets/js/main.js' | append: cache_bust }}"></script>
7983

src/_sass/_site.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
@use 'components/card';
1717
@use 'components/code';
1818
@use 'components/content';
19+
@use 'components/diagnostics';
1920
@use 'components/filter-search';
2021
@use 'components/cookie-notice';
2122
@use 'components/footer';
2223
@use 'components/form';
2324
@use 'components/glossary';
2425
@use 'components/header';
25-
@use 'components/linter-rules';
2626
@use 'components/misc';
2727
@use 'components/next-prev-nav';
2828
@use 'components/os-tabs';

src/_sass/components/_breadcrumbs.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
nav.breadcrumbs {
44
align-items: center;
5-
margin-block-start: 1rem;
5+
margin-block-start: 0.25rem;
66
margin-block-end: 1rem;
77

88
ol.breadcrumb-list {
9+
margin: 0;
910
border-radius: 0.375rem;
1011
padding: 0.375rem 0;
1112

src/_sass/components/_card.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@
5656

5757
.card-content {
5858
display: flex;
59-
align-items: center;
59+
flex-direction: column;
6060
gap: 0.75rem;
6161
font-size: 0.95rem;
6262
color: var(--card-text-color, $site-color-body);
6363

6464
p {
6565
margin: 0;
66-
margin-block-end: 0.75rem;
6766

6867
code {
6968
font-size: 0.95em;

src/_sass/components/_content.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ article {
4545
}
4646

4747
#site-content-title {
48-
margin-bottom: 1.5rem;
48+
margin-bottom: 1rem;
4949
scroll-margin: 4.5rem;
5050
}
5151

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@use '../base/mixins' as *;
22
@use '../base/variables' as *;
33

4-
body.linter-rules {
4+
body.diagnostics {
55
--chip-container-color: transparent;
66
--chip-border-color: rgba(0, 0, 0, .35);
77
--chip-selected-container-color: rgb(194 229 255);

src/content/assets/js/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ function setupCopyButtons() {
115115
return;
116116
}
117117

118+
const copyButtons = document.querySelectorAll('.copy-button[data-copy]');
119+
copyButtons.forEach(button => {
120+
button.addEventListener('click', async (e) => {
121+
const textToCopy = button.dataset.copy;
122+
if (textToCopy) {
123+
await navigator.clipboard.writeText(textToCopy);
124+
}
125+
e.preventDefault();
126+
});
127+
button.classList.remove('hidden');
128+
});
129+
118130
const codeBlocks =
119131
document.querySelectorAll('.code-block-body');
120132

0 commit comments

Comments
 (0)