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

Improve snippets #25

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Improve snippets #25

wants to merge 5 commits into from

Conversation

tib
Copy link
Contributor

@tib tib commented Jan 13, 2025

  • update snippets location, group by year
  • fix protobuf & grpc snippets
  • fix jwt-kit snippet location
  • fixes Fix gRPC snippets #21

@tib tib requested a review from Joannis January 13, 2025 22:00
@tib
Copy link
Contributor Author

tib commented Jan 13, 2025

Seems like CI failed, but swiftinit was able to locate the snippets.

@tayloraswift
Copy link
Collaborator

this looks like the same issue @sebsto ran into yesterday

@tib
Copy link
Contributor Author

tib commented Jan 14, 2025

Also I've noticed, that the snippets are working on swiftinit, but the path seems to be incorrect, taken this example the path should contain 2025:

@Snippet(path: "site/Snippets/introduction-to-jwts-in-swift", slice: jwt_verify)

The rendered snippet in the article looks just fine: link

This is a strange behavior, what's the correct approach here? @tayloraswift

+1: What's site in the path? 🤔

@tayloraswift
Copy link
Collaborator

tayloraswift commented Jan 14, 2025

as described here, the path is not a file path, but a three component string in which the last component is the Snippet module name (not the filename!) and the middle component is the constant string Snippets.

the way Snippets are implemented in SwiftPM, each Snippet is a module, so all Snippets share a global namespace within a build tree. Snippet names also undergo module name mangling, so Snippets whose names differ in special characters only will still collide from SwiftPM’s perspective.

the first component (site) is the package name as specified in the Package.swift manifest.

this has a lot of weird implications, the first being that if the package name contains special characters (like spaces), path is effectively unusable. this is one of the weirder parts about SE-0356.

i recommend using id over path, as the former is a bit clearer about what part of the string is actually meaningful, but keep in mind that id only works on Unidoc.

@tib
Copy link
Contributor Author

tib commented Jan 14, 2025

What do you think @Joannis are you fine with migrating to IDs instead of paths?

I'm happy to do the changes, Snippets never really worked with DocC when using Xcode anyway... we always use unidoc to render them, so it makes sense imho.

@Joannis
Copy link
Member

Joannis commented Jan 15, 2025

I'm completely convinced we should drop Xcode's DocC. Right now we have no way to view updated text quickly through swiftinit's rendering system. So it's a bit of a guessing game requiring many rerenders to get the desired result.

@tayloraswift
Copy link
Collaborator

is the unidoc preview tool not working locally?

@tib
Copy link
Contributor Author

tib commented Jan 15, 2025

I'll give it a try & update all the path-s to ids to see how it works & looks like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix gRPC snippets
3 participants