Commit 59175af
RenderBlockContent.Aside Names (#1361)
* Introduce a new stored property on `RenderBlockContent.Aside` called
`name` to stored the name or title of aside blocks. This allows DocC to
independently save and control the styling and the name of asides.
Previously DocC conflated the style of the aside block (e.g. colors or
other styling) with the name of the aside. Although it isn't currently
possible to author an aside with a different style and name, this change
allows the `Aside` model itself to support that one day.
Aside now has four available initializers:
* init(style: AsideStyle, content: [RenderBlockContent])
* init(name: String, content: [RenderBlockContent])
* init(style: AsideStyle, name: String, content: [RenderBlockContent])
* init(asideKind: Markdown.Aside.Kind, content: [RenderBlockContent])
Most often DocC will use the fourth initializer to create aside blocks
from markdown, via RenderContentCompiler. This initializer, creating an
aside from a Swift Markdown Aside.Kind, also contains special logic to
determine a capitalized name for the aside that was previously
implemented in AsideStyle.
Simplify the `RenderBlockContent.AsideStyle` structure to act as if it
were an enum of the known styles supported by DocC Render: note, tip,
experiment, important, or warning. (Since this is public API, this
change retains AsideStyle as a structure with a string raw value.)
Also simplify the JSON encoding and decoding of Aside and AsideStyle
structures to save and read the style and name in a natural way.
* Correct Swift syntax error that cropped up in macOS CI
* Improve the documentation comments for the RenderBlockContent.Aside and
AsideStyle initializers.
* Update Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift
Co-authored-by: David Rönnqvist <ronnqvist@apple.com>
* Simplify RenderBlockContent.AsideStyle.init(rawValue:)
* Update Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift
Co-authored-by: David Rönnqvist <ronnqvist@apple.com>
* When decoding JSON, AsideStyle#init(from:) calls init(rawValue:) to
handle uppercased and other invalid style values.
Fix the logic for decoding RenderBlockContent asides, to retain both the
name and style separately when they are different in JSON. This is
different than the previous behavior, which overrode the style with the
name.
* Cleanup: Update copywrite dates, remove stray debug print statements and
whitespace, and simplify how we express some expected data in a unit
test.
* Deprecate RenderBlockContent.AsideStyle.displayName
* Simplify some test code in SemaToRenderNodeTests.swift and RenderBlockContent+AsideTests.swift
* Refactor RenderBlockContent_AsideTests.decodeAsideRenderBlock to return
a non-optional Aside by implementing the same logic the #require uses. And remove #require from all the call sites.
* Remove use of deprecated AsideStyle.displayName at one call site.
* Update Tests/SwiftDocCTests/Rendering/RenderBlockContent+AsideTests.swift
Co-authored-by: David Rönnqvist <ronnqvist@apple.com>
* Refactor RenderBlockContent_AsideTests.decodeAsideRenderBlock again to
avoid throwing an exception manually, and to record the source location
when decoding an unexpected block type.
---------
Co-authored-by: David Rönnqvist <ronnqvist@apple.com>1 parent 8b49f1b commit 59175af
File tree
7 files changed
+907
-201
lines changed- Sources/SwiftDocC/Model/Rendering
- Content
- Tests/SwiftDocCTests
- Model
- Rendering
7 files changed
+907
-201
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
Lines changed: 136 additions & 53 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
113 | 124 | | |
114 | 125 | | |
| 126 | + | |
115 | 127 | | |
116 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
117 | 195 | | |
118 | 196 | | |
119 | 197 | | |
| |||
515 | 593 | | |
516 | 594 | | |
517 | 595 | | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
| 596 | + | |
522 | 597 | | |
523 | 598 | | |
524 | 599 | | |
| |||
529 | 604 | | |
530 | 605 | | |
531 | 606 | | |
532 | | - | |
| 607 | + | |
533 | 608 | | |
534 | 609 | | |
535 | 610 | | |
536 | 611 | | |
| 612 | + | |
537 | 613 | | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
| 614 | + | |
547 | 615 | | |
548 | 616 | | |
549 | | - | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
550 | 623 | | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
564 | 633 | | |
565 | | - | |
| 634 | + | |
566 | 635 | | |
567 | 636 | | |
568 | 637 | | |
569 | | - | |
570 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
571 | 650 | | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
| 651 | + | |
579 | 652 | | |
580 | | - | |
| 653 | + | |
581 | 654 | | |
582 | 655 | | |
| 656 | + | |
583 | 657 | | |
584 | | - | |
| 658 | + | |
585 | 659 | | |
586 | 660 | | |
587 | 661 | | |
588 | 662 | | |
589 | 663 | | |
590 | | - | |
591 | | - | |
592 | 664 | | |
593 | 665 | | |
594 | 666 | | |
595 | | - | |
596 | | - | |
| 667 | + | |
| 668 | + | |
597 | 669 | | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
598 | 675 | | |
599 | 676 | | |
600 | | - | |
| 677 | + | |
601 | 678 | | |
602 | 679 | | |
603 | 680 | | |
| |||
930 | 1007 | | |
931 | 1008 | | |
932 | 1009 | | |
933 | | - | |
934 | | - | |
935 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
936 | 1019 | | |
937 | | - | |
| 1020 | + | |
938 | 1021 | | |
939 | 1022 | | |
940 | 1023 | | |
| |||
1049 | 1132 | | |
1050 | 1133 | | |
1051 | 1134 | | |
1052 | | - | |
1053 | | - | |
| 1135 | + | |
| 1136 | + | |
1054 | 1137 | | |
1055 | 1138 | | |
1056 | 1139 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | | - | |
| 393 | + | |
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
| |||
0 commit comments