Skip to content

Commit

Permalink
feat: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Col0ring committed Nov 29, 2024
1 parent 76ff31d commit c4258be
Show file tree
Hide file tree
Showing 30 changed files with 375 additions and 9 deletions.
17 changes: 17 additions & 0 deletions .changeset/late-cameras-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@modelscope-studio/legacy-waterfall-gallery': patch
'@modelscope-studio/legacy-multimodal-input': patch
'@modelscope-studio/legacy-lifecycle': patch
'@modelscope-studio/legacy-markdown': patch
'@modelscope-studio/legacy-compiled': patch
'@modelscope-studio/legacy-chatbot': patch
'@modelscope-studio/legacy-flow': patch
'@modelscope-studio/lint-config': patch
'@modelscope-studio/changelog': patch
'@modelscope-studio/antd': patch
'@modelscope-studio/base': patch
'@modelscope-studio/frontend': patch
'modelscope_studio': patch
---

fix: component paramters in Python
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ demo.queue().launch()

## Migration to 1.0

If you have previously used `modelscope_studio` components and want to continue using them in the new version, no modifications to the original components are needed. You just need to introduce `ms.Application` in the outer layer.
If you have used the `modelscope_studio` component before and want to continue using it in the new version, you do not need to make any changes to the original component, just import `ms.Application` in the outer layer.

