forked from writer/writer-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request writer#465 from anant-writer/dev
Implement writer framework documentation related to mintlify
- Loading branch information
Showing
250 changed files
with
14,375 additions
and
8,556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ src/ui/components.codegen.json | |
playground/ | ||
*.mp4 | ||
.turbo | ||
styles.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/** | ||
* Generates an example of component usage in Low Code | ||
* | ||
* @param component {object} Name of a component | ||
* @returns Example code {string} | ||
* | ||
* @example | ||
* component.low_code_usage = core.generateLowCodeUsage(component) | ||
*/ | ||
export function generateLowCodeUsage(component) { | ||
let contents = "content={\n" | ||
for (let fieldKey in component.fields) { | ||
const properties = component.fields[fieldKey] | ||
contents += ` "${fieldKey}": ${renderDefaultValue(properties)}, # ${renderPyType(properties['type'])} ${renderPyOptions(properties['options'])}\n` | ||
} | ||
contents += " }" | ||
|
||
let handlers = "" | ||
if (component.events && Object.keys(component.events).length > 0) { | ||
handlers += "\n,\n handlers={\n" | ||
for (let event in component.events) { | ||
handlers += ` "${event}": handle_event,\n` | ||
} | ||
handlers += " }" | ||
} | ||
|
||
// @ts-ignore | ||
let code = `ui.${component.name.replaceAll(/\s/g, "")}(${contents.trim()}${handlers.trim()} | ||
)` | ||
return code | ||
} | ||
|
||
/** | ||
* | ||
* @example | ||
* component.event_handler = core.generateEventHandler() | ||
*/ | ||
export function generateEventHandler() { | ||
let code = `def handle_event(state, payload, context, ui): | ||
pass` | ||
return code | ||
} | ||
|
||
/** | ||
* | ||
* @param obj {object} | ||
* @returns {*[]} | ||
*/ | ||
export function values(obj) { | ||
if (!obj) return []; | ||
|
||
return Object.keys(obj).map((key) => { | ||
return obj[key] | ||
}) | ||
} | ||
|
||
/** | ||
* | ||
* @param properties {object} | ||
* @returns {string} | ||
*/ | ||
function renderDefaultValue(properties) { | ||
const type = properties['type']; | ||
switch (type) { | ||
case "Number": | ||
return '0.0'; | ||
case "Object": | ||
return "{}"; | ||
case "Key-Value": | ||
return "{}"; | ||
default: | ||
if (properties['options'] && properties['default']) { | ||
return `"${ properties['default'] }"`; | ||
} | ||
|
||
return '""'; | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param type {string} | ||
* @returns {string} | ||
*/ | ||
const renderPyType = (type) => { | ||
switch (type) { | ||
case "Number": | ||
return "Union[float, str]"; | ||
case "Object": | ||
return "Union[Dict, str]"; | ||
case "Key-Value": | ||
return "Union[Dict, str]"; | ||
default: | ||
return "str"; | ||
} | ||
}; | ||
|
||
/** | ||
* | ||
* @param options {object} | ||
* @returns {string} | ||
*/ | ||
const renderPyOptions = (options) => { | ||
if (!options) return ""; | ||
|
||
return "[" + Object.keys(options).join(", ") + "]" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
!.gitignore | ||
!component_page.mdx.tpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: {{ name }} | ||
mode: "wide" | ||
--- | ||
|
||
{{ description }} | ||
|
||
<img src="/framework/public/components/{{type}}.png" /> | ||
|
||
{{ docs }} | ||
|
||
{% if fields %} | ||
## Fields | ||
|
||
<table className="componentFields"> | ||
<thead> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th class="desc">Description</th> | ||
<th>Options</th> | ||
</thead> | ||
<tbody> | ||
{% for _, field in fields %} | ||
<tr> | ||
<td>{{ field.name }}</td> | ||
<td>{{ field.type }}</td> | ||
<td>{{ field.desc }}</td> | ||
<td> | ||
<ol> | ||
{% for _, option in field.options %} | ||
<li>{{ option }}</li> | ||
{% endfor %} | ||
</ol> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endif %} | ||
|
||
{% if events %} | ||
## Events | ||
<AccordionGroup> | ||
{% for event, eventInfo in events %} | ||
<Accordion title="{{ event }}" icon="code"> | ||
{{ eventInfo.desc }} | ||
|
||
```python | ||
{{ eventInfo.stub | safe }} | ||
``` | ||
</Accordion> | ||
{% endfor %} | ||
</AccordionGroup> | ||
{% endif %} | ||
|
||
## Low code usage | ||
|
||
This component can be declared directly in Python, using [backend-driven UI](../backend-driven-ui). | ||
|
||
```python | ||
{{ low_code_usage | safe }} | ||
``` | ||
|
||
{% if events %} | ||
A function, in this example `handle_event`, should be implemented in your code to handle events. | ||
```python | ||
{{ event_handler | safe }} | ||
``` | ||
{% endif %} | ||
|
||
|
||
## Reference | ||
|
||
* <a href="https://github.com/streamsync-cloud/streamsync/blob/dev/src/ui/{{fileRef}}" target="_blank" >Explore this component's source code on GitHub</a> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.