https://github.com/ghostdevv/extractinator
https://github.com/ghostdevv/extractinator
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ghostdevv/extractinator
- Owner: ghostdevv
- License: mit
- Created: 2023-10-13T00:54:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-24T04:52:11.000Z (over 1 year ago)
- Last Synced: 2025-07-01T23:40:39.536Z (9 months ago)
- Language: TypeScript
- Size: 247 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Extractinator
A tool to extract the api information from Svelte and TS/JS files. Extract slots, events, module exports, props, and css props all with parsed tsdoc comments.
## Usage
Install
`pnpm i -D extractinator`
Extract
`pnpm extractinator extract `
## Requirements
| Tool | Version |
| ------ | --------------------------------- |
| Node | v18 >= |
| TS | 5.3 (other v5 may work, untested) |
| Svelte | v4 |
## CLI
```bash
$ extractinator --help
Usage
$ extractinator [options]
Available Commands
extract Extract the nator
For more info, run any command with the `--help` flag
$ extractinator extract --help
Options
--version -v Displays current version
--help -h Displays this message
--quiet -q Disabled all logging
--verbose Enables verbose logging
```
## JS API
```ts
import { extractinator } from 'extractinator'
interface ExtractinatorOptions {
input: string
tsdocConfigPath?: string
}
const results = await extractinator({
// Path to the input file(s). Will recursively search for svelte and ts files.
input: './playground',
// (optional) Path to a custom tsdoc config. This will be merged with the internal config.
tsdocConfigPath: './tsdoc.json',
})
```
## Example
Input:
`Example.svelte`
````html
import { writable } from 'svelte/store'
/**
* The state the component is in
* @default true
*/
export const state = (writable < string) | number | (boolean > true)
/**
* Let the thing know whether it's on earth
*/
export let isExample: boolean
Is an example: {isExample}
````
Output:
`Example.svelte.doc.json`
````json
{
"type": "svelte",
"fileName": "Example.svelte",
"filePath": "playground/Example.svelte",
"comment": {
"raw": "/**\n * Example Svelte Component\n *\n * @example\n *\n * Simple\n * ```html\n * \n * ```\n *\n * @example\n *\n * Slots ```html
Test \n */",
"summary": "Example Svelte Component",
"examples": [
{
"name": "Simple",
"content": "```html\n\n```"
},
{
"name": "Slots",
"content": "```html\n\n\tTest\n"
}
]
},
"componentName": "Example",
"props": [
{
"comment": {
"raw": "/**\n * Let the thing know whether it's an example or not.\n */",
"summary": "Let the thing know whether it's an example or not."
},
"name": "isExample",
"type": "boolean"
}
],
"events": [
{
"name": "click",
"type": "HTMLElementEventMap"
}
],
"slots": [
{
"name": "default",
"props": [
{
"name": "isExample",
"type": "boolean"
}
]
},
{
"name": "test",
"props": []
}
],
"exports": [
{
"comment": {
"raw": "/**\n * The state the component is in\n *\n * @default\n *\n * true\n */",
"summary": "The state the component is in",
"defaultValue": "true"
},
"name": "state",
"type": "Writable"
}
]
}
````