Skip to content

Commit 155ef45

Browse files
author
Jesse Haigh
committed
rename feature flag
1 parent 2987eac commit 155ef45

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

Sources/SwiftDocC/Infrastructure/Workspace/FeatureFlags+Info.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ extension DocumentationBundle.Info {
3737
self.unknownFeatureFlags = []
3838
}
3939

40-
/// This feature flag corresponds to ``FeatureFlags/isExperimentalCodeBlockEnabled``.
41-
public var experimentalCodeBlock: Bool?
40+
/// This feature flag corresponds to ``FeatureFlags/isExperimentalCodeBlockAnnotationsEnabled``.
41+
public var experimentalCodeBlockAnnotations: Bool?
4242

43-
public init(experimentalCodeBlock: Bool? = nil) {
44-
self.experimentalCodeBlock = experimentalCodeBlock
43+
public init(experimentalCodeBlockAnnotations: Bool? = nil) {
44+
self.experimentalCodeBlockAnnotations = experimentalCodeBlockAnnotations
4545
self.unknownFeatureFlags = []
4646
}
4747

@@ -50,7 +50,7 @@ extension DocumentationBundle.Info {
5050

5151
enum CodingKeys: String, CodingKey, CaseIterable {
5252
case experimentalOverloadedSymbolPresentation = "ExperimentalOverloadedSymbolPresentation"
53-
case experimentalCodeBlock = "ExperimentalCodeBlock"
53+
case experimentalCodeBlockAnnotations = "ExperimentalCodeBlockAnnotations"
5454
}
5555

5656
struct AnyCodingKeys: CodingKey {
@@ -76,8 +76,8 @@ extension DocumentationBundle.Info {
7676
case .experimentalOverloadedSymbolPresentation:
7777
self.experimentalOverloadedSymbolPresentation = try values.decode(Bool.self, forKey: flagName)
7878

79-
case .experimentalCodeBlock:
80-
self.experimentalCodeBlock = try values.decode(Bool.self, forKey: flagName)
79+
case .experimentalCodeBlockAnnotations:
80+
self.experimentalCodeBlockAnnotations = try values.decode(Bool.self, forKey: flagName)
8181
}
8282
} else {
8383
unknownFeatureFlags.append(flagName.stringValue)
@@ -91,7 +91,7 @@ extension DocumentationBundle.Info {
9191
var container = encoder.container(keyedBy: CodingKeys.self)
9292

9393
try container.encode(experimentalOverloadedSymbolPresentation, forKey: .experimentalOverloadedSymbolPresentation)
94-
try container.encode(experimentalCodeBlock, forKey: .experimentalCodeBlock)
94+
try container.encode(experimentalCodeBlockAnnotations, forKey: .experimentalCodeBlockAnnotations)
9595
}
9696
}
9797
}

Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ extension RenderBlockContent: Codable {
733733
}
734734
self = try .aside(.init(style: style, content: container.decode([RenderBlockContent].self, forKey: .content)))
735735
case .codeListing:
736-
let copy = FeatureFlags.current.isExperimentalCodeBlockEnabled
736+
let copy = FeatureFlags.current.isExperimentalCodeBlockAnnotationsEnabled
737737
self = try .codeListing(.init(
738738
syntax: container.decodeIfPresent(String.self, forKey: .syntax),
739739
code: container.decode([String].self, forKey: .code),

Sources/SwiftDocC/Model/Rendering/RenderContentCompiler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct RenderContentCompiler: MarkupVisitor {
4848
mutating func visitCodeBlock(_ codeBlock: CodeBlock) -> [any RenderContent] {
4949
// Default to the bundle's code listing syntax if one is not explicitly declared in the code block.
5050

51-
if FeatureFlags.current.isExperimentalCodeBlockEnabled {
51+
if FeatureFlags.current.isExperimentalCodeBlockAnnotationsEnabled {
5252

5353
func parseLanguageString(_ input: String?) -> (lang: String? , tokens: [RenderBlockContent.CodeListing.OptionName]) {
5454
guard let input else { return (lang: nil, tokens: []) }

Sources/SwiftDocC/Semantics/Snippets/Snippet.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ extension Snippet: RenderableDirectiveConvertible {
8383
let lines = snippetMixin.lines[lineRange]
8484
let minimumIndentation = lines.map { $0.prefix { $0.isWhitespace }.count }.min() ?? 0
8585
let trimmedLines = lines.map { String($0.dropFirst(minimumIndentation)) }
86-
let copy = FeatureFlags.current.isExperimentalCodeBlockEnabled
86+
let copy = FeatureFlags.current.isExperimentalCodeBlockAnnotationsEnabled
8787
return [RenderBlockContent.codeListing(.init(syntax: snippetMixin.language, code: trimmedLines, metadata: nil, copyToClipboard: copy))]
8888
} else {
8989
// Render the whole snippet with its explanation content.
9090
let docCommentContent = snippetEntity.markup.children.flatMap { contentCompiler.visit($0) }
91-
let copy = FeatureFlags.current.isExperimentalCodeBlockEnabled
91+
let copy = FeatureFlags.current.isExperimentalCodeBlockAnnotationsEnabled
9292
let code = RenderBlockContent.codeListing(.init(syntax: snippetMixin.language, code: snippetMixin.lines, metadata: nil, copyToClipboard: copy))
9393
return docCommentContent + [code]
9494
}

Sources/SwiftDocC/Utility/FeatureFlags.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public struct FeatureFlags: Codable {
1515
public static var current = FeatureFlags()
1616

1717
/// Whether or not experimental annotation of code blocks is enabled.
18-
public var isExperimentalCodeBlockEnabled = false
18+
public var isExperimentalCodeBlockAnnotationsEnabled = false
1919

2020
/// Whether or not experimental support for device frames on images and video is enabled.
2121
public var isExperimentalDeviceFrameSupportEnabled = false

Sources/SwiftDocCUtilities/ArgumentParsing/ActionExtensions/ConvertAction+CommandInitialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extension ConvertAction {
1919
public init(fromConvertCommand convert: Docc.Convert, withFallbackTemplate fallbackTemplateURL: URL? = nil) throws {
2020
var standardError = LogHandle.standardError
2121
let outOfProcessResolver: OutOfProcessReferenceResolver?
22-
FeatureFlags.current.isExperimentalCodeBlockEnabled = convert.enableExperimentalCodeBlock
22+
FeatureFlags.current.isExperimentalCodeBlockAnnotationsEnabled = convert.featureFlags.enableExperimentalCodeBlockAnnotations
2323
FeatureFlags.current.isExperimentalDeviceFrameSupportEnabled = convert.enableExperimentalDeviceFrameSupport
2424
FeatureFlags.current.isExperimentalLinkHierarchySerializationEnabled = convert.enableExperimentalLinkHierarchySerialization
2525
FeatureFlags.current.isExperimentalOverloadedSymbolPresentationEnabled = convert.enableExperimentalOverloadedSymbolPresentation

Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/Convert.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,10 @@ extension Docc {
477477
var experimentalEnableCustomTemplates = false
478478

479479
@Flag(
480-
name: .customLong("enable-experimental-code-block"),
481-
help: "Support copy-to-clipboard for code blocks."
480+
name: .customLong("enable-experimental-code-block-annotations"),
481+
help: "Support annotations for code blocks."
482482
)
483-
var enableExperimentalCodeBlock = false
483+
var enableExperimentalCodeBlockAnnotations = false
484484

485485
@Flag(help: .hidden)
486486
var enableExperimentalDeviceFrameSupport = false
@@ -567,9 +567,9 @@ extension Docc {
567567
/// A user-provided value that is true if the user enables experimental support for code block annotation.
568568
///
569569
/// Defaults to false.
570-
public var enableExperimentalCodeBlock: Bool {
571-
get { featureFlags.enableExperimentalCodeBlock }
572-
set { featureFlags.enableExperimentalCodeBlock = newValue}
570+
public var enableExperimentalCodeBlocAnnotations: Bool {
571+
get { featureFlags.enableExperimentalCodeBlockAnnotations }
572+
set { featureFlags.enableExperimentalCodeBlockAnnotations = newValue}
573573
}
574574

575575
/// A user-provided value that is true if the user enables experimental support for device frames.

Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class RenderContentCompilerTests: XCTestCase {
225225
}
226226

227227
func testCopyToClipboard() async throws {
228-
enableFeatureFlag(\.isExperimentalCodeBlockEnabled)
228+
enableFeatureFlag(\.isExperimentalCodeBlockAnnotationsEnabled)
229229

230230
let (bundle, context) = try await testBundleAndContext()
231231
var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift))
@@ -249,7 +249,7 @@ class RenderContentCompilerTests: XCTestCase {
249249
}
250250

251251
func testNoCopyToClipboard() async throws {
252-
enableFeatureFlag(\.isExperimentalCodeBlockEnabled)
252+
enableFeatureFlag(\.isExperimentalCodeBlockAnnotationsEnabled)
253253

254254
let (bundle, context) = try await testBundleAndContext()
255255
var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleID: bundle.id, path: "/path", fragment: nil, sourceLanguage: .swift))

0 commit comments

Comments
 (0)