Skip to content

Add a documentation article for @_spi and when to use existentials #1696

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 4 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ allows Swift tools to parse, inspect, generate, and transform Swift source code.
### Articles

- <doc:Working-with-SwiftSyntax>
- <doc:ChangingSwiftSyntax>
- <doc:Create-SwiftSyntax-Release>

### Tutorials

- <doc:Tutorial-Table-of-Contents>

### Contributing

These articles are intended for developers wishing to contribute to SwiftSyntax

- <doc:ChangingSwiftSyntax>

### Syntax

- <doc:SwiftSyntax/Syntax>
Expand Down

This file was deleted.

9 changes: 9 additions & 0 deletions Sources/SwiftSyntax/Documentation.docc/SPI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# `@_spi` attribute

swift-syntax extensively makes extensive use of the `@_spi` attribute.

Functions marked as `@_spi(RawSyntax)` (where `RawSyntax` can be any name) are considered *SPI* (System Programming Interface) and are only accessible if the module that declares them is imported as `@_spi(RawSyntax)`.

Since functions marked as SPI are not part of the public API, swift-syntax makes no guarantee to their source stability. swift-syntax makes no effort to keep its SPI stable.

Declarations are typically marked as SPI because they have some kind of caveat that makes them unsafe to use in general. For example, when accessing ``RawSyntax`` nodes, you need to manually guarantee that the ``SyntaxArena`` they live in doesn’t get de-allocated. Other declarations have an `@_spi` to share them between different modudules within the swift-syntax package but those APIs shouldn’t be accessed publicly.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ allows Swift tools to parse, inspect, generate, and transform Swift source code.
### Articles

- <doc:Working-with-SwiftSyntax>
- <doc:ChangingSwiftSyntax>
- <doc:Create-SwiftSyntax-Release>

### Tutorials

- <doc:Tutorial-Table-of-Contents>

### Contributing

These articles are intended for developers wishing to contribute to SwiftSyntax

- <doc:ChangingSwiftSyntax>

### Syntax

- <doc:SwiftSyntax/Syntax>
Expand Down