Skip to content

Commit b98cd87

Browse files
authored
chore: cdk publishing for twoslash bundler (#2697)
1 parent 3c60f05 commit b98cd87

39 files changed

+12558
-460
lines changed

.github/workflows/deploy-fdr-dev.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- "fern/fern.config.json"
1010
- "servers/fdr-deploy/**"
1111
- "servers/fdr/**"
12+
- "servers/mdx-bundler/**"
1213
- ".github/workflows/deploy-fdr-dev.yml"
1314
- ".github/workflows/publish-fdr-sdk.yml"
1415
- "packages/fdr-sdk/**"
@@ -34,7 +35,7 @@ jobs:
3435
secrets: inherit
3536

3637
deploy_dev:
37-
runs-on: ubuntu-latest
38+
runs-on: Seed
3839
environment: Fern Dev
3940
strategy:
4041
matrix:
@@ -82,6 +83,7 @@ jobs:
8283
run: |
8384
git_version="$(scripts/git-version.sh)"
8485
pnpm --filter=@fern-platform/fdr run docker:dev "${git_version}"
86+
pnpm --filter=@fern-platform/mdx-bundler docker "${git_version}"
8587
npm install -g aws-cdk
8688
cd servers/fdr-deploy
8789
VERSION="${git_version}" pnpm --filter=@fern-platform/fdr-deploy deploy:dev

packages/fern-docs/bundle/src/mdx/bundler/serialize.ts

+2-36
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
import "server-only";
22

3-
// import { RehypeShikiOptions } from "@shikijs/rehype";
4-
// import {
5-
// transformerNotationDiff,
6-
// transformerNotationFocus,
7-
// transformerNotationHighlight,
8-
// } from "@shikijs/transformers";
9-
// import { rendererRich, transformerTwoslash } from "@shikijs/twoslash";
103
import { mapKeys } from "es-toolkit/object";
114
import fs from "fs";
125
import { gracefulify } from "graceful-fs";
13-
// import { ElementContent } from "hast";
146
import { bundleMDX } from "mdx-bundler";
157
import path from "path";
168
import rehypeKatex from "rehype-katex";
@@ -30,7 +22,6 @@ import {
3022
customHeadingHandler,
3123
sanitizeBreaks,
3224
sanitizeMdxExpression,
33-
// toTree,
3425
} from "@fern-docs/mdx";
3526
import {
3627
rehypeAcornErrorBoundary,
@@ -58,7 +49,7 @@ import { rehypeExtractAsides } from "../plugins/rehype-extract-asides";
5849
import { rehypeFiles } from "../plugins/rehype-files";
5950
import { RehypeLinksOptions, rehypeLinks } from "../plugins/rehype-links";
6051
import { rehypeMigrateJsx } from "../plugins/rehype-migrate-jsx";
61-
// import { conditionalRehypeShiki } from "../plugins/rehype-shiki-twoslash";
52+
import { conditionalRehypeShiki } from "../plugins/rehype-shiki-twoslash";
6253
import { rehypeSteps } from "../plugins/rehype-steps";
6354
import { rehypeTabs } from "../plugins/rehype-tabs";
6455
import { remarkExtractTitle } from "../plugins/remark-extract-title";
@@ -167,32 +158,7 @@ async function serializeMdxImpl(
167158
[rehypeFiles, { files: remoteFiles }],
168159
rehypeMdxClassStyle,
169160
rehypeCodeBlock,
170-
// [
171-
// conditionalRehypeShiki,
172-
// {
173-
// themes: {
174-
// light: "min-light",
175-
// dark: "material-theme-darker",
176-
// },
177-
// transformers: [
178-
// transformerNotationDiff(),
179-
// transformerNotationFocus(),
180-
// transformerNotationHighlight(),
181-
// transformerTwoslash({
182-
// explicitTrigger: true,
183-
// renderer: rendererRich({
184-
// renderMarkdown: function (markdown) {
185-
// const { hast } = toTree(markdown, {
186-
// format: "md",
187-
// sanitize: false,
188-
// });
189-
// return hast.children as ElementContent[];
190-
// },
191-
// }),
192-
// }),
193-
// ],
194-
// } satisfies RehypeShikiOptions,
195-
// ],
161+
conditionalRehypeShiki,
196162
rehypeSteps,
197163
rehypeAccordions,
198164
rehypeTabs,

packages/fern-docs/bundle/src/mdx/components/twoslash/index.scss

+48-29
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
--twoslash-docs-color: #888;
1111
--twoslash-docs-font: var(--font-body);
1212
--twoslash-code-font: var(--font-code);
13-
--twoslash-code-font-size: 1em;
13+
--twoslash-code-font-size: var(--text-sm);
1414
--twoslash-matched-color: inherit;
1515
--twoslash-unmatched-color: #888;
1616
--twoslash-cursor-color: #8888;
@@ -49,40 +49,43 @@ html.dark .shiki span {
4949
position: relative;
5050
}
5151

52-
.twoslash .twoslash-popup-container {
53-
position: absolute;
52+
.twoslash .twoslash-popup-info-hover {
53+
position: fixed;
5454
opacity: 0;
5555
display: inline-flex;
5656
flex-direction: column;
5757
transform: translateY(1.1em);
5858
background: var(--card-background, var(--card-surface-fallback));
5959
color: var(--twoslash-popup-color);
6060
transition: opacity 0.3s;
61-
pointer-events: none;
6261
border-radius: calc(var(--radius) * 3);
6362
border: 1px solid var(--card-border, var(--color-border-default));
64-
z-index: 10;
6563
user-select: none;
6664
text-align: left;
6765
box-shadow: var(--twoslash-popup-shadow);
68-
max-width: var(--content-width);
66+
max-width: 500px;
67+
max-height: 600px;
6968
overflow: scroll;
69+
pointer-events: none;
70+
white-space: pre-wrap;
71+
z-index: 20;
72+
padding: 8px 12px;
7073
}
7174

72-
.twoslash .twoslash-query-presisted .twoslash-popup-container {
75+
.twoslash .twoslash-query-presisted .twoslash-popup-info-hover {
7376
z-index: 9;
7477
transform: translateY(1.5em);
7578
}
7679

77-
.twoslash .twoslash-hover:hover .twoslash-popup-container,
78-
.twoslash .twoslash-error-hover:hover .twoslash-popup-container,
79-
.twoslash .twoslash-query-presisted .twoslash-popup-container,
80-
.twoslash .twoslash-query-line .twoslash-popup-container {
80+
.twoslash .twoslash-hover:hover .twoslash-popup-info-hover,
81+
.twoslash .twoslash-error-hover:hover .twoslash-popup-info-hover,
82+
.twoslash .twoslash-query-presisted .twoslash-popup-info-hover,
83+
.twoslash .twoslash-query-line .twoslash-popup-info-hover {
8184
opacity: 1;
8285
pointer-events: auto;
8386
}
8487

85-
.twoslash .twoslash-popup-container:hover {
88+
.twoslash .twoslash-popup-info-hover:hover {
8689
user-select: auto;
8790
}
8891

@@ -101,7 +104,7 @@ html.dark .shiki span {
101104

102105
.twoslash .twoslash-popup-code,
103106
.twoslash .twoslash-popup-error,
104-
.twoslash .twoslash-popup-docs {
107+
.twoslash .twoslash-popup-jsdoc {
105108
padding: 6px 8px !important;
106109
}
107110

@@ -110,43 +113,43 @@ html.dark .shiki span {
110113
font-size: var(--twoslash-code-font-size);
111114
}
112115

113-
.twoslash .twoslash-popup-docs {
116+
.twoslash .twoslash-popup-jsdoc {
114117
color: var(--twoslash-docs-color);
115118
font-family: var(--twoslash-docs-font);
116-
font-size: 0.8em;
119+
font-size: var(--twoslash-code-font-size);
117120
border-top: 1px solid var(--twoslash-border-color);
118121

119122
--tw-content: "-";
120123
}
121124

122-
.twoslash .twoslash-popup-docs code {
123-
font-size: inherit;
125+
.twoslash .twoslash-popup-jsdoc code {
126+
font-size: var(--twoslash-code-font-size);
124127
}
125128

126129
.twoslash .twoslash-popup-error {
127130
color: var(--twoslash-error-color);
128131
background-color: var(--twoslash-error-bg);
129132
font-family: var(--twoslash-docs-font);
130-
font-size: 0.8em;
133+
font-size: var(--twoslash-code-font-size);
131134
}
132135

133-
.twoslash .twoslash-popup-docs-tags {
136+
.twoslash .twoslash-popup-jsdoc-tags {
134137
display: flex;
135138
flex-direction: column;
136139
font-family: var(--twoslash-docs-font);
137140
}
138141

139-
.twoslash .twoslash-popup-docs-tags,
140-
.twoslash .twoslash-popup-docs-tag-name {
142+
.twoslash .twoslash-popup-jsdoc-tags,
143+
.twoslash .twoslash-popup-jsdoc-tag-name {
141144
margin-right: 0.5em;
142145
}
143146

144-
.twoslash .twoslash-popup-docs-tag-name {
147+
.twoslash .twoslash-popup-jsdoc-tag-name {
145148
font-family: var(--twoslash-code-font);
146149
}
147150

148151
/* ===== Query Line ===== */
149-
.twoslash .twoslash-query-line .twoslash-popup-container {
152+
.twoslash .twoslash-query-line .twoslash-popup-info-hover {
150153
position: relative;
151154
margin-bottom: 1.4em;
152155
transform: translateY(0.6em);
@@ -203,7 +206,7 @@ html.dark .shiki span {
203206

204207
.twoslash-completion-list {
205208
width: 240px;
206-
font-size: 0.8rem;
209+
font-size: var(--twoslash-code-font-size);
207210
padding: 4px 0 0;
208211
display: flex;
209212
flex-direction: column;
@@ -347,7 +350,7 @@ pre.twoslash .language-id {
347350
}
348351

349352
pre.twoslash code {
350-
border-radius: calc(var(--radius) * 3);
353+
border-radius: 4px;
351354
box-shadow: unset !important;
352355
}
353356

@@ -371,7 +374,7 @@ pre.twoslash data-lsp:hover::before {
371374
padding: 5px 8px;
372375
border-radius: 2px;
373376
font-family: var(--twoslash-code-font);
374-
font-size: 14px;
377+
font-size: var(--twoslash-code-font-size);
375378
white-space: pre-wrap;
376379
z-index: 100;
377380
}
@@ -501,7 +504,7 @@ pre .inline-completions ul.dropdown {
501504
background-color: gainsboro;
502505
color: grey;
503506
font-family: var(--twoslash-code-font);
504-
font-size: 0.8rem;
507+
font-size: var(--twoslash-code-font-size);
505508
margin: 0;
506509
padding: 4px 0 0;
507510
border-left: 4px solid #4b9edd;
@@ -575,8 +578,8 @@ data-lsp {
575578

576579
.tag-container .twoslash-annotation p {
577580
text-align: left;
578-
font-size: 0.8rem;
579-
line-height: 0.9rem;
581+
font-size: var(--twoslash-code-font-size);
582+
line-height: inherit;
580583
}
581584

582585
.tag-container .twoslash-annotation svg {
@@ -632,3 +635,19 @@ pre .logger.log-log svg {
632635
.twoslash li::before {
633636
--tw-content: "";
634637
}
638+
639+
.twoslash-popup-jsdoc p,
640+
.twoslash-popup-jsdoc ul,
641+
.twoslash-popup-jsdoc li {
642+
margin-top: 0.25rem !important;
643+
margin-bottom: 0.25rem !important;
644+
}
645+
646+
.twoslash-popup-jsdoc code {
647+
font-family: var(--font-code);
648+
border: 0 !important;
649+
}
650+
651+
.twoslash code span {
652+
font-size: var(--twoslash-code-font-size);
653+
}

0 commit comments

Comments
 (0)