```python
import gradio as gr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,18 @@ def __init__(
allow_clear: bool | dict | None = None,
auto_focus: bool | None = None,
auto_size: bool | dict | None = None,
class_names: dict | None = None,
default_value: str | None = None,
filter_option: bool | str | None = None,
disabled: bool | None = None,
read_only: bool | None = None,
get_popup_container: str | None = None,
popup_class_name: str | None = None,
not_found_content: str | None = None,
options: list[dict] | None = None,
loading: bool | None = None,
placement: Literal['top', 'bottom'] | None = None,
placeholder: str | None = None,
prefix: str | list[str] | None = '@',
split: str | None = None,
status: Literal['error', 'warning'] | None = None,
Expand Down Expand Up @@ -90,9 +94,13 @@ def __init__(
self.disabled = disabled
self.read_only = read_only
self.get_popup_container = get_popup_container
self.popup_class_name = popup_class_name
self.not_found_content = not_found_content
self.options = options
self.placeholder = placeholder
self.loading = loading
self.placement = placement
self.class_names = class_names
self.prefix = prefix
self.split = split
self.status = status
Expand Down
2 changes: 1 addition & 1 deletion backend/modelscope_studio/components/antd/rate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(
auto_focus: bool | None = None,
character: str | None = None,
count: int | float | None = 5,
default_value: int | float | None = 0,
default_value: int | float | None = None,
disabled: bool | None = None,
keyboard: bool | None = None,
tooltips: list[str] | None = None,
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pip install modelscope_studio~=1.0.0b

## Migration to 1.0

If you have previously used `modelscope_studio` components and want to continue using them in the new version, no modifications to the original components are needed. You just need to introduce `ms.Application` in the outer layer.
If you have used the `modelscope_studio` component before and want to continue using it in the new version, you do not need to make any changes to the original component, just import `ms.Application` in the outer layer.

```python
import gradio as gr
Expand Down
12 changes: 12 additions & 0 deletions docs/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ def get_docs(file_path: str, type: Literal["antd", "base"]):
}, {
"label": get_text("Input", "Input 输入框"),
"key": "input"
}, {
"label": get_text("InputNumber", "InputNumber 数字输入框"),
"key": "input_number"
}, {
"label": get_text("Mentions", "Mentions 提及"),
"key": "mentions"
}, {
"label": get_text("Radio", "Radio 单选框"),
"key": "radio"
}, {
"label": get_text("Rate", "Rate 评分"),
"key": "rate"
}, {
"label": get_text("Select", "Select 选择器"),
"key": "select"
Expand Down
7 changes: 7 additions & 0 deletions docs/components/antd/input/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Input

Through mouse or keyboard input content, it is the most basic form field wrapper. See [Ant Design](https://ant.design/components/input/) for more information.

## Examples

<demo name="basic"></demo>
7 changes: 7 additions & 0 deletions docs/components/antd/input/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Input

Through mouse or keyboard input content, it is the most basic form field wrapper. See [Ant Design](https://ant.design/components/input/) for more information.

## Examples

<demo name="basic"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/input/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from helper.Docs import Docs

docs = Docs(__file__)

if __name__ == "__main__":
docs.render().queue().launch()
31 changes: 31 additions & 0 deletions docs/components/antd/input/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.Space(direction="vertical"):
antd.Input()
antd.Input.Password()
antd.Input.Textarea(
placeholder=
"Autosize height with minimum and maximum number of lines",
auto_size={
"minRows": 2,
"maxRows": 6
})
antd.Input.Search(placeholder="Input search text",
addon_before="https://",
allow_clear=True)
with antd.Input.Search(enter_button="Search",
placeholder="input search text",
size="large"):
with ms.Slot("suffix"):
antd.Icon("AudioOutlined",
elem_style=dict(fontSize=16,
color="#1677ff"))
antd.Input.OTP()
if __name__ == "__main__":
demo.queue().launch()
7 changes: 7 additions & 0 deletions docs/components/antd/input_number/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# InputNumber

Enter a number within certain range with the mouse or keyboard. See [Ant Design](https://ant.design/components/input-number/) for more information.

## Examples

<demo name="basic"></demo>
7 changes: 7 additions & 0 deletions docs/components/antd/input_number/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# InputNumber

Enter a number within certain range with the mouse or keyboard. See [Ant Design](https://ant.design/components/input-number/) for more information.

## Examples

<demo name="basic"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/input_number/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from helper.Docs import Docs

docs = Docs(__file__)

if __name__ == "__main__":
docs.render().queue().launch()
42 changes: 42 additions & 0 deletions docs/components/antd/input_number/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.Space(direction="vertical"):
antd.InputNumber()
antd.InputNumber(min=1, max=10, keyboard=True)
antd.InputNumber(value=100, addon_after="$", addon_before="+")
with antd.InputNumber(value=100):
with ms.Slot("addonBefore"):
antd.Select(value="add",
elem_style=dict(width=60),
options=[{
"value": "add",
"label": "+"
}, {
"value": "minus",
"label": "-"
}])
with ms.Slot("addonAfter"):
antd.Select(value="USD",
elem_style=dict(width=60),
options=[{
"value": "USD",
"label": "$"
}, {
"value": "EUR",
"label": "€"
}, {
"value": "GBP",
"label": "£"
}, {
"value": "CNY",
"label": "¥"
}])

if __name__ == "__main__":
demo.queue().launch()
8 changes: 8 additions & 0 deletions docs/components/antd/mentions/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Mentions

Used to mention someone or something in an input. See [Ant Design](https://ant.design/components/mentions/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="dynamic_options" title="Dynamic Options"></demo>
8 changes: 8 additions & 0 deletions docs/components/antd/mentions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Mentions

Used to mention someone or something in an input. See [Ant Design](https://ant.design/components/mentions/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="dynamic_options" title="Dynamic Options"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/mentions/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from helper.Docs import Docs

docs = Docs(__file__)

if __name__ == "__main__":
docs.render().queue().launch()
36 changes: 36 additions & 0 deletions docs/components/antd/mentions/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.Space(direction="vertical"):
antd.Mentions(elem_style=dict(width=320),
placeholder="Input @ to mention",
options=[{
"value": "modelscope",
"label": "modelscope"
}, {
"value": "gradio",
"label": "gradio"
}, {
"value": "ant design",
"label": "ant design"
}])
with antd.Mentions(elem_style=dict(width=320),
prefix=['@', "#"],
placeholder="Input @ or # to mention"):
with antd.Mentions.Option(value="modelscope"):
with ms.Slot("label"):
antd.Typography.Text("modelscope", type="success")
with antd.Mentions.Option(value="gradio"):
with ms.Slot("label"):
antd.Typography.Text("gradio", type="success")
with antd.Mentions.Option(value="ant design"):
with ms.Slot("label"):
antd.Typography.Text("ant design", type="success")

if __name__ == "__main__":
demo.queue().launch()
43 changes: 43 additions & 0 deletions docs/components/antd/mentions/demos/dynamic_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms


def on_search(e: gr.EventData):
prefix = e._data['payload'][1]
if prefix == '@':
return gr.update(options=[{
"value": "modelscope",
"label": "modelscope"
}, {
"value": "gradio",
"label": "gradio"
}, {
"value": "ant design",
"label": "ant design"
}])
elif prefix == '#':
return gr.update(options=[{
"value": "1.0",
"label": "1.0"
}, {
"value": "2.0",
"label": "2.0"
}, {
"value": "3.0",
"label": "3.0"
}])


with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
mentions = antd.Mentions(
elem_style=dict(width='100%'),
prefix=['@', "#"],
placeholder="input @ to mention people, # to mention tag")
mentions.search(fn=on_search, outputs=[mentions])

if __name__ == "__main__":
demo.queue().launch()
7 changes: 7 additions & 0 deletions docs/components/antd/radio/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Radio

Used to select a single state from multiple options. See [Ant Design](https://ant.design/components/radio/) for more information.

## Examples

<demo name="basic"></demo>
7 changes: 7 additions & 0 deletions docs/components/antd/radio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Radio

Used to select a single state from multiple options. See [Ant Design](https://ant.design/components/radio/) for more information.

## Examples

<demo name="basic"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/radio/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from helper.Docs import Docs

docs = Docs(__file__)

if __name__ == "__main__":
docs.render().queue().launch()
40 changes: 40 additions & 0 deletions docs/components/antd/radio/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.Radio():
ms.Text("Radio")
antd.Divider("Radio Group")
with antd.Radio.Group():
with antd.Radio(group_value=1):
ms.Text("A")
with antd.Radio(group_value=2):
ms.Text("B")
with antd.Radio(group_value=3):
ms.Text("C")
with antd.Radio(group_value=4):
ms.Text("D")
antd.Divider("Configuring Options")
antd.Radio.Group(option_type="button",
button_style="solid",
options=[
{
"label": 'Apple',
"value": 'Apple'
},
{
"label": 'Pear',
"value": 'Pear'
},
{
"label": 'Orange',
"value": 'Orange',
"disabled": True
},
])
if __name__ == "__main__":
demo.queue().launch()
7 changes: 7 additions & 0 deletions docs/components/antd/rate/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Rate

Used for rating operation on something. See [Ant Design](https://ant.design/components/rate/) for more information.

## Examples

<demo name="basic"></demo>
Loading

0 comments on commit c4258be

Please sign in to comment.