Commit cc90b4f
authored
Rollup merge of rust-lang#145782 - karolzwolak:rustdoc-consistent-attributes-rendering, r=GuillaumeGomez
rustdoc: make attributes render consistently
While working on rust-lang#132304, I discovered that even standard attributes aren't consistently rendered.
For some constructs/fields, attributes were missing entirely, and the attributes were only sometimes wrapped in a code-attribute divs so they appear greyed out.
In short this PR:
* makes attributes render inside code elements and inside divs with class `code-attribute`
* renders attributes for macros, associated constants, and struct/union fields
Attributes in `Fields` and `Variants` sections are still not rendered (see struct and enum screenshots), because I wasn't sure we want that.
[Compirison of tests/rustdoc/attributes.rs](https://github.com/karolzwolak/rust/blob/90aa25a1c5dbae1e94099b1a2015dfb83783dbe0/tests/rustdoc/attributes.rs)
Before (left) / after (right):
<img width="279" height="97" alt="image" src="https://github.com/user-attachments/assets/baca4b75-f809-4a76-8ac1-e3aa6389aad4" />
<img width="363" height="112" alt="image" src="https://github.com/user-attachments/assets/14970fb0-6fe5-474f-983e-5a95e16175c5" />
<img width="368" height="492" alt="image" src="https://github.com/user-attachments/assets/f9a25583-10e3-49c7-961b-34f3587b552e" />
<img width="415" height="515" alt="image" src="https://github.com/user-attachments/assets/f2fe4aa0-c731-4f2f-a3c2-04e524a858d1" />
<img width="383" height="483" alt="image" src="https://github.com/user-attachments/assets/bccc1b6e-f236-4948-8557-f9b25cad8a07" />
<img width="402" height="528" alt="image" src="https://github.com/user-attachments/assets/2cea9250-37e1-439e-8010-0603905d0f52" />
<img width="372" height="485" alt="image" src="https://github.com/user-attachments/assets/cd49bc0a-90e1-4d08-af0f-084c42af1834" />
<img width="406" height="542" alt="image" src="https://github.com/user-attachments/assets/67fb4ac7-746b-4e20-9c80-97702a71def8" />
<img width="357" height="131" alt="image" src="https://github.com/user-attachments/assets/42769532-1e4d-486d-bdca-6ecc409554b9" />
<img width="366" height="161" alt="image" src="https://github.com/user-attachments/assets/0b4d01d4-dd8e-4467-8cfc-ad58200ba0d7" />
<img width="291" height="65" alt="image" src="https://github.com/user-attachments/assets/43f61335-8eff-491b-a297-1953d17bbfc0" />
<img width="259" height="57" alt="image" src="https://github.com/user-attachments/assets/598618a3-e52f-4a4e-b790-2c8d5f1b4c77" />
r? ``@GuillaumeGomez``File tree
8 files changed
+139
-80
lines changed- src/librustdoc/html
- render
- templates
- tests/rustdoc
- enum
- type-alias
8 files changed
+139
-80
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1029 | 1029 | | |
1030 | 1030 | | |
1031 | 1031 | | |
| 1032 | + | |
1032 | 1033 | | |
1033 | 1034 | | |
1034 | 1035 | | |
| |||
1136 | 1137 | | |
1137 | 1138 | | |
1138 | 1139 | | |
1139 | | - | |
| 1140 | + | |
1140 | 1141 | | |
1141 | 1142 | | |
1142 | | - | |
| 1143 | + | |
1143 | 1144 | | |
1144 | 1145 | | |
1145 | 1146 | | |
| |||
1309 | 1310 | | |
1310 | 1311 | | |
1311 | 1312 | | |
1312 | | - | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | 1313 | | |
1324 | 1314 | | |
1325 | | - | |
1326 | | - | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
1327 | 1323 | | |
1328 | 1324 | | |
1329 | 1325 | | |
1330 | 1326 | | |
1331 | | - | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1332 | 1333 | | |
1333 | | - | |
| 1334 | + | |
1334 | 1335 | | |
1335 | 1336 | | |
1336 | 1337 | | |
| |||
1342 | 1343 | | |
1343 | 1344 | | |
1344 | 1345 | | |
1345 | | - | |
| 1346 | + | |
1346 | 1347 | | |
1347 | 1348 | | |
1348 | 1349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 110 | | |
118 | 111 | | |
119 | 112 | | |
| |||
457 | 450 | | |
458 | 451 | | |
459 | 452 | | |
460 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
461 | 459 | | |
462 | 460 | | |
463 | 461 | | |
| |||
625 | 623 | | |
626 | 624 | | |
627 | 625 | | |
| 626 | + | |
628 | 627 | | |
629 | 628 | | |
630 | | - | |
| 629 | + | |
631 | 630 | | |
632 | | - | |
633 | 631 | | |
634 | 632 | | |
635 | 633 | | |
| |||
666 | 664 | | |
667 | 665 | | |
668 | 666 | | |
| 667 | + | |
669 | 668 | | |
670 | 669 | | |
671 | | - | |
672 | | - | |
| 670 | + | |
673 | 671 | | |
674 | 672 | | |
675 | 673 | | |
| |||
1240 | 1238 | | |
1241 | 1239 | | |
1242 | 1240 | | |
| 1241 | + | |
1243 | 1242 | | |
1244 | 1243 | | |
1245 | | - | |
1246 | | - | |
| 1244 | + | |
1247 | 1245 | | |
1248 | 1246 | | |
1249 | 1247 | | |
| |||
1268 | 1266 | | |
1269 | 1267 | | |
1270 | 1268 | | |
| 1269 | + | |
1271 | 1270 | | |
1272 | 1271 | | |
1273 | | - | |
1274 | | - | |
| 1272 | + | |
1275 | 1273 | | |
1276 | 1274 | | |
1277 | 1275 | | |
| |||
1452 | 1450 | | |
1453 | 1451 | | |
1454 | 1452 | | |
1455 | | - | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
1456 | 1461 | | |
1457 | 1462 | | |
1458 | 1463 | | |
| |||
1479 | 1484 | | |
1480 | 1485 | | |
1481 | 1486 | | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
1485 | | - | |
1486 | | - | |
1487 | | - | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | 1487 | | |
1504 | 1488 | | |
1505 | 1489 | | |
| |||
1563 | 1547 | | |
1564 | 1548 | | |
1565 | 1549 | | |
1566 | | - | |
| 1550 | + | |
1567 | 1551 | | |
1568 | 1552 | | |
1569 | 1553 | | |
| |||
1702 | 1686 | | |
1703 | 1687 | | |
1704 | 1688 | | |
1705 | | - | |
| 1689 | + | |
1706 | 1690 | | |
1707 | 1691 | | |
1708 | 1692 | | |
| |||
1882 | 1866 | | |
1883 | 1867 | | |
1884 | 1868 | | |
| 1869 | + | |
1885 | 1870 | | |
1886 | 1871 | | |
1887 | 1872 | | |
| |||
1950 | 1935 | | |
1951 | 1936 | | |
1952 | 1937 | | |
1953 | | - | |
| 1938 | + | |
1954 | 1939 | | |
1955 | 1940 | | |
1956 | 1941 | | |
| |||
2018 | 2003 | | |
2019 | 2004 | | |
2020 | 2005 | | |
2021 | | - | |
| 2006 | + | |
2022 | 2007 | | |
2023 | 2008 | | |
2024 | 2009 | | |
| |||
2115 | 2100 | | |
2116 | 2101 | | |
2117 | 2102 | | |
2118 | | - | |
| 2103 | + | |
2119 | 2104 | | |
2120 | 2105 | | |
2121 | 2106 | | |
| |||
2135 | 2120 | | |
2136 | 2121 | | |
2137 | 2122 | | |
2138 | | - | |
| 2123 | + | |
2139 | 2124 | | |
2140 | 2125 | | |
2141 | 2126 | | |
| |||
2358 | 2343 | | |
2359 | 2344 | | |
2360 | 2345 | | |
| 2346 | + | |
| 2347 | + | |
2361 | 2348 | | |
2362 | 2349 | | |
2363 | 2350 | | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
2364 | 2357 | | |
2365 | 2358 | | |
2366 | 2359 | | |
| |||
2390 | 2383 | | |
2391 | 2384 | | |
2392 | 2385 | | |
| 2386 | + | |
2393 | 2387 | | |
2394 | 2388 | | |
2395 | 2389 | | |
| |||
2481 | 2475 | | |
2482 | 2476 | | |
2483 | 2477 | | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
2484 | 2481 | | |
2485 | 2482 | | |
2486 | | - | |
| 2483 | + | |
| 2484 | + | |
2487 | 2485 | | |
2488 | | - | |
| 2486 | + | |
2489 | 2487 | | |
2490 | 2488 | | |
2491 | 2489 | | |
| |||
2495 | 2493 | | |
2496 | 2494 | | |
2497 | 2495 | | |
2498 | | - | |
| 2496 | + | |
2499 | 2497 | | |
2500 | | - | |
| 2498 | + | |
2501 | 2499 | | |
2502 | 2500 | | |
2503 | | - | |
| 2501 | + | |
2504 | 2502 | | |
2505 | 2503 | | |
2506 | 2504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
0 commit comments