Skip to content

Commit 201f01f

Browse files
Revert "Transform DocC archives for static hosting by default (#121) (#136)" (#147)
This reverts commit ce886e5. SwiftCI integration tests have started failing on the 5.7 branch since this landed. Reverting appears to resolve the issue. We should be able to re-merge this after resolving the testing issue. rdar://91638258
1 parent 4d3ff2e commit 201f01f

File tree

3 files changed

+6
-120
lines changed

3 files changed

+6
-120
lines changed

Sources/SwiftDocC/Infrastructure/Diagnostics/Diagnostic.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,7 @@ public struct Diagnostic: DescribedError {
6666
/// the second *X* while adding a note on the first *X* to note that it was the first occurrence.
6767
public var notes = [DiagnosticNote]()
6868

69-
public init(
70-
source: URL? = nil,
71-
severity: DiagnosticSeverity,
72-
range: SourceRange? = nil,
73-
identifier: String,
74-
summary: String,
75-
explanation: String? = nil,
76-
notes: [DiagnosticNote] = []
77-
) {
69+
public init(source: URL?, severity: DiagnosticSeverity, range: SourceRange?, identifier: String, summary: String, explanation: String? = nil, notes: [DiagnosticNote] = []) {
7870
self.source = source
7971
self.severity = severity
8072
self.range = range

Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/Convert.swift

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,9 @@ extension Docc {
238238
return outputURL
239239
}
240240

241-
/// A Boolean value that is true if the DocC archive produced by this conversion
242-
/// will support static hosting environments.
243-
///
244-
/// This value defaults to true but can be explicitly disabled with the
245-
/// `--no-transform-for-static-hosting` flag.
246-
@Flag(
247-
inversion: .prefixedNo,
248-
exclusivity: .exclusive,
249-
help: "Produce a DocC archive that supports static hosting environments."
250-
)
251-
public var transformForStaticHosting = true
241+
/// Defaults to false
242+
@Flag(help: "Produce a Swift-DocC Archive that supports a static hosting environment.")
243+
public var transformForStaticHosting = false
252244

253245
/// A user-provided relative path to be used in the archived output
254246
@Option(
@@ -259,10 +251,6 @@ extension Docc {
259251
)
260252
var hostingBasePath: String?
261253

262-
/// The file handle that should be used for emitting warnings during argument validation.
263-
///
264-
/// Provided as a static variable to allow for redirecting output in unit tests.
265-
static var _errorLogHandle: LogHandle = .standardError
266254

267255
// MARK: - Property Validation
268256

@@ -300,29 +288,9 @@ extension Docc {
300288
}
301289

302290
} else {
303-
let invalidOrMissingTemplateDiagnostic = Diagnostic(
304-
severity: .warning,
305-
identifier: "org.swift.docc.MissingHTMLTemplate",
306-
summary: "Invalid or missing HTML template directory",
307-
explanation: """
308-
Invalid or missing HTML template directory, relative to the docc \
309-
executable, at: '\(templateOption.defaultTemplateURL.path)'.
310-
Set the '\(TemplateOption.environmentVariableKey)' environment variable \
311-
to use a custom HTML template.
312-
313-
Conversion will continue, but the produced DocC archive will not be \
314-
compatible with static hosting environments.
315-
316-
Pass the '--no-transform-for-static-hosting' flag to silence this warning.
317-
"""
318-
)
319-
320-
print(
321-
invalidOrMissingTemplateDiagnostic.localizedDescription,
322-
to: &Self._errorLogHandle
291+
throw TemplateOption.missingHTMLTemplateError(
292+
path: templateOption.defaultTemplateURL.path
323293
)
324-
325-
transformForStaticHosting = false
326294
}
327295
}
328296

Tests/SwiftDocCUtilitiesTests/ArgumentParsing/ConvertSubcommandTests.swift

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ class ConvertSubcommandTests: XCTestCase {
2020
private let testTemplateURL = Bundle.module.url(
2121
forResource: "Test Template", withExtension: nil, subdirectory: "Test Resources")!
2222

23-
override func setUp() {
24-
// By default, send all warnings to `.none` instead of filling the
25-
// test console output with unrelated messages.
26-
Docc.Convert._errorLogHandle = .none
27-
}
28-
2923
func testOptionsValidation() throws {
3024
// create source bundle directory
3125
let sourceURL = try createTemporaryDirectory(named: "documentation")
@@ -369,72 +363,4 @@ class ConvertSubcommandTests: XCTestCase {
369363
XCTAssertTrue(commandWithFlag.experimentalEnableCustomTemplates)
370364
XCTAssertTrue(actionWithFlag.experimentalEnableCustomTemplates)
371365
}
372-
373-
func testTransformForStaticHostingFlagWithoutHTMLTemplate() throws {
374-
unsetenv(TemplateOption.environmentVariableKey)
375-
376-
// Since there's no custom template set (and relative HTML template lookup isn't
377-
// supported in the test harness), we expect `transformForStaticHosting` to
378-
// be false in every possible scenario of the flag, even when explicitly requested.
379-
380-
do {
381-
let convertOptions = try Docc.Convert.parse([
382-
testBundleURL.path,
383-
])
384-
385-
XCTAssertFalse(convertOptions.transformForStaticHosting)
386-
}
387-
388-
do {
389-
let convertOptions = try Docc.Convert.parse([
390-
testBundleURL.path,
391-
"--transform-for-static-hosting",
392-
])
393-
394-
XCTAssertFalse(convertOptions.transformForStaticHosting)
395-
}
396-
397-
do {
398-
let convertOptions = try Docc.Convert.parse([
399-
testBundleURL.path,
400-
"--no-transform-for-static-hosting",
401-
])
402-
403-
XCTAssertFalse(convertOptions.transformForStaticHosting)
404-
}
405-
}
406-
407-
func testTransformForStaticHostingFlagWithHTMLTemplate() throws {
408-
setenv(TemplateOption.environmentVariableKey, testTemplateURL.path, 1)
409-
410-
// Since we've provided an HTML template, we expect `transformForStaticHosting`
411-
// to be true by default, and when explicitly requested. It should only be false
412-
// when `--no-transform-for-static-hosting` is passed.
413-
414-
do {
415-
let convertOptions = try Docc.Convert.parse([
416-
testBundleURL.path,
417-
])
418-
419-
XCTAssertTrue(convertOptions.transformForStaticHosting)
420-
}
421-
422-
do {
423-
let convertOptions = try Docc.Convert.parse([
424-
testBundleURL.path,
425-
"--transform-for-static-hosting",
426-
])
427-
428-
XCTAssertTrue(convertOptions.transformForStaticHosting)
429-
}
430-
431-
do {
432-
let convertOptions = try Docc.Convert.parse([
433-
testBundleURL.path,
434-
"--no-transform-for-static-hosting",
435-
])
436-
437-
XCTAssertFalse(convertOptions.transformForStaticHosting)
438-
}
439-
}
440366
}

0 commit comments

Comments
 (0)