Skip to content

Commit

Permalink
feat: improve static tuple literal errors, migrate to fumadocs (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalbdivad authored Dec 22, 2024
1 parent 07d77d0 commit 8b91296
Show file tree
Hide file tree
Showing 208 changed files with 942 additions and 13,442 deletions.
1 change: 1 addition & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Install dependencies and perform setup for https://github.com/arkty
inputs:
node:
default: lts/*
description: Node version to use

runs:
using: composite
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ jobs:
- name: Setup repo
uses: ./.github/actions/setup

- name: Install, build, and upload your site
uses: withastro/action@v2
- name: Build docs
run: pnpm buildDocs

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./ark/docs # The root location of your Astro project inside the repository. (optional)
# node-version: 20 # The specific version of Node that should be used to build your site. Defaults to 20. (optional)
package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
path: ./ark/docs/out

deploy:
needs: update-gh-pages
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shell-emulator=true
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.prettierPath": "./node_modules/prettier",
"biome.enabled": false,
"editor.codeActionsOnSave": [
"editor.formatOnSave",
Expand Down
4 changes: 1 addition & 3 deletions ark/attest/__tests__/demo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ contextualize(() => {

it("type and value assertions", () => {
const even = type("number%2")
// asserts even.infer is exactly number
attest<number>(even.infer)
// make assertions about types and values seamlessly
// snapshot types and values seamlessly
attest(even.infer).type.toString.snap("number")
// including object literals- no more long inline strings!
attest(even.json).snap({ domain: "number", divisor: 2 })
Expand Down
4 changes: 2 additions & 2 deletions ark/attest/__tests__/snapPopulation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ contextualize(() => {
fromHere("benchExpectedOutput.ts")
).replaceAll("\r\n", "\n")
equal(actual, expectedOutput)
}).timeout(20000)
}).timeout(60000)

it("snap populates file", () => {
const actual = runThenGetContents(fromHere("snapTemplate.ts"))
const expectedOutput = readFile(
fromHere("snapExpectedOutput.ts")
).replaceAll("\r\n", "\n")
equal(actual, expectedOutput)
}).timeout(20000)
}).timeout(60000)
})
2 changes: 1 addition & 1 deletion ark/attest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/attest",
"version": "0.32.0",
"version": "0.33.0",
"license": "MIT",
"author": {
"name": "David Blass",
Expand Down
1 change: 0 additions & 1 deletion ark/docs/CNAME

This file was deleted.

127 changes: 19 additions & 108 deletions ark/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,115 +1,26 @@
# arktype.io
# my-app

Source code for ArkType's docs at [arktype.io](https://arktype.io)
This is a Next.js application generated with
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).

Built with [Starlight](https://starlight.astro.build/)
Run development server:

# Definitions
```bash
npm run dev
# or
pnpm dev
# or
yarn dev
```

- Primitives
Open http://localhost:3000 with your browser to see the result.

- string
- keywords
- Autogenerate from JSDoc
- literals
- patterns
- lengths
- number
- keywords
- Autogenerate from JSDoc
- literals
- ranges
- divisors
- more
- bigint
- boolean
- symbol
- null
- undefined
## Learn More

- Objects
To learn more about Next.js and Fumadocs, take a look at the following
resources:

- properties
- required
- optional
- defaultable
- index
- undeclared
- more
- merge
- keyof
- get
- map
- arrays
- lengths
- tuples
- prefix
- optional
- variadic
- postfix
- dates
- keywords
- Autogenerate from JSDoc
- literals
- ranges
- instanceOf
- keywords
- Autogenerate from JSDoc

- Expressions

- intersection
- union
- brand
- narrow
- morph
- more
- unit
- enumerated
- meta
- cast
- parenthetical
- this

# Other stuff

- Types (how you can use existing types)

- Top-level type invocation

- Autogenerate from JSDoc <!-- properties of a Type instance -->

- define <!-- type utilities not attached to a type instance -->
- raw

- Configuration

- errors
- clone
- onUndeclaredKey
- jitless

- Scopes (advanced)

- syntax
- modules
- visibility
- submodules
- thunks

- Generics (advanced)

- keywords
- Autogenerate from JSDoc
- syntax
- hkt (advanced++)

- Integrations

- Standard Schema
- tRPC
- react-hook-form
- hono

- FAQ
- About the project
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default () => (
Type syntax you already know with safety and completions unlike
anything you&apos;ve ever seen
</p>
<CodeBlock fromFile="unparalleledDx" />
<CodeBlock fromFile="unparalleledDx" includesCompletions />
</ArkCard>
<ArkCard title="Faster... everything" icon={<RocketIcon />}>
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createFromSource } from "fumadocs-core/search/server"
import { source } from "../../../lib/source.ts"
import { source } from "../../../lib/source.tsx"
// it should be cached forever
export const revalidate = false
export const { staticGET: GET } = createFromSource(source)
28 changes: 28 additions & 0 deletions ark/docs/app/docs-og/[...slug]/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { generateOGImage } from "fumadocs-ui/og"
import { metadataImage } from "../../../lib/metadata"

export const GET = metadataImage.createAPI(page =>
generateOGImage({
title: page.data.title === "ArkType" ? "ArkType" : "ArkType Docs",
description: page.data.title === "ArkType" ? "" : page.data.title,
site: "ArkType"
// font: {
// title: {
// families: ["Raleway"],
// weight: "Bold",
// size: 100
// },
// description: {
// families: ["Raleway"],
// weight: "SemiBold",
// size: 40
// }
// }
// fonts: [
// fromPackageRoot("src", "assets", "Raleway.ttf"),
// "https://fonts.googleapis.com/css?family=Raleway:300,400,500,700&display=swap"
// ]
})
)

export const generateStaticParams = () => metadataImage.generateParams()
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DocsTitle
} from "fumadocs-ui/page"
import { notFound } from "next/navigation"
import { source } from "../../../lib/source.ts"
import { source } from "../../../lib/source.tsx"

export default async (props: { params: Promise<{ slug?: string[] }> }) => {
const params = await props.params
Expand All @@ -28,7 +28,6 @@ export default async (props: { params: Promise<{ slug?: string[] }> }) => {
Popup,
PopupContent,
PopupTrigger,

pre: ({ ref: _, ...props }) => (
<CodeBlock {...props}>
<Pre>{props.children}</Pre>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DocsLayout } from "fumadocs-ui/layouts/docs"
import type { ReactNode } from "react"
import { source } from "../../lib/source.ts"
import { source } from "../../lib/source.tsx"
import { baseOptions } from "../layout.config.tsx"

export default ({ children }: { children: ReactNode }) => (
Expand Down
35 changes: 31 additions & 4 deletions ark/fuma/app/global.css → ark/docs/app/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
@tailwind components;
@tailwind utilities;

:root {
/** the * ensures this overrides the variable definitions from shiki*/
:root * {
--background: 207 100% 9%;
--hover-glow: 0.5rem 0.5rem 2rem 0 rgba(31, 38, 135, 0.37);

Expand All @@ -33,7 +34,7 @@
--twoslash-code-font-size: 1em;
--twoslash-matched-color: inherit;
--twoslash-unmatched-color: #888;
--twoslash-cursor-color: var(--sl-color-gray-2);
--twoslash-cursor-color: #888;
--twoslash-error-color: var(--ark-error);
--twoslash-error-bg: #9558f818;
--twoslash-warn-color: #c37d0d;
Expand Down Expand Up @@ -65,7 +66,14 @@ pre.shiki,
overflow-x: visible !important;
}

/** should match arkDarkTheme.colors["editor.background"] */
.bg-fd-secondary\/50 {
background-color: #0006;
}

/** avoid border on hover:
https://github.com/arktypeio/arktype/issues/1217 */
.twoslash-popup-container .bg-fd-secondary\/50 {
background-color: unset;
}

Expand All @@ -76,7 +84,10 @@ div.twoslash-popup-container {
box-shadow: var(--hover-glow);
}

.error {
/** .error.highlighted matches error lines explicitly added in the snippet
source via [!code error] */

.error.highlighted {
position: relative;
background-color: #f8585822;
border-left: 3px solid var(--ark-runtime-error);
Expand All @@ -87,10 +98,11 @@ div.twoslash-popup-container {
width: max-content;
}

.error > span {
.error.highlighted > span {
color: var(--ark-runtime-error) !important;
}

/** .twoslash-error matches errors added by twoslash itself, e.g. type errors */
.twoslash .twoslash-error {
/* Override the builtin error squiggle to match our theme */
background: url("/image/errorSquiggle.svg") repeat-x bottom left;
Expand All @@ -116,10 +128,25 @@ div.twoslash-popup-container {
white-space: pre;
}

.completions-block code {
padding-bottom: 3rem;
}

/** avoid a janky white outline on hovers:
https://github.com/arktypeio/arktype/issues/1217 */
:focus-visible {
outline: none;
}

/* Firefox specific rules */
@-moz-document url-prefix() {
/* The backdrop-filter above doesn't work by default yet on Firefox so we do this instead */
.twoslash .twoslash-hover:hover .twoslash-popup-container {
background: #001323ee;
}
}

/* allow us to inject a badge at order 1 */
#nd-sidebar .lucide-chevron-down {
order: 2;
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8b91296

Please sign in to comment.