Extract code snippets to separate files for maintainability#626
Open
Extract code snippets to separate files for maintainability#626
Conversation
Extract inline code blocks from 8 MDX files into separate snippet files under fern/snippets/audio-intelligence/. Code blocks with extractable languages (python, javascript, csharp, ruby, php, bash) and >3 lines are replaced with <Code src="..." /> components. JSON/text/plain output blocks are preserved inline. Added fern/snippets/ to .prettierignore since snippet files are code examples that may not be syntactically valid for prettier. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 3 MDX files (custom-formatting, speech-understanding, translation) into separate snippet files under fern/snippets/speech-understanding/. 26 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 5 MDX files into separate snippet files under fern/snippets/lemur/. 73 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 7 MDX files into separate snippet files under fern/snippets/llm-gateway/. 27 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 3 MDX files into separate snippet files under fern/snippets/getting-started/. 90 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 19 MDX files into separate snippet files under fern/snippets/speech-to-text/pre-recorded-audio/. 149 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 10 MDX files into separate snippet files under fern/snippets/speech-to-text/universal-streaming/. 35 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 9 MDX files into separate snippet files under fern/snippets/integrations/. 32 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from guides/ section including all cookbooks subdirectories (core-transcription, streaming-stt, lemur, audio-intelligence). 558 snippet files created across 79 MDX files. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 1 MDX file into separate snippet files under fern/snippets/concepts/. 1 snippet file created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 3 MDX files into separate snippet files under fern/snippets/use-cases/. 54 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Extract inline code blocks from 3 root-level speech-to-text MDX files (livekit-intro-guide, pipecat-intro-guide, streaming). 42 snippet files created. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Prettier reformatted these files during the format pass. No functional changes - only whitespace/formatting adjustments. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Fern resolves <Code src="..."> paths relative to the page file, not the fern/ root. Change all paths from src="snippets/..." to use relative paths like src="../../snippets/...". Also restore markdown tables that were mangled when prettier reformatted <Code> tags to multi-line, causing the following table to be treated as prose text. Revert unrelated prettier changes to FAQ and voice-agent.js. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
- Restore mangled markdown tables in key-phrases.mdx, customize-parameters.mdx
and translation.mdx from git history
- Fix {/\* escaped JSX comments to {/* in custom-formatting.mdx and
translation.mdx (caused acorn parse errors in fern generate)
- Remove duplicate mangled table in translation.mdx
- Add missing blank line between Code tag and heading in translation.mdx
- Restore proper list formatting in medical-scribe-best-practices.mdx
https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
Remove three mangled table duplicates that were left behind by the table restoration script. These corrupted text blocks contained \_Legacy which the MDX parser interpreted as markdown list items, breaking the <Tab> structure. https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA
…622) - Fix openapi.yml: change `objects` to `items` for expected_languages arrays - Fix openapi-overrides.yml: add missing Authorization header, remove unexpected properties, add word-search example - Remove commented-out JSX Tab sections in translation.mdx and custom-formatting.mdx that prettier escapes to `{/\*`, breaking acorn - Apply prettier formatting to customize-parameters.mdx and voice-agent.js - Regenerate fern definition and openapi.json https://claude.ai/code/session_01NxTbqRLFJXHtJG11JMQVa2 Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors inline code examples in documentation pages to use external snippet files, improving maintainability and reducing duplication across the codebase.
Key Changes
auto-chapters.mdxandcontent-moderation.mdxto dedicated snippet files infern/snippets/audio-intelligence/<code>blocks with<Code src="...">component references that point to external snippet files.prettierignoreto exclude thefern/snippets/directory from formattinghighlight={[8]}) in the component referencesImplementation Details
auto-chapters/,content-moderation/) and languagepython-sdk.py,javascript.js,bash.sh)Benefits
https://claude.ai/code/session_01NinNALWi81ZHvgeZkVoziA