Skip to content
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

Snippet slicing does not handle multiline string literals correctly #946

Open
1 of 2 tasks
tayloraswift opened this issue Jun 10, 2024 · 0 comments
Open
1 of 2 tasks
Labels
bug Something isn't working

Comments

@tayloraswift
Copy link
Member

Description

a snippet slice directive must be a line comment of the form // snippet.*. unfortunately, DocC seems to be incorrectly interpreting the contents of a multiline string literal as slice comments. for example, the following snippet

// snippet.hide
import Snippets_Example

// snippet.show
let _:String = """
Only this part of the code will be shown.

// snippet.hide

Snippet markers inside multiline string literals are ignored.

// snippet.show
"""

ought to display the entire multiline string literal, but instead i get this:

image

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

DocC should leave the contents of the string literal alone.

Actual behavior

DocC is interpreting comment-like substrings inside the literal as if they were actual comment tokens, and performing cuts in those locations.

this can cause serious corruption of the contents, for example:

// snippet.hide
import Snippets_Example

// snippet.show
// snippet.hide
let _:String = """
Only this part of the code will be shown.

// snippet.show

Snippet markers inside multiline string literals are ignored.

"""

will produce unbalanced string literal delimiters.

image

Steps To Reproduce

No response

Swift-DocC Version Information

Plugin version 1.3.0

Swift Compiler Version Information

Swift version 5.10 (swift-5.10-RELEASE)
Target: x86_64-unknown-linux-gnu
@tayloraswift tayloraswift added the bug Something isn't working label Jun 10, 2024
@tayloraswift tayloraswift changed the title Snippet slicing does not handle multiline string literals correctly. Snippet slicing does not handle multiline string literals correctly Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant