I have a Swift package where the code is in modules as shown below:
.
├── Package.swift
├── Sources/
│ ├── MatrixModule/
│ │ ├── DataBuffer.swift
│ │ ├── IntegerArithmetic.swift
│ │ └── Matrix.swift
│ ├── Numerical/
│ │ ├── Documentation.docc/
│ │ │ ├── Documentation.md
│ │ │ └── Resources/
│ │ └── Numerical.swift
│ └── VectorModule/
│ ├── DataBuffer.swift
│ ├── IntegerAlgebra.swift
│ ├── IntegerArithmetic.swift
│ ├── RealAlgebra.swift
│ ├── RealArithmetic.swift
│ └── Vector.swift
└── Tests/
├── MatrixTests.swift
└── VectorTests.swift
The contents of the Package.swift file looks like this:
import PackageDescription
let package = Package(
name: "Numerical",
platforms: [.macOS(.v14), .iOS(.v17), .tvOS(.v17), .watchOS(.v10), .visionOS(.v1)],
products: [
.library(name: "Numerical", targets: ["Numerical"])
],
targets: [
.target(
name: "Numerical",
dependencies: ["VectorModule", "MatrixModule"],
cxxSettings: [.define("ACCELERATE_NEW_LAPACK", to: "1"), .define("ACCELERATE_LAPACK_ILP64", to: "1")],
linkerSettings: [.linkedFramework("Accelerate")]
),
.target(
name: "VectorModule",
cxxSettings: [.define("ACCELERATE_NEW_LAPACK", to: "1"), .define("ACCELERATE_LAPACK_ILP64", to: "1")],
linkerSettings: [.linkedFramework("Accelerate")]
),
.target(
name: "MatrixModule",
cxxSettings: [.define("ACCELERATE_NEW_LAPACK", to: "1"), .define("ACCELERATE_LAPACK_ILP64", to: "1")],
linkerSettings: [.linkedFramework("Accelerate")]
),
.testTarget(name: "Tests", dependencies: ["Numerical"])
]
)
The Numerical.swift file imports the modules as shown below so a user of the package only has to do import Numerical
to get the vector and matrix types.
@_exported import VectorModule
@_exported import MatrixModule
I have some questions about documenting a package like this:
- Where should I put the DocC catalog? I put the DocC catalog in the
Numerical/
directory but is that the proper location? Can I put the DocC catalog at the top-level of theSources/
directory? Or should I put a DocC catalog in the module directories then link to those catalogs from the main catalog? I would like to just have one DocC catalog for the entire package. - Is there anything special I need to do with the
.spi.yml
file for the Swift Package Index website to host the documentation?