Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ let package = Package(
.target(
name: "SwiftDocC",
dependencies: [
.target(name: "DocCCommon"),
.product(name: "Markdown", package: "swift-markdown"),
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
.product(name: "CLMDB", package: "swift-lmdb"),
Expand All @@ -55,6 +56,7 @@ let package = Package(
name: "SwiftDocCTests",
dependencies: [
.target(name: "SwiftDocC"),
.target(name: "DocCCommon"),
.target(name: "SwiftDocCTestUtilities"),
],
resources: [
Expand All @@ -70,6 +72,7 @@ let package = Package(
name: "SwiftDocCUtilities",
dependencies: [
.target(name: "SwiftDocC"),
.target(name: "DocCCommon"),
.product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.macOS, .iOS, .linux, .android])),
.product(name: "ArgumentParser", package: "swift-argument-parser")
],
Expand All @@ -81,6 +84,7 @@ let package = Package(
dependencies: [
.target(name: "SwiftDocCUtilities"),
.target(name: "SwiftDocC"),
.target(name: "DocCCommon"),
.target(name: "SwiftDocCTestUtilities"),
],
resources: [
Expand All @@ -95,6 +99,7 @@ let package = Package(
name: "SwiftDocCTestUtilities",
dependencies: [
.target(name: "SwiftDocC"),
.target(name: "DocCCommon"),
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
],
swiftSettings: swiftSettings
Expand All @@ -109,6 +114,25 @@ let package = Package(
exclude: ["CMakeLists.txt"],
swiftSettings: swiftSettings
),

// A few common types and core functionality that's useable by all other targets.
.target(
name: "DocCCommon",
dependencies: [
// This target shouldn't have any local dependencies so that all other targets can depend on it.
// We can add dependencies on SymbolKit and Markdown here but they're not needed yet.
],
swiftSettings: [.swiftLanguageMode(.v6)]
),

.testTarget(
name: "DocCCommonTests",
dependencies: [
.target(name: "DocCCommon"),
.target(name: "SwiftDocCTestUtilities"),
],
swiftSettings: [.swiftLanguageMode(.v6)]
),

// Test app for SwiftDocCUtilities
.executableTarget(
Expand Down
1 change: 1 addition & 0 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Licensed under Apache License v2.0 with Runtime Library Exception
See https://swift.org/LICENSE.txt for license information
#]]

add_subdirectory(DocCCommon)
add_subdirectory(SwiftDocC)
add_subdirectory(SwiftDocCUtilities)
add_subdirectory(docc)
11 changes: 11 additions & 0 deletions Sources/DocCCommon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[[
This source file is part of the Swift open source project

Copyright © 2014 - 2025 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
#]]

add_library(DocCCommon STATIC
SourceLanguage.swift)
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
Copyright (c) 2021-2025 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
*/

/// A programming language.
public struct SourceLanguage: Hashable, Codable, Comparable {
public struct SourceLanguage: Hashable, Codable, Comparable, Sendable {
/// The display name of the programming language.
public var name: String
/// A globally unique identifier for the language.
Expand Down Expand Up @@ -132,7 +132,7 @@ public struct SourceLanguage: Hashable, Codable, Comparable {
public static let metal = SourceLanguage(name: "Metal", id: "metal")

/// The list of programming languages that are known to DocC.
public static var knownLanguages: [SourceLanguage] = [.swift, .objectiveC, .javaScript, .data, .metal]
public static let knownLanguages: [SourceLanguage] = [.swift, .objectiveC, .javaScript, .data, .metal]

enum CodingKeys: CodingKey {
case name
Expand All @@ -157,7 +157,9 @@ public struct SourceLanguage: Hashable, Codable, Comparable {

try container.encode(self.name, forKey: SourceLanguage.CodingKeys.name)
try container.encode(self.id, forKey: SourceLanguage.CodingKeys.id)
try container.encodeIfNotEmpty(self.idAliases, forKey: SourceLanguage.CodingKeys.idAliases)
if !self.idAliases.isEmpty {
try container.encode(self.idAliases, forKey: SourceLanguage.CodingKeys.idAliases)
}
try container.encode(self.linkDisambiguationID, forKey: SourceLanguage.CodingKeys.linkDisambiguationID)
}

Expand Down
30 changes: 16 additions & 14 deletions Sources/SwiftDocC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ See https://swift.org/LICENSE.txt for license information
add_library(SwiftDocC
Benchmark/Benchmark.swift
Benchmark/BenchmarkResults.swift
Benchmark/Metrics.swift
Benchmark/Metrics/Duration.swift
Benchmark/Metrics/ExternalTopicsHash.swift
Benchmark/Metrics/OutputSize.swift
Benchmark/Metrics/PeakMemory.swift
Benchmark/Metrics/TopicAnchorHash.swift
Benchmark/Metrics/TopicGraphHash.swift
Benchmark/Metrics.swift
"Catalog Processing/GeneratedCurationWriter.swift"
Checker/Checker.swift
Checker/Checkers/AbstractContainsFormattedTextOnly.swift
Expand Down Expand Up @@ -198,16 +198,16 @@ add_library(SwiftDocC
Model/Rendering/RenderContentCompiler.swift
Model/Rendering/RenderContentConvertible.swift
Model/Rendering/RenderContext.swift
Model/Rendering/RenderNode.Tag.swift
Model/Rendering/RenderNode.swift
Model/Rendering/RenderNodeTranslator.swift
Model/Rendering/RenderNodeVariant.swift
Model/Rendering/RenderNode/AnyMetadata.swift
Model/Rendering/RenderNode/CodableContentSection.swift
Model/Rendering/RenderNode/CodableRenderReference.swift
Model/Rendering/RenderNode/CodableRenderSection.swift
Model/Rendering/RenderNode/RenderMetadata.swift
Model/Rendering/RenderNode/RenderNode+Codable.swift
Model/Rendering/RenderNode.swift
Model/Rendering/RenderNode.Tag.swift
Model/Rendering/RenderNodeTranslator.swift
Model/Rendering/RenderNodeVariant.swift
Model/Rendering/RenderReferenceStore.swift
Model/Rendering/RenderSection.swift
Model/Rendering/RenderSectionTranslator/AttributesSectionTranslator.swift
Expand Down Expand Up @@ -238,22 +238,22 @@ add_library(SwiftDocC
Model/Rendering/Symbol/PossibleValuesRenderSection.swift
Model/Rendering/Symbol/PropertiesRenderSection.swift
Model/Rendering/Symbol/PropertyListDetailsRenderSection.swift
Model/Rendering/Symbol/RelationshipsRenderSection.swift
Model/Rendering/Symbol/RESTBodyRenderSection.swift
Model/Rendering/Symbol/RESTEndpointRenderSection.swift
Model/Rendering/Symbol/RESTExampleRenderSection.swift
Model/Rendering/Symbol/RESTParametersRenderSection.swift
Model/Rendering/Symbol/RESTResponseRenderSection.swift
Model/Rendering/Symbol/RelationshipsRenderSection.swift
Model/Rendering/Symbol/SampleDownloadSection.swift
Model/Rendering/Symbol/TaskGroupRenderSection.swift
Model/Rendering/TopicsSectionStyle.swift
"Model/Rendering/Tutorial Article/TutorialArticleSection.swift"
Model/Rendering/Tutorial/LineHighlighter.swift
Model/Rendering/Tutorial/References/DownloadReference.swift
Model/Rendering/Tutorial/References/XcodeRequirementReference.swift
Model/Rendering/Tutorial/Sections/IntroRenderSection.swift
Model/Rendering/Tutorial/Sections/TutorialAssessmentsRenderSection.swift
Model/Rendering/Tutorial/Sections/TutorialSectionsRenderSection.swift
"Model/Rendering/Tutorial Article/TutorialArticleSection.swift"
"Model/Rendering/Tutorials Overview/Resources/RenderTile.swift"
"Model/Rendering/Tutorials Overview/Sections/CallToActionSection.swift"
"Model/Rendering/Tutorials Overview/Sections/ContentAndMediaGroupSection.swift"
Expand Down Expand Up @@ -299,7 +299,6 @@ add_library(SwiftDocC
Model/Semantics/Parameter.swift
Model/Semantics/Return.swift
Model/Semantics/Throw.swift
Model/SourceLanguage.swift
Model/TaskGroup.swift
Semantics/Abstracted.swift
Semantics/Article/Article.swift
Expand Down Expand Up @@ -358,11 +357,11 @@ add_library(SwiftDocC
Semantics/Options/TopicsVisualStyle.swift
Semantics/Redirect.swift
Semantics/Redirected.swift
Semantics/ReferenceResolver.swift
Semantics/Reference/Links.swift
Semantics/Reference/Row.swift
Semantics/Reference/Small.swift
Semantics/Reference/TabNavigator.swift
Semantics/ReferenceResolver.swift
Semantics/Semantic.swift
Semantics/SemanticAnalyzer.swift
Semantics/Snippets/Snippet.swift
Expand All @@ -381,6 +380,8 @@ add_library(SwiftDocC
Semantics/Technology/Volume/Volume.swift
Semantics/Timed.swift
Semantics/Titled.swift
Semantics/TutorialArticle/Stack.swift
Semantics/TutorialArticle/TutorialArticle.swift
Semantics/Tutorial/Assessments/Assessments.swift
"Semantics/Tutorial/Assessments/Multiple Choice/Choice/Choice.swift"
"Semantics/Tutorial/Assessments/Multiple Choice/Choice/Justification.swift"
Expand All @@ -391,8 +392,6 @@ add_library(SwiftDocC
Semantics/Tutorial/Tasks/TutorialSection.swift
Semantics/Tutorial/Tutorial.swift
Semantics/Tutorial/XcodeRequirement.swift
Semantics/TutorialArticle/Stack.swift
Semantics/TutorialArticle/TutorialArticle.swift
Semantics/Visitor/SemanticVisitor.swift
Semantics/Walker/SemanticWalker.swift
Semantics/Walker/Walkers/SemanticTreeDumper.swift
Expand All @@ -402,6 +401,7 @@ add_library(SwiftDocC
Utility/Checksum.swift
Utility/Collection+ConcurrentPerform.swift
Utility/CollectionChanges.swift
Utility/CommonTypeExports.swift
Utility/DataStructures/BidirectionalMap.swift
Utility/DataStructures/GroupedSequence.swift
Utility/DispatchGroup+Async.swift
Expand Down Expand Up @@ -440,14 +440,14 @@ add_library(SwiftDocC
Utility/Graphs/DirectedGraph+Paths.swift
Utility/Graphs/DirectedGraph+Traversal.swift
Utility/Graphs/DirectedGraph.swift
Utility/Language/EnglishLanguage.swift
Utility/Language/NativeLanguage.swift
Utility/ListItemUpdatable.swift
Utility/LMDB/LMDB+Database.swift
Utility/LMDB/LMDB+Environment.swift
Utility/LMDB/LMDB+Error.swift
Utility/LMDB/LMDB+Transaction.swift
Utility/LMDB/LMDB.swift
Utility/Language/EnglishLanguage.swift
Utility/Language/NativeLanguage.swift
Utility/ListItemUpdatable.swift
Utility/LogHandle.swift
Utility/MarkupExtensions/AnyLink.swift
Utility/MarkupExtensions/BlockDirectiveExtensions.swift
Expand All @@ -463,6 +463,8 @@ add_library(SwiftDocC
Utility/Synchronization.swift
Utility/ValidatedURL.swift
Utility/Version.swift)
target_link_libraries(SwiftDocC PRIVATE
DocCCommon)
target_link_libraries(SwiftDocC PUBLIC
SwiftMarkdown::Markdown
DocC::SymbolKit
Expand Down
13 changes: 13 additions & 0 deletions Sources/SwiftDocC/Utility/CommonTypeExports.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2025 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 import DocCCommon

public typealias SourceLanguage = DocCCommon.SourceLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

@testable import SwiftDocC
import DocCCommon
import XCTest

class SourceLanguageTests: XCTestCase {
Expand Down