Skip to content

Commit 748389d

Browse files
authored
Merge pull request #1366 from liveview-native/docs-use-style-attr
Use `style` attribute for generated docs
2 parents f7de946 + 9bfadde commit 748389d

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

Sources/ModifierGenerator/Subcommands/DocumentationExtensions.swift

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension ModifierGenerator {
1616
static let configuration = CommandConfiguration(abstract: "Output a list of the names of all available modifiers.")
1717

1818
@Option(
19-
help: "The `.swiftinterface` file from `/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-ios.swiftinterface`",
19+
help: "The `.swiftinterface` file from `/Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-xros.swiftinterface`",
2020
transform: { URL(filePath: $0) }
2121
)
2222
var interface: URL
@@ -156,25 +156,19 @@ extension ModifierGenerator {
156156
}
157157

158158
var result = ""
159+
let style: String
159160

160161
if parameters.isEmpty {
161-
result.append(#"""
162-
```elixir
163-
# stylesheet
164-
"example" do
165-
\#(name)()
166-
end
167-
```
168-
"""#)
162+
style = #"\#(name)()"#
169163
} else {
170-
result.append(#"""
171-
```elixir
172-
# stylesheet
173-
"example" do
174-
\#(name)(\#(parameters.joined(separator: ", ")))
175-
end
176-
```
177-
"""#)
164+
style = #"\#(name)(\#(parameters.joined(separator: ", ")))"#
165+
}
166+
167+
let quotedStyle: String
168+
if style.contains(#"""# as Character) {
169+
quotedStyle = #"'\#(style)'"#
170+
} else {
171+
quotedStyle = #""\#(style)""#
178172
}
179173

180174
let changeEvent: String? = switch changeTracked.count {
@@ -196,15 +190,15 @@ extension ModifierGenerator {
196190
197191
```html
198192
<%!-- template --%>
199-
<Element class="example" \#(resolvedAttributes.joined(separator: " ")) />
193+
<Element style=\#(quotedStyle) \#(resolvedAttributes.joined(separator: " ")) />
200194
```
201195
"""#)
202196
} else {
203197
result.append(#"""
204198
205199
```html
206200
<%!-- template --%>
207-
<Element class="example" \#(resolvedAttributes.joined(separator: " "))>
201+
<Element style=\#(quotedStyle) \#(resolvedAttributes.joined(separator: " "))>
208202
\#(templates.map({ " \($0)" }).joined(separator: "\n"))
209203
</Element>
210204
```
@@ -215,7 +209,7 @@ extension ModifierGenerator {
215209
216210
```html
217211
<%!-- template --%>
218-
<Element class="example">
212+
<Element style=\#(quotedStyle)>
219213
\#(templates.map({ " \($0)" }).joined(separator: "\n"))
220214
</Element>
221215
```

Sources/ModifierGenerator/Subcommands/List.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension ModifierGenerator {
99
static let configuration = CommandConfiguration(abstract: "Output a list of the names of all available modifiers.")
1010

1111
@Option(
12-
help: "The `.swiftinterface` file from `/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-ios.swiftinterface`",
12+
help: "The `.swiftinterface` file from `/Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-xros.swiftinterface`",
1313
transform: { URL(filePath: $0) }
1414
)
1515
var interface: URL?

Sources/ModifierGenerator/Subcommands/Schema.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension ModifierGenerator {
99
static let configuration = CommandConfiguration(abstract: "Generate a `stylesheet-language.json` file compatible with the VS Code extension.")
1010

1111
@Option(
12-
help: "The `.swiftinterface` file from `/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-ios.swiftinterface`",
12+
help: "The `.swiftinterface` file from `/Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-xros.swiftinterface`",
1313
transform: { URL(filePath: $0) }
1414
)
1515
var interface: URL?

lib/mix/tasks/lvn.swiftui.gen.docs.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule Mix.Tasks.Lvn.Swiftui.Gen.Docs do
77
# Using a temporary folder outside of the project avoids ElixirLS file watching issues
88
defp temp_doc_folder, do: Path.join(System.tmp_dir!(), "temp_swiftui_docs")
99
defp generate_swift_lvn_docs_command, do: ~c"xcodebuild docbuild -scheme LiveViewNative -destination generic/platform=iOS -derivedDataPath #{temp_doc_folder()} -skipMacroValidation -skipPackagePluginValidation"
10-
@swiftui_interface_path "Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-ios.swiftinterface"
10+
@swiftui_interface_path "Platforms/XROS.platform/Developer/SDKs/XROS.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-xros.swiftinterface"
1111
defp generate_modifier_documentation_extensions(xcode_path), do: ~c(xcrun swift run ModifierGenerator documentation-extensions --interface "#{Path.join(xcode_path, @swiftui_interface_path)}" --output Sources/LiveViewNative/LiveViewNative.docc/DocumentationExtensions)
1212
@generate_documentation_extensions ~c(xcrun swift package plugin --allow-writing-to-package-directory generate-documentation-extensions)
1313
defp modifier_list(xcode_path), do: ~s(xcrun swift run ModifierGenerator list --interface "#{Path.join(xcode_path, @swiftui_interface_path)}" --modifier-search-path Sources/LiveViewNative/Stylesheets/Modifiers)

0 commit comments

Comments
 (0)