-
Notifications
You must be signed in to change notification settings - Fork 55
Feat: New plugin flag for skipping synthesized symbols #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ethan-kusters
merged 6 commits into
swiftlang:main
from
sofiaromorales:sr/issue-27/skipping-synthesized-symbols
Mar 13, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3eec2d8
Feat: New plugin flag for skipping synthesized symbols
sofiaromorales b20147a
fix: Changes requested
sofiaromorales fa7bb7e
Merge branch 'main'
sofiaromorales debd20c
Merge branch 'main'
sofiaromorales 5e2eb78
refactor: changes to standardize code with the strategy used in #34
sofiaromorales 19ec1ac
refactor: address review comments
sofiaromorales File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
IntegrationTests/Tests/DocCConvertSynthesizedSymbolsTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
import XCTest | ||
|
||
final class DocCConvertSynthesizedSymbolsTests: ConcurrencyRequiringTestCase { | ||
func testGenerateDocumentationWithSkipSynthesizedSymbolsEnabled() throws { | ||
let result = try swiftPackage( | ||
"generate-documentation", "--experimental-skip-synthesized-symbols", | ||
workingDirectory: try setupTemporaryDirectoryForFixture(named: "PackageWithConformanceSymbols") | ||
) | ||
|
||
result.assertExitStatusEquals(0) | ||
let doccArchiveURL = try XCTUnwrap(result.referencedDocCArchives.first) | ||
let dataDirectoryContents = try filesIn(.dataSubdirectory, of: doccArchiveURL) | ||
XCTAssertEqual( | ||
Set(dataDirectoryContents.map(\.lastTwoPathComponents)), | ||
[ | ||
"documentation/packagewithconformancesymbols.json", | ||
"packagewithconformancesymbols/foo.json" | ||
] | ||
) | ||
} | ||
|
||
func testGenerateDocumentationWithSynthesizedSymbols() throws { | ||
let result = try swiftPackage( | ||
"generate-documentation", | ||
workingDirectory: try setupTemporaryDirectoryForFixture(named: "PackageWithConformanceSymbols") | ||
) | ||
|
||
result.assertExitStatusEquals(0) | ||
let doccArchiveURL = try XCTUnwrap(result.referencedDocCArchives.first) | ||
let dataDirectoryContents = try filesIn(.dataSubdirectory, of: doccArchiveURL) | ||
XCTAssertEqual( | ||
Set(dataDirectoryContents.map(\.lastTwoPathComponents)), | ||
[ | ||
"documentation/packagewithconformancesymbols.json", | ||
"packagewithconformancesymbols/foo.json", | ||
"foo/equatable-implementations.json", | ||
"foo/!=(_:_:).json" | ||
] | ||
) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
IntegrationTests/Tests/Fixtures/PackageWithConformanceSymbols/Package.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// swift-tools-version: 5.6 | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
import Foundation | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "PackageWithConformanceSymbols", | ||
targets: [ | ||
.target(name: "PackageWithConformanceSymbols") | ||
] | ||
) | ||
|
||
// We only expect 'swift-docc-plugin' to be a sibling when this package | ||
// is running as part of a test. | ||
// | ||
// This allows the package to compile outside of tests for easier | ||
// test development. | ||
if FileManager.default.fileExists(atPath: "../swift-docc-plugin") { | ||
package.dependencies += [ | ||
.package(path: "../swift-docc-plugin"), | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
...ixtures/PackageWithConformanceSymbols/Sources/PackageWithConformanceSymbols/FooTest.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
public struct Foo: Hashable { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,7 +182,8 @@ public struct ParsedArguments { | |
|
||
private static let argumentsTransformers: [ArgumentsTransforming] = [ | ||
PluginFlag.disableIndex, | ||
PluginFlag.extendedTypes | ||
PluginFlag.extendedTypes, | ||
PluginFlag.skipSynthesizedSymbols | ||
] | ||
} | ||
|
||
|
@@ -201,7 +202,8 @@ private extension ParsedArguments { | |
switch self { | ||
case .dumpSymbolGraph: | ||
return [ | ||
PluginFlag.extendedTypes | ||
PluginFlag.extendedTypes, | ||
PluginFlag.skipSynthesizedSymbols | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed along the same strategy as in #34 since |
||
] | ||
case .docc: | ||
return [] | ||
|
24 changes: 24 additions & 0 deletions
24
Sources/SwiftDocCPluginUtilities/PluginFlags/SkipSynthesizedSymbolsFlag.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
extension PluginFlag { | ||
/// Exclude synthesized symbols from the generated documentation. | ||
/// | ||
/// `--experimental-skip-synthesized-symbols` produces a DocC archive without compiler synthesized symbols. | ||
static let skipSynthesizedSymbols = PluginFlag( | ||
parsedValues: [ | ||
"--experimental-skip-synthesized-symbols" | ||
], | ||
abstract: "Exclude synthesized symbols from the generated documentation", | ||
description: """ | ||
Experimental feature that produces a DocC archive without compiler synthesized symbols. | ||
""", | ||
argumentTransformation: { $0 } | ||
) | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Tests/SwiftDocCPluginUtilitiesTests/PluginFlags/SkipSynthesizedSymbolsFlagTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2022 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
|
||
import Foundation | ||
@testable import SwiftDocCPluginUtilities | ||
import XCTest | ||
|
||
final class SkipSynthesizedSymbolsFlagTests: XCTestCase { | ||
func testNotTransformExistingFlagsWhenPresent() { | ||
XCTAssertEqual( | ||
PluginFlag.skipSynthesizedSymbols.transform( | ||
["--index", "--other-flag"] | ||
), | ||
["--index", "--other-flag"] | ||
) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.