Skip to content

preserve kdocs -> kir -> sir -> swift#182

Open
jhaven-stytch wants to merge 2 commits into
touchlab:mainfrom
jhaven-stytch:jordan/preserve-kdocs
Open

preserve kdocs -> kir -> sir -> swift#182
jhaven-stytch wants to merge 2 commits into
touchlab:mainfrom
jhaven-stytch:jordan/preserve-kdocs

Conversation

@jhaven-stytch
Copy link
Copy Markdown

Fixes #45 / #46

There was already precedent for adding docs using a documentation property on the SirDeclaration, so this just builds off of that.

Working backwards (because that's how I thought about this lol):

  1. Swift files are written with documentation that lives on the SIR element's documentation property
  2. Which is populated by a new documentation property added to the companion KIR element
  3. Which is populated by matching the element's FQN in a new map that's hung on the main context
  4. Which is populated by converting the KDoc from each element into a Swifty format for every file thats processed
  5. Which is triggered by a new KotlinIrPhase
  6. Which runs before the KIR and SIR phases

IDK if there are any relevant tests to write/run because the acceptance-tests module is a private submodule, so this is just a best effort to not break anything 😅 But I at least did a local publish (many of them...) and confirmed it's adding docs in my library, so at least it works.

@TadeasKriz
Copy link
Copy Markdown
Collaborator

Thank you for the pull request, I'll review it right after we get a version supporting Kotlin 2.3.20 out. I've also finally gotten around to open-sourcing our acceptance tests, so if you could rebase on top of latest main and try if the tests pass on your machine and perhaps try adding a few new acceptance tests (it might not be possible to verify this feature through the current tests unfortunately).

@jhaven-stytch
Copy link
Copy Markdown
Author

@TadeasKriz awesome, sounds good!

I am traveling next week, so won't be able to get back to this until the following week, but I'll let you know if I have any issues with the tests.

@jhaven-stytch jhaven-stytch force-pushed the jordan/preserve-kdocs branch from 9398386 to 1cdcfae Compare March 27, 2026 17:19
@jhaven-stytch
Copy link
Copy Markdown
Author

Hmm, any chance these tests are a lil flaky? I just ran the failing ones locally (with the onlyIndices trick, thanks for that!), and they all pass. I don't think I have the ability to re-run failing jobs, so I can't check.

@jhaven-stytch
Copy link
Copy Markdown
Author

@TadeasKriz following back up to see if you could try rerunning the failed jobs?

Thanks!

@TadeasKriz
Copy link
Copy Markdown
Collaborator

Hey, I'm sorry for the long wait, I was super busy with work.

Copy link
Copy Markdown
Collaborator

@TadeasKriz TadeasKriz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR seems to be doing a lot. Could you write some acceptance tests for the new functionality? Thanks!

Comment on lines -29 to -35
EntrypointUtils.runKirPhases(
mainSkieContext = mainSkieContext,
objCExportedInterfaceProvider = ObjCExportedInterfaceProvider(input),
)

EntrypointUtils.runSirPhases(mainSkieContext)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you move these to the SkieIrGenerationExtension?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry for my delay, things are a little busy on my side, too, but I will definitely look into adding some tests (fair warning, I have an onsite next week, so won't get to it until after that 😄)

As for the question, it's just because of task ordering. CollectKDocFromSourcesPhase runs as part of runKotlinIrPhases (to populate the context map), which needs to happen before these two phases. Originally, they were happening before the KDocs were collected and they ended up reading an empty map.

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.

Method documentation not visible at XCode

2 participants