Skip to content

Commit e6aa999

Browse files
authored
Refactor code (#101)
* Remove deprecations file * Remove thumbnail * Rename the documentation catalog of htmlkit * Refactor the formula class of the renderer * Extract the cache handling in its own class The class should handle the caching later and everything that comes with. * Refactor the renderer class The functions add(_ :) and render(_ :) can be simplified. Therefore the view requirements have to be removed. * Restore renderer methods Brings back the briefly removed methods and mark them as deprecated. * Fix test failing * Extract the localization in its own class The class should handle the localization later and everything that comes with it. * Remove the modifiable protocol * Move the draw handler for the path element way up The draw attribute on the group element is incorrect. It should be removed. * Change the initializer of the document element * Add computed properties to the node protocols It reduces the code redundancy, plus each node is one single ingredient in the renderer formula. * Remove the string builder The converter doesn't use it anymore. * Rework the context manager * Remove the context variable file The html context class is slightly the same. While the html context is more used, the context variable file can be removed. * Add tests for the statements * Remove the template value mapping file * Refactor the html context class * Refactor the template value enum * Change the access level of the conditions The access level for the comparison operators stays public. * Add a namespace for the several enumerations of attribute values * Adjust the syntax of some attribute handlers * Rearrange and rename files * Refactor the statements * Change the internal comments * Add tests for the conditions * Refactor the conditions
1 parent 3c22a8a commit e6aa999

File tree

91 files changed

+10507
-10969
lines changed

Some content is hidden

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

91 files changed

+10507
-10969
lines changed

Sources/HTMLKit/External/Attributes/AriaAttributes.swift renamed to Sources/HTMLKit/Abstraction/Attributes/AriaAttributes.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public protocol AriaAutoCompleteAttribute: AnyAttribute {
7777
/// ```html
7878
/// <tag aria-autocomplete="" />
7979
/// ```
80-
func aria(autoComplete value: Accessibility.Complete) -> Self
80+
func aria(autoComplete value: Values.Accessibility.Complete) -> Self
8181
}
8282

8383
extension AriaAutoCompleteAttribute {
@@ -137,7 +137,7 @@ public protocol AriaCheckedAttribute: AnyAttribute {
137137
/// ```html
138138
/// <tag aria-checked="" />
139139
/// ```
140-
func aria(checked value: Accessibility.Check) -> Self
140+
func aria(checked value: Values.Accessibility.Check) -> Self
141141
}
142142

143143
extension AriaCheckedAttribute {
@@ -287,7 +287,7 @@ public protocol AriaCurrentAttribute: AnyAttribute {
287287
/// ```html
288288
/// <tag aria-current="" />
289289
/// ```
290-
func aria(current value: Accessibility.Current) -> Self
290+
func aria(current value: Values.Accessibility.Current) -> Self
291291
}
292292

293293
extension AriaCurrentAttribute {
@@ -497,7 +497,7 @@ public protocol AriaPopupAttribute: AnyAttribute {
497497
/// ```html
498498
/// <tag aria-haspopup="" />
499499
/// ```
500-
func aria(hasPopup value: Accessibility.Popup) -> Self
500+
func aria(hasPopup value: Values.Accessibility.Popup) -> Self
501501
}
502502

503503
extension AriaPopupAttribute {
@@ -557,7 +557,7 @@ public protocol AriaInvalidAttribute: AnyAttribute {
557557
/// ```html
558558
/// <tag aria-invalid="" />
559559
/// ```
560-
func aria(invalid value: Accessibility.Invalid) -> Self
560+
func aria(invalid value: Values.Accessibility.Invalid) -> Self
561561
}
562562

563563
extension AriaInvalidAttribute {
@@ -707,7 +707,7 @@ public protocol AriaLiveAttribute: AnyAttribute {
707707
/// ```html
708708
/// <tag aria-live="" />
709709
/// ```
710-
func aria(live value: Accessibility.Live) -> Self
710+
func aria(live value: Values.Accessibility.Live) -> Self
711711
}
712712

713713
extension AriaLiveAttribute {
@@ -827,7 +827,7 @@ public protocol AriaOrientationAttribute: AnyAttribute {
827827
/// ```html
828828
/// <tag aria-orientation="" />
829829
/// ```
830-
func aria(orientation value: Accessibility.Orientation) -> Self
830+
func aria(orientation value: Values.Accessibility.Orientation) -> Self
831831
}
832832

833833
extension AriaOrientationAttribute {
@@ -947,7 +947,7 @@ public protocol AriaPressedAttribute: AnyAttribute {
947947
/// ```html
948948
/// <tag aria-pressed="" />
949949
/// ```
950-
func aria(presssed value: Accessibility.Pressed) -> Self
950+
func aria(presssed value: Values.Accessibility.Pressed) -> Self
951951
}
952952

953953
extension AriaPressedAttribute {
@@ -1007,7 +1007,7 @@ public protocol AriaRelevantAttribute: AnyAttribute {
10071007
/// ```html
10081008
/// <tag aria-relevant="" />
10091009
/// ```
1010-
func aria(relevant value: Accessibility.Relevant) -> Self
1010+
func aria(relevant value: Values.Accessibility.Relevant) -> Self
10111011
}
10121012

10131013
extension AriaRelevantAttribute {
@@ -1187,7 +1187,7 @@ public protocol AriaSelectedAttribute: AnyAttribute {
11871187
/// ```html
11881188
/// <tag aria-selected="" />
11891189
/// ```
1190-
func aria(selected value: Accessibility.Selected) -> Self
1190+
func aria(selected value: Values.Accessibility.Selected) -> Self
11911191
}
11921192

11931193
extension AriaSelectedAttribute {
@@ -1247,7 +1247,7 @@ public protocol AriaSortAttribute: AnyAttribute {
12471247
/// ```html
12481248
/// <tag aria-sort="" />
12491249
/// ```
1250-
func aria(sort value: Accessibility.Sort) -> Self
1250+
func aria(sort value: Values.Accessibility.Sort) -> Self
12511251
}
12521252

12531253
extension AriaSortAttribute {

Sources/HTMLKit/External/Attributes/BasicAttributes.swift renamed to Sources/HTMLKit/Abstraction/Attributes/BasicAttributes.swift

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
Abstract:
33
The file contains the protocols for the basic html-attributes.
44

5-
Authors:
6-
- Mats Moll (https://github.com/matsmoll)
7-
8-
Contributors:
9-
- Mattes Mohr (https://github.com/mattesmohr)
10-
115
Note:
126
If you about to add something to the file, stick to the official documentation to keep the code consistent.
137
*/
@@ -178,7 +172,7 @@ public protocol AutocapitalizeAttribute: AnyAttribute {
178172
/// ```html
179173
/// <tag autocapitalize="" />
180174
/// ```
181-
func autocapitalize(_ type: Capitalization) -> Self
175+
func autocapitalize(_ value: Values.Capitalization) -> Self
182176
}
183177

184178
extension AutocapitalizeAttribute {
@@ -208,7 +202,7 @@ public protocol AutocompleteAttribute: AnyAttribute {
208202
/// ```html
209203
/// <tag autocomplete="" />
210204
/// ```
211-
func hasCompletion(_ condition: Bool) -> Self
205+
func hasCompletion(_ value: Bool) -> Self
212206
}
213207

214208
extension AutocompleteAttribute {
@@ -298,7 +292,7 @@ public protocol CharsetAttribute: AnyAttribute {
298292
/// ```html
299293
/// <tag charset="" />
300294
/// ```
301-
func charset(_ value: Charset) -> Self
295+
func charset(_ value: Values.Charset) -> Self
302296
}
303297

304298
extension CharsetAttribute {
@@ -511,7 +505,7 @@ public protocol EditAttribute: AnyAttribute {
511505
/// ```html
512506
/// <tag contenteditable />
513507
/// ```
514-
func isEditable(_ condition: Bool) -> Self
508+
func isEditable(_ value: Bool) -> Self
515509
}
516510

517511
extension EditAttribute {
@@ -723,7 +717,7 @@ public protocol DirectionAttribute: AnyAttribute {
723717
/// ```html
724718
/// <tag dir="" />
725719
/// ```
726-
func direction(_ type: Direction) -> Self
720+
func direction(_ value: Values.Direction) -> Self
727721
}
728722

729723
extension DirectionAttribute {
@@ -813,7 +807,7 @@ public protocol DragAttribute: AnyAttribute {
813807
/// ```html
814808
/// <tag draggable />
815809
/// ```
816-
func isDraggable(_ condition: Bool) -> Self
810+
func isDraggable(_ value: Bool) -> Self
817811
}
818812

819813
extension DragAttribute {
@@ -845,7 +839,7 @@ public protocol EncodingAttribute: AnyAttribute {
845839
/// ```html
846840
/// <tag enctype="" />
847841
/// ```
848-
func encoding(_ type: Encoding) -> Self
842+
func encoding(_ value: Values.Encoding) -> Self
849843
}
850844

851845
extension EncodingAttribute {
@@ -877,7 +871,7 @@ public protocol EnterKeyHintAttribute: AnyAttribute {
877871
/// ```html
878872
/// <tag enterkeyhint="" />
879873
/// ```
880-
func enterKeyHint(_ type: Hint) -> Self
874+
func enterKeyHint(_ value: Values.Hint) -> Self
881875
}
882876

883877
extension EnterKeyHintAttribute {
@@ -1003,7 +997,7 @@ public protocol EquivalentAttribute: AnyAttribute {
1003997
/// ```html
1004998
/// <tag http-equiv="" />
1005999
/// ```
1006-
func equivalent(_ value: Equivalent) -> Self
1000+
func equivalent(_ value: Values.Equivalent) -> Self
10071001
}
10081002

10091003
extension EquivalentAttribute {
@@ -1195,7 +1189,7 @@ public protocol ReferenceLanguageAttribute: AnyAttribute {
11951189
/// ```html
11961190
/// <tag hreflang="" />
11971191
/// ```
1198-
func referenceLanguage(_ type: Language) -> Self
1192+
func referenceLanguage(_ value: Values.Language) -> Self
11991193
}
12001194

12011195
extension ReferenceLanguageAttribute {
@@ -1499,7 +1493,7 @@ public protocol KindAttribute: AnyAttribute {
14991493
/// ```html
15001494
/// <tag kind="" />
15011495
/// ```
1502-
func kind(_ type: Kinds) -> Self
1496+
func kind(_ value: Values.Kind) -> Self
15031497
}
15041498

15051499
extension KindAttribute {
@@ -1559,7 +1553,7 @@ public protocol LanguageAttribute: AnyAttribute {
15591553
/// ```html
15601554
/// <tag lang="" />
15611555
/// ```
1562-
func language(_ type: Language) -> Self
1556+
func language(_ value: Values.Language) -> Self
15631557
}
15641558

15651559
extension LanguageAttribute {
@@ -1771,7 +1765,7 @@ public protocol MethodAttribute: AnyAttribute {
17711765
/// ```html
17721766
/// <tag method="" />
17731767
/// ```
1774-
func method(_ type: Method) -> Self
1768+
func method(_ value: Values.Method) -> Self
17751769
}
17761770

17771771
extension MethodAttribute {
@@ -2018,7 +2012,7 @@ public protocol OpenAttribute: AnyAttribute {
20182012
/// ```html
20192013
/// <tag open />
20202014
/// ```
2021-
func isOpen(_ condition: Bool) -> Self
2015+
func isOpen(_ value: Bool) -> Self
20222016
}
20232017

20242018
extension OpenAttribute {
@@ -2230,7 +2224,7 @@ public protocol PreloadAttribute: AnyAttribute {
22302224
/// ```html
22312225
/// <tag preload="" />
22322226
/// ```
2233-
func preload(_ type: Preload) -> Self
2227+
func preload(_ value: Values.Preload) -> Self
22342228
}
22352229

22362230
extension PreloadAttribute {
@@ -2290,7 +2284,7 @@ public protocol ReferrerPolicyAttribute: AnyAttribute {
22902284
/// ```html
22912285
/// <tag referrerpolicy="" />
22922286
/// ```
2293-
func referrerPolicy(_ type: Policy) -> Self
2287+
func referrerPolicy(_ value: Values.Policy) -> Self
22942288
}
22952289

22962290
extension ReferrerPolicyAttribute {
@@ -2320,7 +2314,7 @@ public protocol RelationshipAttribute: AnyAttribute {
23202314
/// ```html
23212315
/// <tag rel="" />
23222316
/// ```
2323-
func relationship(_ type: Relation) -> Self
2317+
func relationship(_ value: Values.Relation) -> Self
23242318
}
23252319

23262320
extension RelationshipAttribute {
@@ -2410,7 +2404,7 @@ public protocol RoleAttribute: AnyAttribute {
24102404
/// ```html
24112405
/// <tag role="" />
24122406
/// ```
2413-
func role(_ value: Roles) -> Self
2407+
func role(_ value: Values.Role) -> Self
24142408
}
24152409

24162410
extension RoleAttribute {
@@ -2560,7 +2554,7 @@ public protocol ShapeAttribute: AnyAttribute {
25602554
/// ```html
25612555
/// <tag shape="" />
25622556
/// ```
2563-
func shape(_ type: Shape) -> Self
2557+
func shape(_ value: Values.Shape) -> Self
25642558
}
25652559

25662560
extension ShapeAttribute {
@@ -2710,7 +2704,7 @@ public protocol SpellCheckAttribute: AnyAttribute {
27102704
/// ```html
27112705
/// <tag spellcheck="" />
27122706
/// ```
2713-
func hasSpellCheck(_ condition: Bool) -> Self
2707+
func hasSpellCheck(_ value: Bool) -> Self
27142708
}
27152709

27162710
extension SpellCheckAttribute {
@@ -2890,7 +2884,7 @@ public protocol TargetAttribute: AnyAttribute {
28902884
/// ```html
28912885
/// <tag target="" />
28922886
/// ```
2893-
func target(_ type: Target) -> Self
2887+
func target(_ value: Values.Target) -> Self
28942888
}
28952889

28962890
extension TargetAttribute {
@@ -2950,7 +2944,7 @@ public protocol TranslateAttribute: AnyAttribute {
29502944
/// ```html
29512945
/// <tag translate="" />
29522946
/// ```
2953-
func translate(_ type: Decision) -> Self
2947+
func translate(_ value: Values.Decision) -> Self
29542948
}
29552949

29562950
extension TranslateAttribute {
@@ -3074,7 +3068,7 @@ public protocol WrapAttribute: AnyAttribute {
30743068
/// ```html
30753069
/// <tag wrap="" />
30763070
/// ```
3077-
func wrap(_ type: Wrapping) -> Self
3071+
func wrap(_ value: Values.Wrapping) -> Self
30783072
}
30793073

30803074
extension WrapAttribute {
@@ -3106,7 +3100,7 @@ public protocol PropertyAttribute: AnyAttribute {
31063100
/// ```
31073101
///
31083102
/// - Parameter type:
3109-
func property(_ type: Graphs) -> Self
3103+
func property(_ value: Values.Graph) -> Self
31103104
}
31113105

31123106
extension PropertyAttribute {

0 commit comments

Comments
 (0)