feat(cli): support registering translated API definitions in docs publish#15480
feat(cli): support registering translated API definitions in docs publish#15480
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
Docs Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on
Docs generation runs |
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
ad7b159 to
c7cf90c
Compare
| const translationDomain = preview ? urlToOutput : domain; | ||
| if (translationPages != null && Object.keys(translationPages).length > 0) { |
There was a problem hiding this comment.
The translation registration logic only checks for translationPages but not translationApiDefinitions. If a user provides only translated API definitions without translated pages, the entire registration block is skipped and API definitions are never registered.
Fix:
if ((translationPages != null && Object.keys(translationPages).length > 0) ||
(translationApiDefinitions != null && Object.keys(translationApiDefinitions).length > 0)) {
const totalLocales = new Set([
...Object.keys(translationPages ?? {}),
...Object.keys(translationApiDefinitions ?? {})
]).size;
context.logger.info(`Registering translations for ${totalLocales} locale(s)...`);| const translationDomain = preview ? urlToOutput : domain; | |
| if (translationPages != null && Object.keys(translationPages).length > 0) { | |
| const translationDomain = preview ? urlToOutput : domain; | |
| if ((translationPages != null && Object.keys(translationPages).length > 0) || | |
| (translationApiDefinitions != null && Object.keys(translationApiDefinitions).length > 0)) { | |
| const totalLocales = new Set([ | |
| ...Object.keys(translationPages ?? {}), | |
| ...Object.keys(translationApiDefinitions ?? {}) | |
| ]).size; | |
| context.logger.info(`Registering translations for ${totalLocales} locale(s)...`); | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
6e99ea4 to
60b70d3
Compare
Co-Authored-By: Deep Singhvi <deep@buildwithfern.com>
Co-Authored-By: Deep Singhvi <deep@buildwithfern.com>
60b70d3 to
affbdb7
Compare
Co-Authored-By: Deep Singhvi <deep@buildwithfern.com>
Description
Extends the docs publish flow to support registering translated API definitions alongside translated pages. Users can place translated API definition JSON files in
translations/<lang>/apis/<api-name>.jsonand they will be included in the translation registration request to FDR.Companion PR: https://github.com/fern-api/fern-platform/pull/10196 (FDR backend changes to accept and merge translated API definitions)
Changes Made
ParsedDocsConfiguration(packages/cli/configuration/): AddedtranslationApiDefinitionsfield —Record<string, Record<string, unknown>> | undefined— mapping locale → { apiName → JSON definition }parseDocsConfiguration.ts(packages/cli/configuration-loader/): AddedloadTranslationApiDefinitions()function that scanstranslations/<lang>/apis/*.jsondirectories and loads translated API definition JSON filesDocsDefinitionResolver(packages/cli/docs-resolver/): AddedgetTranslationApiDefinitions()getter to expose loaded translation API definitionspublishDocs.ts(packages/cli/generation/remote-generation/remote-workspace-runner/): Updated translation registration to includeapiDefinitionsin the request body when available, with logging of included API definition namesTesting
Link to Devin session: https://app.devin.ai/sessions/36455db2d89641e3b8dd32c39a792643
Requested by: @dsinghvi