Skip to content

feat(docs): add translations block to docs.yml#15172

Merged
dsinghvi merged 20 commits into
mainfrom
feat/docs-translations
Apr 27, 2026
Merged

feat(docs): add translations block to docs.yml#15172
dsinghvi merged 20 commits into
mainfrom
feat/docs-translations

Conversation

@fern-support
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a translations block to docs.yml that declares the locales a documentation site supports
  • Each entry has a required lang (one of the supported Language enum values) and an optional default: true flag
  • Wires the field through the full config pipeline: Zod schema → parsed config → JSON schema validation → Fern API definition

Example usage

translations:
  - lang: en
    default: true
  - lang: ja
  - lang: fr

Files changed

Area Change
DocsYmlSchemas.ts New TranslationConfig Zod schema; translations added to DocsConfiguration
Generated SDK types New TranslationConfig.ts interface; translations added to DocsConfiguration.ts
Serialization schemas New TranslationConfig.ts serializer; translations added to serialization DocsConfiguration.ts
ParsedDocsConfiguration.ts `translations: TranslationConfig[]
parseDocsConfiguration.ts Pass-through for translations
JSON schemas translations property + docs.TranslationConfig definition in both docs-yml.schema.json files
Fern API definition TranslationConfig type and translations property in docs.yml

Test plan

  • Unit tests for TranslationConfig Zod schema (valid langs, invalid codes, optional default)
  • Unit tests for DocsConfiguration with translations field (absent, single, multiple, mixed with languages)
  • Integration tests for parseDocsConfiguration confirming translations passes through correctly
  • pnpm turbo run compile --filter @fern-api/configuration --filter @fern-api/configuration-loader — clean
  • All existing tests in both packages pass

🤖 Generated with Claude Code

@fern-support fern-support self-assigned this Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI

How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR.

Comment thread packages/cli/docs-resolver/src/DocsDefinitionResolver.ts
@fern-support fern-support force-pushed the feat/docs-translations branch 2 times, most recently from 03f545f to 8341ae9 Compare April 24, 2026 20:36
@dsinghvi
Copy link
Copy Markdown
Member

@claude review

@dsinghvi dsinghvi marked this pull request as ready for review April 24, 2026 20:50
@dsinghvi dsinghvi requested a review from amckinney as a code owner April 24, 2026 20:50
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread packages/cli/docs-resolver/src/DocsDefinitionResolver.ts
Comment thread fern/apis/docs-yml/definition/docs.yml
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

Docs Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-04-23T04:59:11Z).

Fixture main PR Delta
docs 301.0s (n=5) 297.9s (35 versions) -3.1s (-1.0%)

Docs generation runs fern generate --docs --preview end-to-end against the benchmark fixture with 35 API versions (each version: markdown processing + OpenAPI-to-IR + FDR upload).
Delta is computed against the nightly baseline on main.
Baseline from nightly run(s) on main (latest: 2026-04-23T04:59:11Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-04-27 00:47 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

SDK Generation Benchmark Results

Comparing PR branch against median of 5 nightly run(s) on main (latest: 2026-04-23T04:59:11Z).

Full benchmark table (click to expand)
Generator Spec main (generator) main (E2E) PR (generator) Delta
csharp-sdk square 56s (n=5) 86s (n=5) 51s -5s (-8.9%)
go-sdk square 115s (n=5) 132s (n=5) 115s +0s (+0.0%)
java-sdk square 179s (n=5) 207s (n=5) 190s +11s (+6.1%)
php-sdk square 43s (n=5) 66s (n=5) 42s -1s (-2.3%)
python-sdk square 115s (n=5) 223s (n=5) 119s +4s (+3.5%)
ruby-sdk-v2 square 130s (n=5) 159s (n=5) 130s +0s (+0.0%)
rust-sdk square 166s (n=5) 163s (n=5) 170s +4s (+2.4%)
swift-sdk square 41s (n=5) 290s (n=5) 40s -1s (-2.4%)
ts-sdk square 74s (n=5) 86s (n=5) 73s -1s (-1.4%)

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 fern generate). main (E2E): full customer-observable time including build/test scripts (nightly baseline, informational). Delta is computed against generator-only baseline.
⚠️ = generation exited with a non-zero exit code (timing may not reflect a successful run).
Baseline from nightly runs on main (latest: 2026-04-23T04:59:11Z). Trigger benchmark-baseline to refresh.
Last updated: 2026-04-27 00:47 UTC

Comment thread fern/apis/docs-yml/definition/docs.yml Outdated
Comment thread packages/cli/configuration/src/docs-yml/DocsYmlSchemas.ts
Comment thread package.json
Comment thread packages/cli/docs-resolver/src/applyTranslatedFrontmatterToNavTree.ts Outdated
Comment thread packages/cli/configuration/src/docs-yml/DocsYmlSchemas.ts
dsinghvi and others added 10 commits April 26, 2026 18:52
Add a `translations` block to `docs.yml` that lets users declare which
locales their documentation supports, with an optional `default` flag.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add noop handler for the new `translations` field in the exhaustive
ObjectPropertiesVisitor<DocsConfiguration> call inside
visitDocsConfigFileYamlAst, fixing the TS2345 compile error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ParsedDocsConfiguration gains translationPages: Record<locale, pages>
- parseDocsConfiguration reads translations/<lang>/ directories, errors
  clearly when a declared locale directory is missing, and warns about
  individual missing files (partial translations are allowed)
- DocsDefinitionResolver exposes getTranslationPages() after resolve()
- publishDocs calls POST /v2/registry/docs/translations/register for
  each locale after finishDocsRegister, using a direct axios call
  (registerTranslation is not yet in the published fdr-sdk version)
- visitDocsConfigFileYamlAst gains translations: noop to satisfy the
  exhaustive ObjectPropertiesVisitor<DocsConfiguration> type
- Integration tests use real temp directories to exercise FS loading

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Upgrades fdr-sdk from 1.1.13-c1ad12a2b8 to 1.1.23-d25ead8e05 which includes
the registerTranslation SDK call used by the docs translations feature.

Fixes resulting type errors:
- IntegrationsConfig.context7 changed from string to FileId — suppress the
  raw path string by setting context7: undefined in parseDocsConfiguration
  (the resolved AbsoluteFilePath is already stored as context7File)
- AiChatLocation now excludes "discord" in the SDK type — cast at the
  API boundary in DocsDefinitionResolver
- Remove now-resolved @ts-expect-error directive for agents field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a locale listed in `translations:` has no corresponding
`translations/<lang>/` directory, and that locale is the default
(first entry or marked `default: true`), skip it silently rather
than erroring. The default locale's pages already live in `pages/`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
For i18n translations, the CLI now:
1. Uses gray-matter (from docs-resolver) to parse sidebar-title and slug
   overrides from translated page frontmatter
2. Walks the navigation tree and updates PageNode title/slug where
   translated pages have frontmatter overrides
3. Sends the fully-computed DocsDefinition (with updated nav root) to FDR
   so the server can write a correct LoadDocsForUrlResponse to S3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nResolver

Address reviewer feedback requesting a missing blank line.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
dsinghvi and others added 8 commits April 26, 2026 18:52
- Filter 'discord' from AIChatLocation at runtime instead of using type cast
- Add TODO comment documenting that translated pages bypass MDX transformation pipeline

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix language code jp -> ja in docs.yml example
- Add preview mode guard to prevent translations overwriting prod in preview
- Remove slug override support (requires proper composition with parent slugs)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add getCollectedFileIds() and getDocsWorkspacePath() to DocsDefinitionResolver
- Re-export stripMdxComments and replaceImagePathsAndUrls from docs-resolver
- Apply stripMdxComments to translated pages to prevent comment leakage
- Preserve editThisPageUrl/editThisPageLaunch from base pages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Apply replaceImagePathsAndUrls to translated pages using base page path for resolution
- Add comprehensive tests for applyTranslatedFrontmatterToNavTree
- Remaining TODOs: <Markdown src=.../>, <CodeBlock src=.../>, @-prefix imports

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Hoist default locale skip above existence check in loadTranslationPages
- Add superRefine validation to reject multiple default translations
- Handle section nodes in applyTranslatedFrontmatterToNavTree (overviewPageId)
- Rewrite editThisPageUrl to point to translated file path
- Add tests for section node handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Spread telemetry headers (X-CLI-Version, X-CI-Source, etc.) into translation registration fetch
- Add logging for frontmatter parse errors in applyTranslatedFrontmatterToNavTree

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace `as any` with helper functions using proper type casts
- Fix import ordering in docs-resolver/index.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The translation tests were failing because they only specified a single
translation locale without marking any as the default. The code treats
the first translation without a `default: true` flag as the default locale,
which means it gets skipped during translation loading.

Fixed by adding `{ lang: "en", default: true }` to each test's translations
config so the other locales (fr, ja) are correctly treated as translations.

Also fixes TypeScript errors in applyTranslatedFrontmatterToNavTree tests
by using optional chaining on array access.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@fern-support fern-support force-pushed the feat/docs-translations branch from 78dc728 to 91edb64 Compare April 26, 2026 23:25
Regenerates the TypeScript SDK types and JSON schemas for the docs-yml
API definition to include the translations configuration documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Updates IR test definition snapshots to include the new tokenPlaceholder
field added in main.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@dsinghvi dsinghvi merged commit a8250cf into main Apr 27, 2026
209 checks passed
@dsinghvi dsinghvi deleted the feat/docs-translations branch April 27, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants