diff --git a/site/content/docs/03-runtime/03-svelte-motion.md b/site/content/docs/03-runtime/03-svelte-motion.md index c40991fafa..d026541bab 100644 --- a/site/content/docs/03-runtime/03-svelte-motion.md +++ b/site/content/docs/03-runtime/03-svelte-motion.md @@ -6,6 +6,8 @@ The `svelte/motion` module exports two functions, `tweened` and `spring`, for cr ## `tweened` +> EXPORT_SNIPPET: svelte/motion#tweened + ```js store = tweened(value: any, options) ``` @@ -81,6 +83,8 @@ The `interpolate` option allows you to tween between _any_ arbitrary values. It ## `spring` +> EXPORT_SNIPPET: svelte/motion#spring + ```js store = spring(value: any, options) ``` diff --git a/site/content/docs/03-runtime/04-svelte-transition.md b/site/content/docs/03-runtime/04-svelte-transition.md index c30e659b51..bd8175ea36 100644 --- a/site/content/docs/03-runtime/04-svelte-transition.md +++ b/site/content/docs/03-runtime/04-svelte-transition.md @@ -6,6 +6,8 @@ The `svelte/transition` module exports seven functions: `fade`, `blur`, `fly`, ` ## `fade` +> EXPORT_SNIPPET: svelte/transition#fade + ```svelte transition:fade={params} ``` @@ -40,6 +42,8 @@ You can see the `fade` transition in action in the [transition tutorial](/tutori ## `blur` +> EXPORT_SNIPPET: svelte/transition#blur + ```svelte transition:blur={params} ``` @@ -74,6 +78,8 @@ Animates a `blur` filter alongside an element's opacity. ## `fly` +> EXPORT_SNIPPET: svelte/transition#fly + ```svelte transition:fly={params} ``` @@ -117,6 +123,8 @@ You can see the `fly` transition in action in the [transition tutorial](/tutoria ## `slide` +> EXPORT_SNIPPET: svelte/transition#slide + ```svelte transition:slide={params} ``` @@ -154,6 +162,8 @@ Slides an element in and out. ## `scale` +> EXPORT_SNIPPET: svelte/transition#scale + ```svelte transition:scale={params} ``` @@ -191,6 +201,8 @@ Animates the opacity and scale of an element. `in` transitions animate from an e ## `draw` +> EXPORT_SNIPPET: svelte/transition#draw + ```svelte transition:draw={params} ``` @@ -236,6 +248,8 @@ The `speed` parameter is a means of setting the duration of the transition relat ## `crossfade` +> EXPORT_SNIPPET: svelte/transition#crossfade + The `crossfade` function creates a pair of [transitions](/docs/element-directives#transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used. `crossfade` accepts the following parameters: diff --git a/site/content/docs/03-runtime/05-svelte-animate.md b/site/content/docs/03-runtime/05-svelte-animate.md index 3d9c719308..f0ad868dd3 100644 --- a/site/content/docs/03-runtime/05-svelte-animate.md +++ b/site/content/docs/03-runtime/05-svelte-animate.md @@ -6,6 +6,8 @@ The `svelte/animate` module exports one function for use with Svelte [animations ## `flip` +> EXPORT_SNIPPET: svelte/animate#flip + ```svelte animate:flip={params} ``` diff --git a/site/content/docs/04-compiler-and-api/01-svelte-compiler.md b/site/content/docs/04-compiler-and-api/01-svelte-compiler.md index 09964d2b8c..bf0bbf2d69 100644 --- a/site/content/docs/04-compiler-and-api/01-svelte-compiler.md +++ b/site/content/docs/04-compiler-and-api/01-svelte-compiler.md @@ -8,6 +8,8 @@ Nonetheless, it's useful to understand how to use the compiler, since bundler pl ## `svelte.compile` +> EXPORT_SNIPPET: svelte/compiler#compile + ```js result: { js, @@ -147,6 +149,8 @@ compiled: { ## `svelte.parse` +> EXPORT_SNIPPET: svelte/compiler#parse + ```js ast: object = svelte.parse( source: string, @@ -167,6 +171,8 @@ const ast = svelte.parse(source, { filename: 'App.svelte' }); ## `svelte.preprocess` +> EXPORT_SNIPPET: svelte/compiler#preprocess + A number of [community-maintained preprocessing plugins](https://sveltesociety.dev/tools#preprocessors) are available to allow you to use Svelte with tools like TypeScript, PostCSS, SCSS, and Less. You can write your own preprocessor using the `svelte.preprocess` API. @@ -305,6 +311,8 @@ const { code } = await svelte.preprocess( ## `svelte.walk` +> EXPORT_SNIPPET: svelte/compiler#walk + ```js walk(ast: Node, { enter(node: Node, parent: Node, prop: string, index: number)?: void, @@ -334,13 +342,11 @@ svelte.walk(ast, { ## `svelte.VERSION` +> EXPORT_SNIPPET: svelte/compiler#VERSION + The current version, as set in package.json. ```js import svelte from 'svelte/compiler'; console.log(`running svelte version ${svelte.VERSION}`); ``` - -## Types - -> TYPES: svelte/compiler diff --git a/site/content/docs/05-misc/03-svelte-internal.md b/site/content/docs/05-misc/03-svelte-internal.md new file mode 100644 index 0000000000..e02537def4 --- /dev/null +++ b/site/content/docs/05-misc/03-svelte-internal.md @@ -0,0 +1,11 @@ +--- +title: svelte/internal +--- + +## Exports + +> EXPORTS: svelte/internal + +## Types + +> TYPES: svelte/internal diff --git a/site/content/docs/05-misc/03-migrating-v3-to-v4.md b/site/content/docs/05-misc/04-migrating-v3-to-v4.md similarity index 100% rename from site/content/docs/05-misc/03-migrating-v3-to-v4.md rename to site/content/docs/05-misc/04-migrating-v3-to-v4.md diff --git a/sites/svelte.dev/src/lib/server/docs/render.js b/sites/svelte.dev/src/lib/server/docs/render.js index edd6cc8bcd..0f0207f047 100644 --- a/sites/svelte.dev/src/lib/server/docs/render.js +++ b/sites/svelte.dev/src/lib/server/docs/render.js @@ -108,6 +108,36 @@ export function replace_placeholders(content) { .join('\n\n')}`; }) .join('\n\n'); + }) + .replace(/> EXPORTS: (.+)/, (_, name) => { + const module = modules.find((module) => module.name === name); + if (!module) throw new Error(`Could not find module ${name} for EXPORTS: clause`); + + if (module.exports.length === 0 && !module.exempt) return ''; + + let import_block = ''; + + if (module.exports.length > 0) { + // deduplication is necessary for now, because of `error()` overload + const exports = Array.from(new Set(module.exports.map((x) => x.name))); + + let declaration = `import { ${exports.join(', ')} } from '${module.name}';`; + if (declaration.length > 80) { + declaration = `import {\n\t${exports.join(',\n\t')}\n} from '${module.name}';`; + } + + import_block = fence(declaration, 'js'); + } + + return `${import_block}\n\n${module.comment}\n\n${module.exports + .map((type) => { + const markdown = + `