|
| 1 | +## Functions |
| 2 | + |
| 3 | +<dl> |
| 4 | +<dt><a href="#File">File()</a></dt> |
| 5 | +<dd><p>Component is used to describe to the generator that you want a file to be created and rendered based on the defined children.</p> |
| 6 | +</dd> |
| 7 | +<dt><a href="#Indent">Indent()</a></dt> |
| 8 | +<dd><p>Component is for wrapping multiple components and apply an indentation on those.</p> |
| 9 | +<p>It supports any form of nested components as well, meaning you can have as many nested <code>Indent</code> components as you would like.</p> |
| 10 | +</dd> |
| 11 | +<dt><a href="#Text">Text()</a></dt> |
| 12 | +<dd><p>Component is for defining a group of text which should be rendered on the same line.</p> |
| 13 | +</dd> |
| 14 | +<dt><a href="#render">render(component)</a> ⇒ <code>string</code></dt> |
| 15 | +<dd><p>Renders given component to string</p> |
| 16 | +</dd> |
| 17 | +<dt><a href="#renderTemplate">renderTemplate(filepath)</a></dt> |
| 18 | +<dd><p>render a file with react. This function automatically transforms jsx to js before importing the component.</p> |
| 19 | +</dd> |
| 20 | +<dt><a href="#transpileFiles">transpileFiles(directory, outputDir, options)</a></dt> |
| 21 | +<dd><p>Transpile files in a given directory (and sub directory if recursive option are passed) and write it to an output directory, if no errors are thrown it completed successfully.</p> |
| 22 | +</dd> |
| 23 | +</dl> |
| 24 | + |
| 25 | +<a name="IndentationTypes"></a> |
| 26 | + |
| 27 | +## IndentationTypes : <code>enum</code> |
| 28 | +Type of indentation to use |
| 29 | + |
| 30 | +**Kind**: global enum |
| 31 | +**Read only**: true |
| 32 | +**Properties** |
| 33 | + |
| 34 | +| Name | Type | Description | |
| 35 | +| --- | --- | --- | |
| 36 | +| TABS | <code>string</code> | indicate to use tabs as separator | |
| 37 | +| SPACES | <code>string</code> | indicate to use spaces as separator | |
| 38 | + |
| 39 | +<a name="File"></a> |
| 40 | + |
| 41 | +## File() |
| 42 | +Component is used to describe to the generator that you want a file to be created and rendered based on the defined children. |
| 43 | + |
| 44 | +**Kind**: global function |
| 45 | +**Component**: |
| 46 | +**Example** |
| 47 | +```js |
| 48 | +const name = "test.js" |
| 49 | +const permissions = 0o777 |
| 50 | +return ( |
| 51 | + <File name={name} permissions={permissions}>Test</File> |
| 52 | +) |
| 53 | +``` |
| 54 | +<a name="Indent"></a> |
| 55 | + |
| 56 | +## Indent() |
| 57 | +Component is for wrapping multiple components and apply an indentation on those. |
| 58 | + |
| 59 | +It supports any form of nested components as well, meaning you can have as many nested `Indent` components as you would like. |
| 60 | + |
| 61 | +**Kind**: global function |
| 62 | +**Component**: |
| 63 | +**Example** |
| 64 | +```js |
| 65 | +const size = 4 |
| 66 | +const type = IndentationTypes.SPACES |
| 67 | +return ( |
| 68 | + <Indent size={size} type={type}>test</Indent> |
| 69 | +) |
| 70 | +``` |
| 71 | +<a name="Text"></a> |
| 72 | + |
| 73 | +## Text() |
| 74 | +Component is for defining a group of text which should be rendered on the same line. |
| 75 | + |
| 76 | +**Kind**: global function |
| 77 | +**Component**: |
| 78 | +**Example** |
| 79 | +```js |
| 80 | +const indent = 4 |
| 81 | +const type = IndentationTypes.SPACES |
| 82 | +const newLines = 2 |
| 83 | +return ( |
| 84 | + <Text indent={size} type={type} newLines={newLines}>Test</Text> |
| 85 | +) |
| 86 | +``` |
| 87 | +<a name="render"></a> |
| 88 | + |
| 89 | +## render(component) ⇒ <code>string</code> |
| 90 | +Renders given component to string |
| 91 | + |
| 92 | +**Kind**: global function |
| 93 | + |
| 94 | +| Param | Type | Description | |
| 95 | +| --- | --- | --- | |
| 96 | +| component | <code>ReactNode</code> | a given component to rendering | |
| 97 | + |
| 98 | +**Example** |
| 99 | +```js |
| 100 | +function Component({ textProp }) { |
| 101 | + return <>{textProp}</> |
| 102 | +} |
| 103 | +render(<Component textProp="someText" />) |
| 104 | +``` |
| 105 | +<a name="renderTemplate"></a> |
| 106 | + |
| 107 | +## renderTemplate(filepath) |
| 108 | +render a file with react. This function automatically transforms jsx to js before importing the component. |
| 109 | + |
| 110 | +**Kind**: global function |
| 111 | + |
| 112 | +| Param | Description | |
| 113 | +| --- | --- | |
| 114 | +| filepath | the path to file to render | |
| 115 | + |
| 116 | +<a name="transpileFiles"></a> |
| 117 | + |
| 118 | +## transpileFiles(directory, outputDir, options) |
| 119 | +Transpile files in a given directory (and sub directory if recursive option are passed) and write it to an output directory, if no errors are thrown it completed successfully. |
| 120 | + |
| 121 | +**Kind**: global function |
| 122 | + |
| 123 | +| Param | Description | |
| 124 | +| --- | --- | |
| 125 | +| directory | to transpile. | |
| 126 | +| outputDir | to write the transpiled files to. | |
| 127 | +| options | any extra options that should be passed. | |
| 128 | + |
0 commit comments