Commit 8730c2b
authored
Rollup merge of rust-lang#75330 - Nemo157:improve-doc-cfg-features, r=GuillaumeGomez
Improve rendering of crate features via doc(cfg)
The current rendering of crate features with `doc(cfg(feature = ".."))` is verbose and unwieldy for users, `doc(cfg(target_feature = ".."))` is special-cased to make it render nicely, and a similar rendering can be applied to `doc(cfg(feature))` to make it easier for users to read.
I also added special casing of `all`/`any` cfgs consisting of just `feature`/`target-feature` to remove the repetitive "target/crate feature" prefix.
The downside of this current rendering is that there is no distinction between `feature` and `target_feature` in the shorthand display. IMO this is ok, or if anything `target_feature` should have a more verbose shorthand, because `doc(cfg(feature = ".."))` usage is going to vastly outstrip `doc(cfg(target_feature = ".."))` usage in non-stdlib crates when it eventually stabilizes (or even before that given the number of crates using `cfg_attr(docsrs)` like constructs).
## Previously
<img width="259" alt="Screenshot 2020-08-09 at 13 32 42" src="https://user-images.githubusercontent.com/81079/89731110-d090c000-da44-11ea-96fa-56adc6339123.png">
<img width="438" alt="image" src="https://user-images.githubusercontent.com/81079/89731116-d7b7ce00-da44-11ea-87c6-022d192d6eca.png">
<img width="765" alt="image" src="https://user-images.githubusercontent.com/81079/89731152-24030e00-da45-11ea-9552-1c270bff2729.png">
<img width="671" alt="image" src="https://user-images.githubusercontent.com/81079/89731158-28c7c200-da45-11ea-8acb-97d8a4ce00eb.png">
## Now
<img width="216" alt="image" src="https://user-images.githubusercontent.com/81079/89731123-e1d9cc80-da44-11ea-82a8-5900bd9448a5.png">
<img width="433" alt="image" src="https://user-images.githubusercontent.com/81079/89731127-e8684400-da44-11ea-9d18-572fd810f19f.png">
<img width="606" alt="image" src="https://user-images.githubusercontent.com/81079/89731162-2feed000-da45-11ea-98d2-8a88c364d903.png">
<img width="669" alt="image" src="https://user-images.githubusercontent.com/81079/89731991-ccb46c00-da4b-11ea-9416-cd20a3193826.png">
cc rust-lang#43781File tree
3 files changed
+154
-33
lines changed- src
- librustdoc
- clean
- html/render
- test/rustdoc
3 files changed
+154
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
158 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
159 | 174 | | |
160 | 175 | | |
161 | 176 | | |
| |||
286 | 301 | | |
287 | 302 | | |
288 | 303 | | |
289 | | - | |
290 | | - | |
291 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
292 | 329 | | |
293 | 330 | | |
294 | 331 | | |
| |||
305 | 342 | | |
306 | 343 | | |
307 | 344 | | |
308 | | - | |
| 345 | + | |
309 | 346 | | |
310 | 347 | | |
311 | 348 | | |
| |||
314 | 351 | | |
315 | 352 | | |
316 | 353 | | |
317 | | - | |
| 354 | + | |
318 | 355 | | |
319 | 356 | | |
320 | 357 | | |
321 | | - | |
322 | | - | |
| 358 | + | |
| 359 | + | |
323 | 360 | | |
324 | 361 | | |
325 | 362 | | |
326 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
327 | 384 | | |
328 | 385 | | |
329 | 386 | | |
330 | 387 | | |
331 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
332 | 397 | | |
333 | 398 | | |
334 | 399 | | |
335 | 400 | | |
336 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
337 | 421 | | |
338 | 422 | | |
339 | 423 | | |
340 | 424 | | |
341 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
342 | 434 | | |
343 | 435 | | |
344 | 436 | | |
| |||
406 | 498 | | |
407 | 499 | | |
408 | 500 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
| 501 | + | |
| 502 | + | |
413 | 503 | | |
414 | 504 | | |
415 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
416 | 515 | | |
417 | 516 | | |
418 | 517 | | |
419 | 518 | | |
420 | 519 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
428 | 531 | | |
| 532 | + | |
| 533 | + | |
429 | 534 | | |
430 | 535 | | |
431 | 536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2130 | 2130 | | |
2131 | 2131 | | |
2132 | 2132 | | |
2133 | | - | |
2134 | | - | |
| 2133 | + | |
| 2134 | + | |
2135 | 2135 | | |
2136 | 2136 | | |
2137 | 2137 | | |
| |||
2140 | 2140 | | |
2141 | 2141 | | |
2142 | 2142 | | |
2143 | | - | |
| 2143 | + | |
2144 | 2144 | | |
2145 | 2145 | | |
2146 | 2146 | | |
| |||
2151 | 2151 | | |
2152 | 2152 | | |
2153 | 2153 | | |
2154 | | - | |
| 2154 | + | |
2155 | 2155 | | |
2156 | 2156 | | |
2157 | 2157 | | |
2158 | | - | |
| 2158 | + | |
2159 | 2159 | | |
2160 | 2160 | | |
2161 | 2161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | | - | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
12 | 20 | | |
13 | | - | |
| 21 | + | |
14 | 22 | | |
15 | 23 | | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
20 | 32 | | |
21 | | - | |
| 33 | + | |
22 | 34 | | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
28 | 40 | | |
29 | | - | |
| 41 | + | |
30 | 42 | | |
31 | 43 | | |
32 | 44 | | |
33 | 45 | | |
34 | 46 | | |
35 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | | - | |
| 53 | + | |
38 | 54 | | |
39 | 55 | | |
40 | 56 | | |
| |||
0 commit comments