feat: More styles, renames some items.
This commit is contained in:
11
Sources/CliDoc/Nodes/Empty.swift
Normal file
11
Sources/CliDoc/Nodes/Empty.swift
Normal file
@@ -0,0 +1,11 @@
|
||||
/// An empty text node.
|
||||
public struct Empty: TextNode {
|
||||
|
||||
@inlinable
|
||||
public init() {}
|
||||
|
||||
@inlinable
|
||||
public var body: some TextNode {
|
||||
""
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import Rainbow
|
||||
|
||||
public struct Examples<Header: TextNode, Label: TextNode>: TextNode {
|
||||
public struct ExampleSection<Header: TextNode, Label: TextNode>: TextNode {
|
||||
public typealias Example = (label: String, example: String)
|
||||
|
||||
@usableFromInline
|
||||
@@ -25,24 +25,11 @@ public struct Examples<Header: TextNode, Label: TextNode>: TextNode {
|
||||
|
||||
@inlinable
|
||||
public var body: some TextNode {
|
||||
VStack(spacing: 2) {
|
||||
HStack {
|
||||
header
|
||||
label
|
||||
}
|
||||
VStack(spacing: 2) {
|
||||
self.examples.map { example in
|
||||
VStack {
|
||||
CliDoc.Label(example.label.green.bold)
|
||||
ShellCommand { example.example.italic }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
style(.default())
|
||||
}
|
||||
}
|
||||
|
||||
public extension Examples where Header == String, Label == String {
|
||||
public extension ExampleSection where Header == String, Label == String {
|
||||
@inlinable
|
||||
init(
|
||||
header: String = "Examples:".yellow.bold,
|
||||
|
||||
@@ -18,10 +18,7 @@ public struct Note<Label: TextNode, Content: TextNode>: TextNode {
|
||||
|
||||
@inlinable
|
||||
public var body: some TextNode {
|
||||
HStack {
|
||||
label
|
||||
content
|
||||
}
|
||||
noteStyle(.default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,16 @@ public struct ShellCommand<Content: TextNode>: TextNode {
|
||||
|
||||
@inlinable
|
||||
public var body: some TextNode {
|
||||
HStack {
|
||||
symbol
|
||||
content
|
||||
}
|
||||
style(.default)
|
||||
}
|
||||
}
|
||||
|
||||
public extension ShellCommand where Content == String {
|
||||
@inlinable
|
||||
init(
|
||||
_ content: String,
|
||||
symbol: any TextNode = "$"
|
||||
) {
|
||||
self.init(symbol: symbol) { content }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user