An open API service indexing awesome lists of open source software.

https://github.com/ghostdevv/extractinator


https://github.com/ghostdevv/extractinator

Last synced: 8 months ago
JSON representation

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\t
Test
\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"
}
]
}
````