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

Use SourceDocs lib to create a swift-based way to generate docs #1042

Merged
merged 4 commits into from
Feb 25, 2020
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DocumentationGenerator"
BuildableName = "DocumentationGenerator"
BlueprintName = "DocumentationGenerator"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DocumentationGenerator"
BuildableName = "DocumentationGenerator"
BlueprintName = "DocumentationGenerator"
ReferencedContainer = "container:">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DocumentationGenerator"
BuildableName = "DocumentationGenerator"
BlueprintName = "DocumentationGenerator"
ReferencedContainer = "container:">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
135 changes: 135 additions & 0 deletions SwiftScripts/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,96 @@
{
"object": {
"pins": [
{
"package": "Commandant",
"repositoryURL": "https://github.com/Carthage/Commandant.git",
"state": {
"branch": null,
"revision": "ab68611013dec67413628ac87c1f29e8427bc8e4",
"version": "0.17.0"
}
},
{
"package": "Curry",
"repositoryURL": "https://github.com/thoughtbot/Curry.git",
"state": {
"branch": null,
"revision": "4331dd50bc1db007db664a23f32e6f3df93d4e1a",
"version": "4.0.2"
}
},
{
"package": "CwlCatchException",
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "7cd2f8cacc4d22f21bc0b2309c3b18acf7957b66",
"version": "1.2.0"
}
},
{
"package": "CwlPreconditionTesting",
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "c228db5d2ad1b01ebc84435e823e6cca4e3db98b",
"version": "1.2.0"
}
},
{
"package": "MarkdownGenerator",
"repositoryURL": "https://github.com/eneko/MarkdownGenerator.git",
"state": {
"branch": null,
"revision": "1fc31be6b66245187c3f87f35d86b6aeac6dfe7f",
"version": "0.5.0"
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble.git",
"state": {
"branch": null,
"revision": "b02b00b30b6353632aa4a5fb6124f8147f7140c0",
"version": "8.0.5"
}
},
{
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick.git",
"state": {
"branch": null,
"revision": "33682c2f6230c60614861dfc61df267e11a1602f",
"version": "2.2.0"
}
},
{
"package": "Rainbow",
"repositoryURL": "https://github.com/onevcat/Rainbow",
"state": {
"branch": null,
"revision": "9c52c1952e9b2305d4507cf473392ac2d7c9b155",
"version": "3.1.5"
}
},
{
"package": "SourceDocs",
"repositoryURL": "https://github.com/designatednerd/SourceDocs.git",
"state": {
"branch": "master",
"revision": "990ca72f9a62f5ef6561d1a2187426c39088161e",
"version": null
}
},
{
"package": "SourceKitten",
"repositoryURL": "https://github.com/jpsim/SourceKitten.git",
"state": {
"branch": null,
"revision": "77a4dbbb477a8110eb8765e3c44c70fb4929098f",
"version": "0.29.0"
}
},
{
"package": "SQLite.swift",
"repositoryURL": "https://github.com/stephencelis/SQLite.swift.git",
Expand All @@ -19,6 +109,15 @@
"version": "3.1.1"
}
},
{
"package": "llbuild",
"repositoryURL": "https://github.com/apple/swift-llbuild.git",
"state": {
"branch": null,
"revision": "f1c9ad9a253cdf1aa89a7f5c99c30b4513b06ddb",
"version": "0.1.1"
}
},
{
"package": "swift-nio-zlib-support",
"repositoryURL": "https://github.com/apple/swift-nio-zlib-support.git",
Expand All @@ -28,6 +127,15 @@
"version": "1.0.0"
}
},
{
"package": "SwiftPM",
"repositoryURL": "https://github.com/apple/swift-package-manager.git",
"state": {
"branch": null,
"revision": "8656a25cb906c1896339f950ac960ee1b4fe8034",
"version": "0.4.0"
}
},
{
"package": "swift-tools-support-core",
"repositoryURL": "https://github.com/apple/swift-tools-support-core",
Expand All @@ -36,6 +144,33 @@
"revision": "693aba4c4c9dcc4767cc853a0dd38bf90ad8c258",
"version": "0.0.1"
}
},
{
"package": "SWXMLHash",
"repositoryURL": "https://github.com/drmohundro/SWXMLHash.git",
"state": {
"branch": null,
"revision": "a4931e5c3bafbedeb1601d3bb76bbe835c6d475a",
"version": "5.0.1"
}
},
{
"package": "System",
"repositoryURL": "https://github.com/eneko/System.git",
"state": {
"branch": null,
"revision": "381352d9479fb9c75d99a5ae5503f7d560c62449",
"version": "0.2.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "c947a306d2e80ecb2c0859047b35c73b8e1ca27f",
"version": "2.0.0"
}
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion SwiftScripts/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let package = Package(
dependencies: [
.package(path: ".."),
.package(url: "https://github.com/apple/swift-tools-support-core", from: "0.0.1"),
.package(url: "https://github.com/designatednerd/SourceDocs.git", .branch("master"))
],
targets: [
.target(
Expand All @@ -16,7 +17,7 @@ let package = Package(
.target(name: "SchemaDownload",
dependencies: ["ApolloCodegenLib"]),
.target(name: "DocumentationGenerator",
dependencies: []),
dependencies: ["ApolloCodegenLib", "SourceDocsLib"]),
.testTarget(
name: "CodegenTests",
dependencies: ["Codegen"]),
Expand Down
64 changes: 63 additions & 1 deletion SwiftScripts/Sources/DocumentationGenerator/main.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,66 @@
import Foundation
import SourceDocsLib
import ApolloCodegenLib

// TODO: Create this when I can import Sourcedocs as a library.
#warning("For some reason, this is failing when run directly from Xcode instead of with `swift run DocumentationGenerator`. So use that and not Xcode to run this for now")

enum Target: String, CaseIterable {
case Apollo
case ApolloSQLite
case ApolloWebSocket
case ApolloCodegenLib

var name: String {
self.rawValue
}

var scheme: String {
self.rawValue
}

var outputFolder: String {
self.rawValue
}
}

// Grab the parent folder of this file on the filesystem
let parentFolderOfScriptFile = FileFinder.findParentFolder()

// Use that to calculate the source root
let sourceRootURL = parentFolderOfScriptFile
.deletingLastPathComponent() // Sources
.deletingLastPathComponent() // SwiftScripts
.deletingLastPathComponent() // apollo-ios

for target in Target.allCases {
// Figure out where to put the docs for the current target.
let outputURL = sourceRootURL
.appendingPathComponent("docs")
.appendingPathComponent("source")
.appendingPathComponent("api")
.appendingPathComponent(target.outputFolder)


let options = GenerateCommandOptions(moduleName: target.name,
linkEndingText: "/",
inputFolder: sourceRootURL.path,
outputFolder: outputURL.path,
clean: true,
xcodeArguments: [
"-scheme",
target.scheme,
"-project",
"Apollo.xcodeproj"
])

let result = GenerateCommand().run(options)

switch result {
case .success:
CodegenLogger.log("Generated docs for \(target.name)")
case .failure(let error):
CodegenLogger.log("Error generating docs for \(target.name): \(error)", logLevel: .error)
exit(1)
}
}

2 changes: 1 addition & 1 deletion docs/source/api/Apollo/classes/ApolloClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ApolloClient
### `store`

```swift
public let store: ApolloStore // <- conformance to ApolloClientProtocol
public let store: ApolloStore
```

## Methods
Expand Down
7 changes: 7 additions & 0 deletions docs/source/api/Apollo/classes/GraphQLQueryWatcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ public final class GraphQLQueryWatcher<Query: GraphQLQuery>: Cancellable, Apollo

> A `GraphQLQueryWatcher` is responsible for watching the store, and calling the result handler with a new result whenever any of the data the previous result depends on changes.

## Properties
### `query`

```swift
public let query: Query
```

## Methods
### `init(client:query:resultHandler:)`

Expand Down
3 changes: 3 additions & 0 deletions docs/source/api/Apollo/extensions/ApolloClient.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**EXTENSION**

# `ApolloClient`
```swift
extension ApolloClient: ApolloClientProtocol
```

## Properties
### `cacheKeyForObject`
Expand Down
3 changes: 3 additions & 0 deletions docs/source/api/Apollo/extensions/Array.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**EXTENSION**

# `Array`
```swift
extension Array: GraphQLInputValue
```

## Properties
### `jsonValue`
Expand Down
3 changes: 3 additions & 0 deletions docs/source/api/Apollo/extensions/Atomic.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**EXTENSION**

# `Atomic`
```swift
public extension Atomic where T == Int
```

## Methods
### `increment()`
Expand Down
3 changes: 3 additions & 0 deletions docs/source/api/Apollo/extensions/Bool.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**EXTENSION**

# `Bool`
```swift
extension Bool: JSONDecodable, JSONEncodable
```

## Properties
### `jsonValue`
Expand Down
3 changes: 3 additions & 0 deletions docs/source/api/Apollo/extensions/Dictionary.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**EXTENSION**

# `Dictionary`
```swift
public extension Dictionary
```

## Properties
### `withNilValuesRemoved`
Expand Down
Loading