-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic doc cleanup #2938
Generic doc cleanup #2938
Changes from all commits
ac1e2ee
77a4a0a
e349475
c70680e
a4b1085
336d246
40b0c4a
f6f1b8f
17eaefd
d23462e
53ae8ab
06dcaae
809ca3d
bd31fea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import { registry } from "../../src/library/registry/index.js"; | ||
import { evaluateStringToResult } from "../../src/reducer/index.js"; | ||
|
||
test.each(registry.allExamplesWithFns())( | ||
"tests of example $example", | ||
async ({ fn, example }) => { | ||
const result = await evaluateStringToResult(example); | ||
test.each( | ||
registry.allExamplesWithFns().filter(({ example }) => example.useForTests) | ||
)("tests of example $example", async ({ fn, example }) => { | ||
const result = await evaluateStringToResult(example.text); | ||
|
||
if (!result.ok) { | ||
throw new Error(`Can't test type, with error: ${result.value}`); | ||
} | ||
|
||
if (fn.output !== undefined) { | ||
expect(result.value.type).toEqual(fn.output); | ||
} | ||
if (!result.ok) { | ||
throw new Error(`Can't test type, with error: ${result.value}`); | ||
} | ||
|
||
expect(result.ok).toBe(true); | ||
if (fn.output !== undefined) { | ||
expect(result.value.type).toEqual(fn.output); | ||
} | ||
); | ||
|
||
expect(result.ok).toBe(true); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { makeFnExample } from "../library/registry/core.js"; | ||
import { makeDefinition } from "../library/registry/fnDefinition.js"; | ||
import { | ||
frArray, | ||
|
@@ -35,16 +36,27 @@ export const library = [ | |
name: "make", | ||
output: "Calculator", | ||
examples: [ | ||
`Calculator.make( | ||
{|x| x * 5}, | ||
{ | ||
title: "My great calculator", | ||
inputs: [Input.text({ name: "x", default: "20" })], | ||
autorun: false, | ||
sampleCount: 10k, | ||
} | ||
)`, | ||
"({|x| x * 5}) -> Calculator", | ||
makeFnExample( | ||
`Calculator.make( | ||
{|text, textArea, select, checkbox| text + textArea}, | ||
{ | ||
title: "My example calculator", | ||
inputs: [ | ||
Input.text({ name: "text", default: "20" }), | ||
Input.textArea({ name: "textArea", default: "50 to 80" }), | ||
Input.select({ name: "select", default: "second", options: ["first", "second", "third"] }), | ||
Input.checkbox({ name: "checkbox", default: true }), | ||
], | ||
sampleCount: 10k, | ||
})`, | ||
{ isInteractive: true } | ||
), | ||
makeFnExample( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding We have so many stdlib functions that it's worth it to make the syntax for the most common case as terse as possible. I expect you'll prefer to postpone this idea since you already did the conversion, but here's how I'd do it:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sigh... good point. I did it when I wasn't feeling good anyway, so it was an easy-ish non-intense project to do. Will see about changing later on. |
||
`// When a calculator is created with only a function, it will guess the inputs based on the function's parameters. It won't provide default values if it's a user-written function. | ||
|
||
({|x| x * 5}) -> Calculator`, | ||
{ isInteractive: true } | ||
), | ||
], | ||
description: ` | ||
\`Calculator.make\` takes in a function, a description, and a list of inputs. The function should take in the same number of arguments as the number of inputs, and the arguments should be of the same type as the default value of the input. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not new, but (1) it's broken (tailwind syntax is
max-w-[...]
, notmax-width-[...]
), (2) doesn't seem useful anyway?