Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

feat(docs): Convey TS friendliness (#120)

Pavel 'Strajk' Dolecekee47d84ac36d
diff --git a/apps/docs/src/components/Code.tsx b/apps/docs/src/components/Code.tsx
index e66f44a95..2fecf59ec 100644
--- a/apps/docs/src/components/Code.tsx
+++ b/apps/docs/src/components/Code.tsx
@@ -15,17 +15,7 @@ import { create } from 'zustand'
import { Tag } from '@/components/Tag'
import { CopyButton } from '@/components/CopyButton'
-
-const languageNames: Record<string, string> = {
- js: 'JavaScript',
- ts: 'TypeScript',
- javascript: 'JavaScript',
- typescript: 'TypeScript',
- php: 'PHP',
- python: 'Python',
- ruby: 'Ruby',
- go: 'Go',
-}
+import { languageNames } from '@/utils/consts'
export function getPanelTitle({
title,
@@ -248,7 +238,9 @@ export function CodeGroup({
children,
title,
...props
-}: React.ComponentPropsWithoutRef<typeof CodeGroupPanels> & { title?: string }) {
+}: React.ComponentPropsWithoutRef<typeof CodeGroupPanels> & {
+ title?: string
+}) {
let languages =
Children.map(children, (child) =>
getPanelTitle(isValidElement(child) ? child.props : {})
@@ -320,9 +312,11 @@ export function Pre({
/**
* Special Component just for MDX files, processed by Remark
*/
-export function CodeGroupAutoload({children}) {
+export function CodeGroupAutoload({ children }) {
if (!children) {
- console.warn(`CodeGroupAutoload: No children provided – something is wrong with your MDX file`)
+ console.warn(
+ `CodeGroupAutoload: No children provided – something is wrong with your MDX file`
+ )
return null
}
return <CodeGroup>{children}</CodeGroup>
diff --git a/apps/docs/src/utils/consts.ts b/apps/docs/src/utils/consts.ts
new file mode 100644
index 000000000..a603cc8a3
--- /dev/null
+++ b/apps/docs/src/utils/consts.ts
@@ -0,0 +1,17 @@
+// Beware of our conventions:
+// - use `js` for "JavaScript & TypeScript" – the code is actually JavaScript, but we wanna communicate that we are TypeScript friendly
+// @see https://e2b-team.slack.com/archives/C05AGT4UFMJ/p1694097476092009?thread_ts=1694072588.364759&cid=C05AGT4UFMJ
+// - use `javascript` for explicitly JavaScript
+// - use `typescript` for explicitly TypeScript
+
+export const languageNames: Record<string, string> = {
+ js: 'JavaScript & TypeScript',
+ ts: '⚠️ FIXME See note in apps/docs/src/utils/consts.ts', // Please avoid using `ts`, see note above
+ javascript: 'JavaScript',
+ typescript: 'TypeScript',
+
+ php: 'PHP',
+ python: 'Python',
+ ruby: 'Ruby',
+ go: 'Go',
+}