Add action module

pull/8452/head
Puru Vijay 3 years ago
parent 9abbc8c54a
commit c331551fc7

@ -1,6 +0,0 @@
---
title: Actions
draft: true
---
TODO

@ -0,0 +1,9 @@
---
title: svelte/action
---
TODO
## Types
> TYPES: svelte/action

@ -24,10 +24,6 @@ const type_regex = new RegExp(
const type_links = new Map(); const type_links = new Map();
// const slugs = {
// '@sveltejs/kit': 'public-types'
// };
modules.forEach((module) => { modules.forEach((module) => {
const slug = slugify(module.name); const slug = slugify(module.name);
@ -123,7 +119,8 @@ export async function get_parsed_docs(docs_data, slug) {
`/// <reference types="svelte/easing" />`, `/// <reference types="svelte/easing" />`,
`/// <reference types="svelte/motion" />`, `/// <reference types="svelte/motion" />`,
`/// <reference types="svelte/transition" />`, `/// <reference types="svelte/transition" />`,
`/// <reference types="svelte/store" />` `/// <reference types="svelte/store" />`,
`/// <reference types="svelte/action" />`
); );
} }
@ -131,6 +128,10 @@ export async function get_parsed_docs(docs_data, slug) {
injected.push('// @esModuleInterop'); injected.push('// @esModuleInterop');
} }
if (page.file.includes('svelte-action')) {
injected.push("import type { Action, ActionReturn } from 'svelte/action';");
}
if (injected.length) { if (injected.length) {
const injected_str = injected.join('\n'); const injected_str = injected.join('\n');
if (source.includes('// @filename:')) { if (source.includes('// @filename:')) {
@ -138,7 +139,13 @@ export async function get_parsed_docs(docs_data, slug) {
} else { } else {
source = source.replace( source = source.replace(
/^(?!\/\/ @)/m, /^(?!\/\/ @)/m,
`${injected_str}\n\n// @filename: index.${language}\n// ---cut---\n`
`${injected_str}\n\n// @filename: index.${language}\n` +
injected.filter((val) => val.startsWith('import ')).join('\n') +
// This exists only for the JSDoc examples for svelte action types
'interface Parameter {}; \n' +
'// @errors: 2695 7006 2304 1128 1109 1005' +
` // ---cut---\n`
); );
} }
} }

Loading…
Cancel
Save