Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
helje5 committed Jul 19, 2021
2 parents 1a32fb5 + ff9db98 commit ce99609
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 7 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@ Blog entry on the topic: [DocC 📚 Archived and Analyzed](https://www.alwaysrig

### Status

2021-07-02: The module can import all documents created in the
The module can import all documents created in the
[SlothCreator](https://developer.apple.com/documentation/xcode/slothcreator_building_docc_documentation_in_xcode)
example.

It should be pretty complete, but specifically lacks testing with Objective-C
documentation.
It should be pretty complete.

If you find an issue (usually signalled by an assertion or fatalError),
please [*let us know*](https://github.com/DoccZz/DocCArchive/issues),
we'll fix missing cases ASAP (PRs are welcome too).

TODO:
- [ ] Add DocC documentation! 🤦‍♀️
- [ ] ~~Test with Objective-C documentation.~~ (looks like ObjC is unsupported by DocC?)
- [ ] Add a testsuite (existing one not added for sizing concerns).
- [x] Add a testsuite (existing one not added for sizing concerns).


### Usage in a Swift Package
Expand Down
4 changes: 2 additions & 2 deletions Sources/DocCArchive/Schema_0_1/Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension DocCArchive.DocCSchema_0_1 {

public var schemaVersion : SchemaVersion
public var identifier : Identifier
public var documentVersion : Int
public var documentVersion : Int?
public var kind : Kind
public var metadata : MetaData
public var hierarchy : Hierarchy
Expand All @@ -81,7 +81,7 @@ extension DocCArchive.DocCSchema_0_1 {
var ms = "<Document:"
ms += " schema=\(schemaVersion)"
ms += " identifier=\(identifier)"
ms += " version=\(documentVersion)"
if let v = documentVersion { ms += " version=\(v)" }
ms += " \(kind)"
ms += " \(metadata)"
ms += " \(hierarchy)"
Expand Down
19 changes: 19 additions & 0 deletions Tests/DocCArchiveTests/DocumentDecodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,27 @@ final class DocumentDecodingTests: XCTestCase {

static var allTests = [
( "testSimpleTutorial" , testSimpleTutorial ),
( "testIssue7Fail" , testIssue7Fail ),
( "testAllDataJSONInSlothCreator" , testAllDataJSONInSlothCreator )
]

func testIssue7Fail() throws {
let url = Fixtures.baseURL.appendingPathComponent("Issue7Fail.json")
let data = try Data(contentsOf: url)

let document : DocCArchive.Document

print("Decoding:", url.path)
do {
document = try JSONDecoder().decode(DocCArchive.Document.self, from: data)
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
return
}
XCTAssertEqual(document.schemaVersion, .init(major: 0, minor: 1, patch: 0))
}

func testSimpleTutorial() throws {
let url = Fixtures.baseURL.appendingPathComponent("SimpleTutorial.json")
Expand Down
5 changes: 5 additions & 0 deletions Tests/DocCArchiveTests/Fixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ enum Fixtures {
FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent("Downloads")
.appendingPathComponent("SlothCreator.doccarchive")

static let failJSON1 =
"""
{"primaryContentSections":[{"kind":"declarations","declarations":[{"tokens":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"HTTP"}],"languages":["swift"],"platforms":["macOS"]}]}],"schemaVersion":{"major":0,"minor":1,"patch":0},"sections":[],"variants":[{"paths":["/documentation/llabsnetwork/http"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"No overview available."}],"kind":"symbol","metadata":{"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"HTTP"}],"title":"HTTP","roleHeading":"Structure","role":"symbol","symbolKind":"struct","externalID":"s:12LLabsNetwork4HTTPV","modules":[{"name":"LLabsNetwork"}],"navigatorTitle":[{"kind":"identifier","text":"HTTP"}]},"hierarchy":{"paths":[["doc://LLabsNetwork/documentation/LLabsNetwork"]]},"topicSections":[{"title":"Enumerations","identifiers":["doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Code","doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Method"]}],"references":{"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP":{"role":"symbol","title":"HTTP","fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"HTTP"}],"abstract":[],"identifier":"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"HTTP"}],"url":"/documentation/llabsnetwork/http"},"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Method":{"role":"symbol","title":"HTTP.Method","fragments":[{"kind":"keyword","text":"enum"},{"kind":"text","text":" "},{"kind":"identifier","text":"Method"}],"abstract":[{"type":"text","text":"HTTP verbs."}],"identifier":"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Method","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"Method"}],"url":"/documentation/llabsnetwork/http/method"},"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Code":{"role":"symbol","title":"HTTP.Code","fragments":[{"kind":"keyword","text":"enum"},{"kind":"text","text":" "},{"kind":"identifier","text":"Code"}],"abstract":[{"type":"text","text":"A list of HTTP codes"}],"identifier":"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Code","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"Code"}],"url":"/documentation/llabsnetwork/http/code"},"doc://LLabsNetwork/documentation/LLabsNetwork":{"role":"collection","title":"LLabsNetwork","abstract":[],"identifier":"doc://LLabsNetwork/documentation/LLabsNetwork","kind":"symbol","type":"topic","url":"/documentation/llabsnetwork"}}}
"""
}
92 changes: 92 additions & 0 deletions Tests/DocCArchiveTests/Fixtures/Issue7Fail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"primaryContentSections":[
{"kind":"declarations",
"declarations":[
{"tokens":[
{"kind":"keyword","text":"struct"},
{"kind":"text","text":" "},
{"kind":"identifier","text":"HTTP"}
],
"languages":["swift"],
"platforms":["macOS"]
}
]
}
],
"schemaVersion":{"major":0,"minor":1,"patch":0},
"sections":[],
"variants":[
{"paths":["/documentation/llabsnetwork/http"],
"traits":[{"interfaceLanguage":"swift"}]}
],
"identifier":{
"url":"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP",
"interfaceLanguage":"swift"
},
"abstract":[
{"type":"text","text":"No overview available."}],
"kind":"symbol",
"metadata":{
"fragments":[
{"kind":"keyword","text":"struct"},
{"kind":"text","text":" "},
{"kind":"identifier","text":"HTTP"}
],
"title":"HTTP",
"roleHeading":"Structure",
"role":"symbol",
"symbolKind":"struct",
"externalID":"s:12LLabsNetwork4HTTPV",
"modules":[{"name":"LLabsNetwork"}],
"navigatorTitle":[{"kind":"identifier","text":"HTTP"}]

},
"hierarchy":{
"paths":[["doc://LLabsNetwork/documentation/LLabsNetwork"]]
},
"topicSections":[
{"title":"Enumerations","identifiers":["doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Code","doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Method"]}
],
"references":{
"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP":{
"role":"symbol","title":"HTTP",
"fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"HTTP"}],
"abstract":[],
"identifier":"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP",
"kind":"symbol","type":"topic",
"navigatorTitle":[
{"kind":"identifier","text":"HTTP"}
],
"url":"/documentation/llabsnetwork/http"
},
"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Method":{
"role":"symbol","title":"HTTP.Method",
"fragments":[
{"kind":"keyword","text":"enum"},
{"kind":"text","text":" "},
{"kind":"identifier","text":"Method"}
],
"abstract":[{"type":"text","text":"HTTP verbs."}],
"identifier":"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Method",
"kind":"symbol","type":"topic",
"navigatorTitle":[
{"kind":"identifier","text":"Method"}
],
"url":"/documentation/llabsnetwork/http/method"
},
"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Code":{
"role":"symbol","title":"HTTP.Code",
"fragments":[{"kind":"keyword","text":"enum"},{"kind":"text","text":" "},{"kind":"identifier","text":"Code"}],
"abstract":[{"type":"text","text":"A list of HTTP codes"}],
"identifier":"doc://LLabsNetwork/documentation/LLabsNetwork/HTTP/Code",
"kind":"symbol","type":"topic",
"navigatorTitle":[{"kind":"identifier","text":"Code"}],
"url":"/documentation/llabsnetwork/http/code"
},
"doc://LLabsNetwork/documentation/LLabsNetwork":{
"role":"collection","title":"LLabsNetwork","abstract":[],
"identifier":"doc://LLabsNetwork/documentation/LLabsNetwork",
"kind":"symbol","type":"topic","url":"/documentation/llabsnetwork"
}
}
}

0 comments on commit ce99609

Please sign in to comment.