Skip to content

Wrap references to public types in comments in double backticks #1702

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
merged 1 commit into from
Jun 1, 2023
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
4 changes: 2 additions & 2 deletions CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ public let COMMON_NODES: [Node] = [
Child(
name: "Attributes",
kind: .collection(kind: .attributeList, collectionElementName: "Attribute"),
documentation: "If there were standalone attributes without a declaration to attach them to, the `MissingDeclSyntax` will contain these.",
documentation: "If there were standalone attributes without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these.",
isOptional: true
),
Child(
name: "Modifiers",
kind: .collection(kind: .modifierList, collectionElementName: "Modifier"),
documentation: "If there were standalone modifiers without a declaration to attach them to, the `MissingDeclSyntax` will contain these.",
documentation: "If there were standalone modifiers without a declaration to attach them to, the ``MissingDeclSyntax`` will contain these.",
isOptional: true
),
Child(
Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ public let EXPR_NODES: [Node] = [
kind: .exprList,
base: .syntaxCollection,
nameForDiagnostics: nil,
documentation: "A list of expressions connected by operators. This list is contained by a `SequenceExprSyntax`.",
documentation: "A list of expressions connected by operators. This list is contained by a ``SequenceExprSyntax``.",
elementChoices: [.expr]
),

Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/Utils/CodeGenerationFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class CodeGenerationFormat: BasicFormat {
// MARK: - Private

private func shouldBeSeparatedByTwoNewlines(node: CodeBlockItemSyntax) -> Bool {
// First item in the `CodeBlockItemListSyntax` don't need a newline or identation if the parent is a `SourceFileSyntax`.
// First item in the ``CodeBlockItemListSyntax`` don't need a newline or identation if the parent is a ``SourceFileSyntax``.
// We want to group imports so newline between them should be omitted
return node.parent?.as(CodeBlockItemListSyntax.self)?.first == node || node.item.is(ImportDeclSyntax.self)
}
Expand Down
6 changes: 3 additions & 3 deletions CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public enum SyntaxOrTokenNodeKind: Hashable {
case token(tokenKind: String)
}

/// Extension to the `Child` type to provide functionality specific to
/// Extension to the ``Child`` type to provide functionality specific to
/// SwiftSyntaxBuilder.
public extension Child {
/// The type of this child, represented by a `SyntaxBuildableType`, which can
/// The type of this child, represented by a ``SyntaxBuildableType``, which can
/// be used to create the corresponding `Buildable` and `ExpressibleAs` types.
var type: SyntaxBuildableType {
let buildableKind: SyntaxOrTokenNodeKind
Expand Down Expand Up @@ -96,7 +96,7 @@ public extension Child {

/// If this node is a token that can't contain arbitrary text, generate a Swift
/// `precondition` statement that verifies the variable with name var_name and of type
/// `TokenSyntax` contains one of the supported text options. Otherwise return `nil`.
/// ``TokenSyntax`` contains one of the supported text options. Otherwise return `nil`.
func generateAssertStmtTextChoices(varName: String) -> FunctionCallExprSyntax? {
guard case .token(choices: let choices, requiresLeadingSpace: _, requiresTrailingSpace: _) = kind else {
return nil
Expand Down
6 changes: 3 additions & 3 deletions CodeGeneration/Sources/Utils/SyntaxBuildableNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

import SyntaxSupport

/// Extension to the `Node` type to provide functionality specific to
/// Extension to the ``Node`` type to provide functionality specific to
/// SwiftSyntaxBuilder.
public extension Node {
/// The node's syntax kind as `SyntaxBuildableType`.
/// The node's syntax kind as ``SyntaxBuildableType``.
var type: SyntaxBuildableType {
SyntaxBuildableType(kind: .node(kind: kind))
}

/// The node's syntax kind as `SyntaxBuildableType`.
/// The node's syntax kind as ``SyntaxBuildableType``.
var baseType: SyntaxBuildableType {
if base == .syntaxCollection {
return SyntaxBuildableType(kind: .node(kind: .syntax))
Expand Down
2 changes: 1 addition & 1 deletion CodeGeneration/Sources/Utils/SyntaxBuildableType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public struct SyntaxBuildableType: Hashable {
/// These names look as follows:
/// - For nodes: The node name, e.g. `IdentifierExpr` (these are implemented as structs)
/// - For base kinds: `<BaseKind>Buildable`, e.g. `ExprBuildable` (these are implemented as protocols)
/// - For token: `TokenSyntax` (tokens don't have a dedicated type in SwiftSyntaxBuilder)
/// - For token: ``TokenSyntax`` (tokens don't have a dedicated type in SwiftSyntaxBuilder)
/// If the type is optional, the type is wrapped in an `OptionalType`.
public var buildable: TypeSyntax {
optionalWrapped(type: SimpleTypeIdentifierSyntax(name: .identifier(syntaxBaseName)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let keywordFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
/// This is really unfortunate. Really, we should have a `switch` in
/// `Keyword.defaultText` to return the keyword's kind but the constant lookup
/// table is significantly faster. Ideally, we could also get the compiler to
/// constant-evaluate `Keyword.spi.defaultText` to a `SyntaxText` but I don't
/// constant-evaluate `Keyword.spi.defaultText` to a ``SyntaxText`` but I don't
/// see how that's possible right now.
private static let keywordTextLookupTable: [SyntaxText] = \(lookupTable)
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Utils
let syntaxAnyVisitorFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
try! ClassDeclSyntax(
"""
/// A `SyntaxVisitor` that can visit the nodes as generic `Syntax` values.
/// A `SyntaxVisitor` that can visit the nodes as generic ``Syntax`` values.
///
/// This subclass of `SyntaxVisitor` is slower than the type-specific visitation
/// of `SyntaxVisitor`. Use `SyntaxAnyVisitor` if the `visitAny(_)` function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
"""
// MARK: - \(node.kind.syntaxType)

/// Protocol to which all `\(node.kind.syntaxType)` nodes conform. Extension point to add
/// common methods to all `\(node.kind.syntaxType)` nodes.
/// Protocol to which all ``\(node.kind.syntaxType)`` nodes conform. Extension point to add
/// common methods to all ``\(node.kind.syntaxType)`` nodes.
/// DO NOT CONFORM TO THIS PROTOCOL YOURSELF!
public protocol \(node.kind.protocolType): \(raw: node.base.protocolType) {}
"""
Expand Down Expand Up @@ -62,7 +62,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Create a `\(node.kind.syntaxType)` node from a specialized syntax node.
/// Create a ``\(node.kind.syntaxType)`` node from a specialized syntax node.
public init(_ syntax: some \(node.kind.protocolType)) {
// We know this cast is going to succeed. Go through init(_: SyntaxData)
// to do a sanity check and verify the kind matches in debug builds and get
Expand All @@ -74,7 +74,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Create a `\(node.kind.syntaxType)` node from a specialized optional syntax node.
/// Create a ``\(node.kind.syntaxType)`` node from a specialized optional syntax node.
public init?(_ syntax: (some \(node.kind.protocolType))?) {
guard let syntax = syntax else { return nil }
self.init(syntax)
Expand All @@ -95,7 +95,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Create a `\(node.kind.syntaxType)` node from a specialized optional syntax node.
/// Create a ``\(node.kind.syntaxType)`` node from a specialized optional syntax node.
public init?(fromProtocol syntax: \(node.kind.protocolType)?) {
guard let syntax = syntax else { return nil }
self.init(fromProtocol: syntax)
Expand Down Expand Up @@ -131,8 +131,8 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

try InitializerDeclSyntax(
"""
/// Creates a `\(node.kind.syntaxType)` node from the given `SyntaxData`. This assumes
/// that the `SyntaxData` is of the correct kind. If it is not, the behaviour
/// Creates a ``\(node.kind.syntaxType)`` node from the given ``SyntaxData``. This assumes
/// that the ``SyntaxData`` is of the correct kind. If it is not, the behaviour
/// is undefined.
internal init(_ data: SyntaxData)
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
!node.documentation.isEmpty
? node.documentation
: """
/// `\(node.kind.syntaxType)` represents a collection of one or more
/// `\(node.collectionElementType.syntaxBaseName)` nodes. \(node.kind.syntaxType) behaves
/// ``\(node.kind.syntaxType)`` represents a collection of one or more
/// ``\(node.collectionElementType.syntaxBaseName)`` nodes. ``\(node.kind.syntaxType)`` behaves
/// as a regular Swift collection, and has accessors that return new
/// versions of the collection with different children.
"""
Expand Down Expand Up @@ -187,12 +187,12 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Creates a new `\(node.kind.syntaxType)` by replacing the underlying layout with
/// Creates a new ``\(node.kind.syntaxType)`` by replacing the underlying layout with
/// a different set of raw syntax nodes.
///
/// - Parameter layout: The new list of raw syntax nodes underlying this
/// collection.
/// - Returns: A new `\(node.kind.syntaxType)` with the new layout underlying it.
/// - Returns: A new ``\(node.kind.syntaxType)`` with the new layout underlying it.
internal func replacingLayout(_ layout: [RawSyntax?]) -> \(node.kind.syntaxType) {
let arena = SyntaxArena()
let newRaw = layoutView.replacingLayout(with: layout, arena: arena)
Expand All @@ -204,11 +204,11 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Creates a new `\(node.kind.syntaxType)` by appending the provided syntax element
/// Creates a new ``\(node.kind.syntaxType)`` by appending the provided syntax element
/// to the children.
///
/// - Parameter syntax: The element to append.
/// - Returns: A new `\(node.kind.syntaxType)` with that element appended to the end.
/// - Returns: A new ``\(node.kind.syntaxType)`` with that element appended to the end.
public func appending(_ syntax: Element) -> \(node.kind.syntaxType) {
var newLayout = layoutView.formLayoutArray()
newLayout.append(syntax.raw)
Expand All @@ -219,11 +219,11 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Creates a new `\(node.kind.syntaxType)` by prepending the provided syntax element
/// Creates a new ``\(node.kind.syntaxType)`` by prepending the provided syntax element
/// to the children.
///
/// - Parameter syntax: The element to prepend.
/// - Returns: A new `\(node.kind.syntaxType)` with that element prepended to the
/// - Returns: A new ``\(node.kind.syntaxType)`` with that element prepended to the
/// beginning.
public func prepending(_ syntax: Element) -> \(node.kind.syntaxType) {
return inserting(syntax, at: 0)
Expand All @@ -233,14 +233,14 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Creates a new `\(node.kind.syntaxType)` by inserting the provided syntax element
/// Creates a new ``\(node.kind.syntaxType)`` by inserting the provided syntax element
/// at the provided index in the children.
///
/// - Parameters:
/// - syntax: The element to insert.
/// - index: The index at which to insert the element in the collection.
///
/// - Returns: A new `\(node.kind.syntaxType)` with that element appended to the end.
/// - Returns: A new ``\(node.kind.syntaxType)`` with that element appended to the end.
public func inserting(_ syntax: Element, at index: Int) -> \(node.kind.syntaxType) {
var newLayout = layoutView.formLayoutArray()
/// Make sure the index is a valid insertion index (0 to 1 past the end)
Expand All @@ -254,14 +254,14 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Creates a new `\(node.kind.syntaxType)` by replacing the syntax element
/// Creates a new ``\(node.kind.syntaxType)`` by replacing the syntax element
/// at the provided index.
///
/// - Parameters:
/// - index: The index at which to replace the element in the collection.
/// - syntax: The element to replace with.
///
/// - Returns: A new `\(node.kind.syntaxType)` with the new element at the provided index.
/// - Returns: A new ``\(node.kind.syntaxType)`` with the new element at the provided index.
public func replacing(childAt index: Int, with syntax: Element) -> \(node.kind.syntaxType) {
var newLayout = layoutView.formLayoutArray()
/// Make sure the index is a valid index for replacing
Expand All @@ -275,11 +275,11 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Creates a new `\(node.kind.syntaxType)` by removing the syntax element at the
/// Creates a new ``\(node.kind.syntaxType)`` by removing the syntax element at the
/// provided index.
///
/// - Parameter index: The index of the element to remove from the collection.
/// - Returns: A new `\(node.kind.syntaxType)` with the element at the provided index
/// - Returns: A new ``\(node.kind.syntaxType)`` with the element at the provided index
/// removed.
public func removing(childAt index: Int) -> \(node.kind.syntaxType) {
var newLayout = layoutView.formLayoutArray()
Expand All @@ -291,9 +291,9 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Creates a new `\(node.kind.syntaxType)` by removing the first element.
/// Creates a new ``\(node.kind.syntaxType)`` by removing the first element.
///
/// - Returns: A new `\(node.kind.syntaxType)` with the first element removed.
/// - Returns: A new ``\(node.kind.syntaxType)`` with the first element removed.
public func removingFirst() -> \(node.kind.syntaxType) {
var newLayout = layoutView.formLayoutArray()
newLayout.removeFirst()
Expand All @@ -304,9 +304,9 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Creates a new `\(node.kind.syntaxType)` by removing the last element.
/// Creates a new ``\(node.kind.syntaxType)`` by removing the last element.
///
/// - Returns: A new `\(node.kind.syntaxType)` with the last element removed.
/// - Returns: A new ``\(node.kind.syntaxType)`` with the last element removed.
public func removingLast() -> \(node.kind.syntaxType) {
var newLayout = layoutView.formLayoutArray()
newLayout.removeLast()
Expand All @@ -318,7 +318,7 @@ let syntaxCollectionsFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

try! ExtensionDeclSyntax(
"""
/// Conformance for `\(node.kind.syntaxType)` to the `BidirectionalCollection` protocol.
/// Conformance for ``\(node.kind.syntaxType)`` to the `BidirectionalCollection` protocol.
extension \(node.kind.syntaxType): BidirectionalCollection
"""
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax {

DeclSyntax(
"""
/// Creates a `\(node.kind.syntaxType)` node from the given `SyntaxData`. This assumes
/// Creates a ``\(node.kind.syntaxType)`` node from the given ``SyntaxData``. This assumes
/// that the `SyntaxData` is of the correct kind. If it is not, the behaviour
/// is undefined.
internal init(_ data: SyntaxData) {
Expand Down Expand Up @@ -192,7 +192,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax {

DeclSyntax(
"""
/// Adds the provided `\(raw: childElt)` to the node's `\(raw: child.varName)`
/// Adds the provided `element` to the node's `\(raw: child.varName)`
/// collection.
/// - param element: The new `\(raw: childElt)` to add to the node's
/// `\(raw: child.varName)` collection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
if (node.base == .syntax || node.base == .syntaxCollection) && node.kind != .missing {
DeclSyntax(
"""
/// Visit a `\(node.kind.syntaxType)`.
/// Visit a ``\(node.kind.syntaxType)``.
/// - Parameter node: the node that is being visited
/// - Returns: the rewritten node
open func visit(_ node: \(node.kind.syntaxType)) -> \(node.kind.syntaxType) {
Expand All @@ -47,7 +47,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
} else {
DeclSyntax(
"""
/// Visit a `\(node.kind.syntaxType)`.
/// Visit a ``\(node.kind.syntaxType)``.
/// - Parameter node: the node that is being visited
/// - Returns: the rewritten node
open func visit(_ node: \(node.kind.syntaxType)) -> \(raw: node.baseType.syntaxBaseName) {
Expand All @@ -60,7 +60,7 @@ let syntaxRewriterFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {

DeclSyntax(
"""
/// Visit a `TokenSyntax`.
/// Visit a ``TokenSyntax``.
/// - Parameter node: the node that is being visited
/// - Returns: the rewritten node
open func visit(_ token: TokenSyntax) -> TokenSyntax {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let syntaxTransformFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
for node in SYNTAX_NODES where !node.kind.isBase {
DeclSyntax(
"""
/// Visiting `\(node.kind.syntaxType)` specifically.
/// Visiting ``\(node.kind.syntaxType)`` specifically.
/// - Parameter node: the node we are visiting.
/// - Returns: the sum of whatever the child visitors return.
func visit(_ node: \(node.kind.syntaxType)) -> ResultType
Expand All @@ -47,7 +47,7 @@ let syntaxTransformFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
for node in SYNTAX_NODES where !node.kind.isBase {
DeclSyntax(
"""
/// Visiting `\(node.kind.syntaxType)` specifically.
/// Visiting ``\(node.kind.syntaxType)`` specifically.
/// - Parameter node: the node we are visiting.
/// - Returns: nil by default.
public func visit(_ node: \(node.kind.syntaxType)) -> ResultType {
Expand Down
Loading