feat: Working on documentation
This commit is contained in:
8
Examples/.gitignore
vendored
Normal file
8
Examples/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/configuration/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
||||
24
Examples/Package.resolved
Normal file
24
Examples/Package.resolved
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"originHash" : "afba34e2c2164a53d5b868cb4ece6f0e542fcaed383f1b226ed9179283d0e060",
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "rainbow",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/onevcat/Rainbow",
|
||||
"state" : {
|
||||
"revision" : "e0dada9cd44e3fa7ec3b867e49a8ddbf543e3df3",
|
||||
"version" : "4.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "swift-argument-parser",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apple/swift-argument-parser",
|
||||
"state" : {
|
||||
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
|
||||
"version" : "1.5.0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 3
|
||||
}
|
||||
27
Examples/Package.swift
Normal file
27
Examples/Package.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
// swift-tools-version: 6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "CliDoc-Examples",
|
||||
products: [
|
||||
.executable(name: "examples", targets: ["CliDoc-Examples"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../"),
|
||||
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0")
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "CliDoc-Examples",
|
||||
dependencies: [
|
||||
.product(name: "CliDoc", package: "swift-cli-doc"),
|
||||
.product(name: "ArgumentParser", package: "swift-argument-parser")
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "CliDoc-ExamplesTests",
|
||||
dependencies: ["CliDoc-Examples"]
|
||||
)
|
||||
]
|
||||
)
|
||||
14
Examples/Sources/CliDoc-Examples/CliDoc_Examples.swift
Normal file
14
Examples/Sources/CliDoc-Examples/CliDoc_Examples.swift
Normal file
@@ -0,0 +1,14 @@
|
||||
import ArgumentParser
|
||||
import CliDoc
|
||||
|
||||
@main
|
||||
struct Application: ParsableCommand {
|
||||
static var configuration: CommandConfiguration {
|
||||
.init(
|
||||
commandName: "examples",
|
||||
subcommands: [
|
||||
SectionCommand.self
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
30
Examples/Sources/CliDoc-Examples/SectionCommand.swift
Normal file
30
Examples/Sources/CliDoc-Examples/SectionCommand.swift
Normal file
@@ -0,0 +1,30 @@
|
||||
import ArgumentParser
|
||||
import CliDocCore
|
||||
|
||||
struct SectionCommand: ParsableCommand {
|
||||
|
||||
static var configuration: CommandConfiguration {
|
||||
.init(commandName: "section")
|
||||
}
|
||||
|
||||
func run() throws {
|
||||
let section = Section {
|
||||
"My super awesome section"
|
||||
} header: {
|
||||
"Awesome"
|
||||
} footer: {
|
||||
"Note: this is super awesome"
|
||||
}
|
||||
print(section.style(MySectionStyle()).render())
|
||||
}
|
||||
}
|
||||
|
||||
struct MySectionStyle: SectionStyle {
|
||||
func render(content: SectionConfiguration) -> some TextNode {
|
||||
VStack(separator: .newLine(count: 2)) {
|
||||
content.header.color(.green).bold().underline()
|
||||
content.content
|
||||
content.footer.italic()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import Testing
|
||||
@testable import CliDoc_Examples
|
||||
|
||||
@Test func example() async throws {
|
||||
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||
}
|
||||
3
Examples/justfile
Normal file
3
Examples/justfile
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
run command="section":
|
||||
swift run examples {{command}}
|
||||
Reference in New Issue
Block a user