Skip to content
Open
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
Make a number of RenderNode constants vars
This updates some of the properties in the RenderNode tree to be mutable. A number of the top-level properties in RenderNode are already mutable, and making these additional properties mutable as well allows callers to modify these values.

rdar://164748009
  • Loading branch information
mayaepps committed Nov 14, 2025
commit 28ffa0a3fc7429a560b3a5bbbc94ca03d138815f
34 changes: 17 additions & 17 deletions Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ public enum RenderBlockContent: Equatable {
/// A list of rendering block elements.
public typealias Cell = [RenderBlockContent]
/// The list of row cells.
public let cells: [Cell]
public var cells: [Cell]

/// Creates a new table row.
/// - Parameter cells: The list of row cells to use.
Expand Down Expand Up @@ -692,18 +692,18 @@ public enum RenderBlockContent: Equatable {
/// A term rendered as content.
public struct Term: Codable, Equatable {
/// The term content.
public let inlineContent: [RenderInlineContent]
public var inlineContent: [RenderInlineContent]
}
/// A definition rendered as a list of block-content elements.
public struct Definition: Codable, Equatable {
/// The definition content.
public let content: [RenderBlockContent]
public var content: [RenderBlockContent]
}

/// The term in the term-list item.
public let term: Term
public var term: Term
/// The definition in the term-list item.
public let definition: Definition
public var definition: Definition
}

/// A row in a grid-based layout system that describes a collection of columns.
Expand All @@ -713,18 +713,18 @@ public enum RenderBlockContent: Equatable {
/// This may be different then the count of ``columns`` array. For example, there may be
/// individual columns that span multiple columns (specified with the column's
/// ``Column/size`` property) or the row could be not fully filled with columns.
public let numberOfColumns: Int
public var numberOfColumns: Int

/// The columns that should be rendered in this row.
public let columns: [Column]
public var columns: [Column]

/// A column with a row in a grid-based layout system.
public struct Column: Codable, Equatable {
/// The number of columns in the parent row this column should span.
public let size: Int
public var size: Int

/// The content that should be rendered in this column.
public let content: [RenderBlockContent]
public var content: [RenderBlockContent]
}
}

Expand All @@ -734,21 +734,21 @@ public enum RenderBlockContent: Equatable {
/// license, or copyright text.
public struct Small: Codable, Equatable {
/// The inline content that should be rendered.
public let inlineContent: [RenderInlineContent]
public var inlineContent: [RenderInlineContent]
}

/// A collection of content that should be rendered in a tab-based layout.
public struct TabNavigator: Codable, Equatable {
/// The tabs that make up this tab navigator.
public let tabs: [Tab]
public var tabs: [Tab]

/// A titled tab inside a tab-based layout container.
public struct Tab: Codable, Equatable {
/// The title that should be used to identify this tab.
public let title: String
public var title: String

/// The content that should be rendered in this tab.
public let content: [RenderBlockContent]
public var content: [RenderBlockContent]
}
}

Expand All @@ -770,10 +770,10 @@ public enum RenderBlockContent: Equatable {
}

/// The style that should be used when rendering the link items.
public let style: Style
public var style: Style

/// The topic render references for the pages that should be rendered in this links block.
public let items: [String]
public var items: [String]

/// Create a new links block with the given style and topic render references.
public init(style: RenderBlockContent.Links.Style, items: [String]) {
Expand All @@ -785,10 +785,10 @@ public enum RenderBlockContent: Equatable {
/// A video with an optional caption.
public struct Video: Codable, Equatable {
/// A reference to the video media that should be rendered in this block.
public let identifier: RenderReferenceIdentifier
public var identifier: RenderReferenceIdentifier

/// Any metadata associated with this video, like a caption.
public let metadata: RenderContentMetadata?
public var metadata: RenderContentMetadata?

/// Create a new video with the given identifier and metadata.
public init(identifier: RenderReferenceIdentifier, metadata: RenderContentMetadata? = nil) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDocC/Model/Rendering/RenderNode.Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public extension RenderNode {
/// The tag type.
let type: String
/// The text to display.
let text: String
var text: String

/// A pre-defined SPI tag.
static let spi = Tag(type: "spi", text: "SPI")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import Foundation
public struct AttributesRenderSection: RenderSection, Equatable {
public var kind: RenderSectionKind = .attributes
/// The section title.
public let title: String
public var title: String
/// The list of attributes in this section.
public let attributes: [RenderAttribute]?
public var attributes: [RenderAttribute]?

/// Creates a new attributes section.
/// - Parameter title: The section title.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public struct ConformanceSection: Codable, Equatable {
var conformancePrefix: [RenderInlineContent] = [.text("Conforms when")]

/// The section constraints rendered as inline content.
let constraints: [RenderInlineContent]
var constraints: [RenderInlineContent]

/// Additional parameters to consider when rendering conformance constraints.
struct ConstraintRenderOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public struct ParametersRenderSection: RenderSection, Equatable {
public var kind: RenderSectionKind = .parameters
/// The list of parameter sub-sections.
public let parameters: [ParameterRenderSection]
public var parameters: [ParameterRenderSection]

/// Creates a new parameters section with the given list.
public init(parameters: [ParameterRenderSection]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public struct PossibleValuesRenderSection: RenderSection, Equatable {
/// The value name.
let name: String
/// Details content, if any.
let content: [RenderBlockContent]?
var content: [RenderBlockContent]?
}

public var kind: RenderSectionKind = .possibleValues
/// The title for the section, `nil` by default.
public let title: String?
public var title: String?
/// The list of named values.
public let values: [NamedValue]
public var values: [NamedValue]

/// Creates a new possible values section.
/// - Parameter title: The section title.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import Foundation
public struct PropertiesRenderSection: RenderSection {
public var kind: RenderSectionKind = .properties
/// The title for this section.
public let title: String
public var title: String
/// The list of properties.
public let items: [RenderProperty]
public var items: [RenderProperty]

/// Creates a new property-list section.
/// - Parameters:
Expand Down Expand Up @@ -60,9 +60,9 @@ public struct RenderProperty: Codable, TextIndexing, Equatable {
/// The list of possible type declarations for the property's value including additional details, if available.
public let typeDetails: [TypeDetails]?
/// Additional details about the property, if available.
public let content: [RenderBlockContent]?
public var content: [RenderBlockContent]?
/// Additional list of attributes, if any.
public let attributes: [RenderAttribute]?
public var attributes: [RenderAttribute]?
/// A mime-type associated with the property, if applicable.
public let mimeType: String?
/// If true, the property is required in its containing context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Foundation
public struct RESTBodyRenderSection: RenderSection, Equatable {
public var kind: RenderSectionKind = .restBody
/// A title for the section.
public let title: String
public var title: String

/// Content encoding MIME type for the request body.
public let mimeType: String
Expand All @@ -23,14 +23,14 @@ public struct RESTBodyRenderSection: RenderSection, Equatable {
public let bodyContentType: [DeclarationRenderSection.Token]

/// Details about the request body, if available.
public let content: [RenderBlockContent]?
public var content: [RenderBlockContent]?

/// A list of request parameters, if applicable.
///
/// If the body content is `multipart/form-data` encoded, it contains a list
/// of parameters. Each of these parameters is a ``RESTParameter``
/// and it has its own value-content encoding, name, type, and description.
public let parameters: [RenderProperty]?
public var parameters: [RenderProperty]?

/// Creates a new REST body section.
/// - Parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct RESTEndpointRenderSection: RenderSection, Equatable {
}

/// The title for the section.
public let title: String
public var title: String

/// The list of tokens.
public let tokens: [Token]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public enum RESTParameterSource: String, Codable {
public struct RESTParametersRenderSection: RenderSection, Equatable {
public var kind: RenderSectionKind = .restParameters
/// The title for the section.
public let title: String
public var title: String
/// The list of REST parameters.
public let parameters: [RenderProperty]
public var parameters: [RenderProperty]
/// The kind of listed parameters.
public let source: RESTParameterSource

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import Foundation
public struct RESTResponseRenderSection: RenderSection, Equatable {
public var kind: RenderSectionKind = .restResponses
/// The title for the section.
public let title: String
public var title: String
/// The list of possible REST responses.
public let responses: [RESTResponse]
public var responses: [RESTResponse]

enum CodingKeys: String, CodingKey {
case kind
Expand Down Expand Up @@ -70,7 +70,7 @@ public struct RESTResponse: Codable, TextIndexing, Equatable {
/// A type declaration of the response's content.
public let type: [DeclarationRenderSection.Token]
/// Response details, if any.
public let content: [RenderBlockContent]?
public var content: [RenderBlockContent]?

/// Creates a new REST response section.
/// - Parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public struct TaskGroupRenderSection: RenderSection, Equatable {
public let kind: RenderSectionKind = .taskGroup

/// An optional title for the section.
public let title: String?
public var title: String?
/// An optional abstract summary for the section.
public let abstract: [RenderInlineContent]?
public var abstract: [RenderInlineContent]?
/// An optional discussion for the section.
public var discussion: (any RenderSection)? {
get {
Expand Down