Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package theming #364

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Assets/css/Main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/css/Main.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "5b662e886a1c844ac00c50de4de4484d2a2ab18317faa2db1b09e6903e5b8baf",
"originHash" : "a059e82587beea08a6328f0d7e20e904d26c130b76234d3f44176f28233d1a16",
"pins" : [
{
"identity" : "indexstore-db",
Expand Down
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,9 @@ let package:Package = .init(
.product(name: "BSONTesting", package: "swift-mongodb"),
]),

.executableTarget(name: "URITests",
.testTarget(name: "URITests",
dependencies: [
.target(name: "URI"),
.product(name: "Testing_", package: "swift-grammar"),
]),

.target(name: "guides", path: "Guides"),
Expand Down
2 changes: 1 addition & 1 deletion Sources/SymbolGraphBuilder/SSGC.Compile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ extension SSGC
*/

@Flag(
name: [.customLong("pretty"), .customShort("p")],
name: [.customLong("pretty")],
help: """
Tell lib/SymbolGraphGen to pretty-print the JSON output, if possible
""")
Expand Down
12 changes: 1 addition & 11 deletions Sources/URI/URI.Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extension URI
public
var parameters:[Parameter]

@inlinable internal
@inlinable
init(_ parameters:[Parameter])
{
self.parameters = parameters
Expand Down Expand Up @@ -94,16 +94,6 @@ extension URI.Query:LosslessStringConvertible
}
}
}
extension URI.Query
{
/// Parses query parameters from UTF-8 text. This parser does not expect a leading
/// question mark (`?`).
public static
func parse(parameters:[UInt8]) throws -> Self
{
.init(try URI.QueryRule<Int>.Parameters.parse(parameters))
}
}
extension URI.Query:Equatable
{
public static
Expand Down
52 changes: 52 additions & 0 deletions Sources/URI/URI.QueryEncodedForm.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
extension URI
{
@frozen public
struct QueryEncodedForm:Sendable
{
public
var parameters:[Query.Parameter]

private
init(_ parameters:[Query.Parameter])
{
self.parameters = parameters
}
}
}
extension URI.QueryEncodedForm
{
@inlinable public
var query:URI.Query { .init(self.parameters) }
}
extension URI.QueryEncodedForm
{
/// FIXME: This is hideously inefficient. We probably want to use a custom parser
/// that can transform the `+` characters without copying the entire string into an array!
private static
func parse(utf8:consuming [UInt8]) throws -> Self
{
for i:Int in utf8.indices
{
if utf8[i] == 0x2B
{
utf8[i] = 0x20
}
}

return .init(try URI.QueryRule<Int>.Parameters.parse(utf8))
}

/// Parses query parameters from UTF-8 text. This parser does not expect a leading
/// question mark (`?`).
public static
func parse(parameters:ArraySlice<UInt8>) throws -> Self
{
try .parse(utf8: [UInt8].init(parameters))
}

public static
func parse(parameters:Substring) throws -> Self
{
try .parse(utf8: [UInt8].init(parameters.utf8))
}
}
81 changes: 81 additions & 0 deletions Sources/URITests/AbsoluteParsing.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import Testing
import URI

@Suite
struct AbsoluteParsing
{
@Test
static func Empty() throws
{
#expect(URI.init("") == nil)
}

@Test
static func OneSlash() throws
{
let uri:URI = try #require(.init("/"))
#expect(uri.path == [])
}

@Test
static func TwoSlashes() throws
{
let uri:URI = try #require(.init("//"))
#expect(uri.path == ["", ""])
}

@Test
static func OneComponent() throws
{
let uri:URI = try #require(.init("/abc"))
#expect(uri.path == ["abc"])
}

@Test
static func ManyComponents() throws
{
let uri:URI = try #require(.init("/abc/def/ghi"))
#expect(uri.path == ["abc", "def", "ghi"])
}

@Test
static func TrailingSlash() throws
{
let uri:URI = try #require(.init("/abc/"))
#expect(uri.path == ["abc", ""])
}

@Test
static func SpecialComponents() throws
{
let uri:URI = try #require(.init(#"//foo/bar/.\bax.qux/..//baz./.Foo/%2E%2E//"#))
#expect(uri.path == [
"",
"foo",
"bar",
"",
"bax.qux",
.pop,
"",
"baz.",
".Foo",
"..",
"",
""
])
}

@Test
static func Normalization() throws
{
let uri:URI = try #require(.init(#"//foo/bar/.\bax.qux/..//baz./.Foo/%2E%2E//"#))
#expect(uri.path.normalized() == ["foo", "bar", "baz.", ".Foo", ".."])
}

@Test
static func OverNormalization() throws
{
let uri:URI = try #require(.init("/abc/../../../../def"))
#expect(uri.path.normalized() == ["def"])
}
}
22 changes: 22 additions & 0 deletions Sources/URITests/Array (ext).swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
extension [(key:String, value:String)]
{
static func == (a:Self, b:Self) -> Bool
{
guard a.count == b.count
else
{
return false
}

for (a, b):(Element, Element) in zip(a, b)
{
guard a.key == b.key, a.value == b.value
else
{
return false
}
}

return true
}
}
20 changes: 20 additions & 0 deletions Sources/URITests/FragmentParsing.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Testing
import URI

@Suite
struct FragmentParsing
{
@Test
static func Fragment() throws
{
let fragment:URI.Fragment = try #require(.init(decoding: "Parameters"))
#expect(fragment.decoded == "Parameters")
}

@Test
static func FragmentWithSpaces() throws
{
let fragment:URI.Fragment = try #require(.init(decoding: "Getting%20started"))
#expect(fragment.decoded == "Getting started")
}
}
122 changes: 0 additions & 122 deletions Sources/URITests/Main.Parsing.swift

This file was deleted.

11 changes: 0 additions & 11 deletions Sources/URITests/Main.swift

This file was deleted.

Loading
Loading