Skip to content

Commit 2856016

Browse files
feat: Adding [OutputType([xml])] where appropriate ( Fixes PoshWeb#266 )
1 parent 3063c5d commit 2856016

7 files changed

Lines changed: 34 additions & 16 deletions

File tree

Types/Turtle/get_Marker.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
.LINK
1111
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/marker
1212
#>
13+
[OutputType([xml])]
1314
param()
1415

1516
# The default settings for markers

Types/Turtle/get_Mask.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
.LINK
3535
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/mask
3636
#>
37+
[OutputType([xml])]
3738
param()
3839

3940
$keyPattern = '^mask/'

Types/Turtle/get_PathElement.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
Gets the Path Element of a Turtle.
66
77
This contains the path of the Turtle's motion.
8+
.EXAMPLE
9+
turtle forward 42 rotate 90 forward 42 pathElement
810
#>
9-
11+
[OutputType([xml])]
12+
param()
1013
# Set our core attributes
1114
$coreAttributes = [Ordered]@{
1215
id="$($this.id)-path"
@@ -26,12 +29,20 @@ foreach ($pathAttributeName in $this.PathAttribute.Keys) {
2629
$coreAttributes[$pathAttributeName] = $($this.PathAttribute[$pathAttributeName])
2730
}
2831

29-
@(
32+
# Path attributes can be defined within .SVGAttribute or .Attribute
33+
foreach ($attributeCollectionName in 'SVGAttribute', 'Attribute') {
34+
$attributeCollection = $this.$attributeCollectionName
35+
foreach ($attributeName in $attributeCollection.Keys -match '^path/') {
36+
$coreAttributes[$attributeName -replace '^path/'] = $attributeCollection[$attributeName]
37+
}
38+
}
39+
40+
[xml]@(
3041
"<path$(
3142
foreach ($attributeName in $coreAttributes.Keys) {
3243
" $attributeName='$($coreAttributes[$attributeName])'"
3344
}
3445
)>"
3546
if ($this.PathAnimation) {$this.PathAnimation}
3647
"</path>"
37-
) -as [xml]
48+
)

Types/Turtle/get_PatternMask.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
.LINK
3838
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/mask
3939
#>
40+
[OutputType([xml])]
4041
param()
4142
$keyPattern = '^pattern-?mask/'
4243
$defaultId = "$($this.Id)-pattern-mask"
@@ -65,4 +66,4 @@ $segments = @(
6566
"</mask>"
6667
)
6768
# join them and cast to XML.
68-
[xml]($segments -join '')
69+
[xml]$segments

Types/Turtle/get_SVG.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
.DESCRIPTION
55
Gets this turtle and any nested turtles as a single Scalable Vector Graphic.
66
#>
7+
[OutputType([xml])]
78
param()
8-
@(
99

1010
$svgAttributes = [Ordered]@{
1111
xmlns='http://www.w3.org/2000/svg'
@@ -35,6 +35,7 @@ foreach ($key in $this.SVGAttribute.Keys) {
3535
$svgAttributes[$key] = $this.SVGAttribute[$key]
3636
}
3737

38+
$svgElement = @(
3839
"<svg $(@(foreach ($attributeName in $svgAttributes.Keys) {
3940
if ($attributeName -match '/') { continue }
4041
" $attributeName='$($svgAttributes[$attributeName])'"
@@ -75,7 +76,7 @@ foreach ($key in $this.SVGAttribute.Keys) {
7576
}
7677

7778
# Declare any SVG animations
78-
if ($this.SVGAnimation) {$this.SVGAnimation}
79+
if ($this.SVGAnimation) {$this.SVGAnimation}
7980
if ($this.BackgroundColor) {
8081
"<rect width='10000%' height='10000%' x='-5000%' y='-5000%' fill='$($this.BackgroundColor)' transform-origin='50% 50%' />"
8182
}
@@ -113,4 +114,5 @@ foreach ($key in $this.SVGAttribute.Keys) {
113114
"</a>"
114115
}
115116
"</svg>"
116-
) -join '' -as [xml]
117+
)
118+
[xml]$svgElement

Types/Turtle/get_Symbol.ps1

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
Move-Turtle Flower |
1212
Select-Object -ExpandProperty Symbol
1313
#>
14+
[OutputType([xml])]
1415
param()
1516

16-
@(
17-
"<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%' transform-origin='50% 50%'>"
18-
"<symbol id='$($this.ID)-symbol' viewBox='$($this.ViewBox)' transform-origin='50% 50%'>"
19-
$($this.SVG.OuterXml)
20-
"</symbol>"
21-
"<use href='#$($this.ID)-symbol' width='100%' height='100%' transform-origin='50% 50%' />"
22-
"</svg>"
23-
) -join '' -as [xml]
17+
[xml]@(
18+
"<svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%' transform-origin='50% 50%'>"
19+
"<symbol id='$($this.ID)-symbol' viewBox='$($this.ViewBox)' transform-origin='50% 50%'>"
20+
$($this.SVG.OuterXml)
21+
"</symbol>"
22+
"<use href='#$($this.ID)-symbol' width='100%' height='100%' transform-origin='50% 50%' />"
23+
"</svg>"
24+
)

Types/Turtle/get_TextElement.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
.EXAMPLE
1313
turtle text "hello world" textElement
1414
#>
15-
15+
[OutputType([xml])]
16+
param()
1617

1718
if (-not $this.Text) { return }
1819

0 commit comments

Comments
 (0)