mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
Determine documentation group automatically (#7062)
This commit is contained in:
parent
2e6672c815
commit
0fddd0f971
6
.changeset/easy-nights-fly.md
Normal file
6
.changeset/easy-nights-fly.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"gradio": minor
|
||||
"gradio_client": minor
|
||||
---
|
||||
|
||||
feat:Determine documentation group automatically
|
@ -31,7 +31,7 @@ from huggingface_hub.utils import (
|
||||
from packaging import version
|
||||
|
||||
from gradio_client import serializing, utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from gradio_client.exceptions import SerializationSetupError
|
||||
from gradio_client.utils import (
|
||||
Communicator,
|
||||
@ -43,9 +43,6 @@ from gradio_client.utils import (
|
||||
StatusUpdate,
|
||||
)
|
||||
|
||||
set_documentation_group("py-client")
|
||||
|
||||
|
||||
DEFAULT_TEMP_DIR = os.environ.get("GRADIO_TEMP_DIR") or str(
|
||||
Path(tempfile.gettempdir()) / "gradio"
|
||||
)
|
||||
|
@ -3,18 +3,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
import warnings
|
||||
from collections import defaultdict
|
||||
from functools import lru_cache
|
||||
from typing import Callable
|
||||
|
||||
classes_to_document = {}
|
||||
classes_to_document = defaultdict(list)
|
||||
classes_inherit_documentation = {}
|
||||
documentation_group = None
|
||||
|
||||
|
||||
def set_documentation_group(m):
|
||||
global documentation_group # noqa: PLW0603
|
||||
documentation_group = m
|
||||
if m not in classes_to_document:
|
||||
classes_to_document[m] = []
|
||||
|
||||
|
||||
def extract_instance_attr_doc(cls, attr):
|
||||
@ -42,7 +37,33 @@ def extract_instance_attr_doc(cls, attr):
|
||||
return doc_string
|
||||
|
||||
|
||||
def document(*fns, inherit=False):
|
||||
_module_prefixes = [
|
||||
("gradio._simple_templates", "component"),
|
||||
("gradio.block", "block"),
|
||||
("gradio.chat", "chatinterface"),
|
||||
("gradio.component", "component"),
|
||||
("gradio.events", "helpers"),
|
||||
("gradio.exceptions", "helpers"),
|
||||
("gradio.external", "helpers"),
|
||||
("gradio.flag", "flagging"),
|
||||
("gradio.helpers", "helpers"),
|
||||
("gradio.interface", "interface"),
|
||||
("gradio.layout", "layout"),
|
||||
("gradio.route", "routes"),
|
||||
("gradio.theme", "themes"),
|
||||
("gradio_client", "py-client"),
|
||||
]
|
||||
|
||||
|
||||
@lru_cache(maxsize=10)
|
||||
def _get_module_documentation_group(modname) -> str:
|
||||
for prefix, group in _module_prefixes:
|
||||
if modname.startswith(prefix):
|
||||
return group
|
||||
raise ValueError(f"No known documentation group for module {modname!r}")
|
||||
|
||||
|
||||
def document(*fns, inherit=False, documentation_group=None):
|
||||
"""
|
||||
Defines the @document decorator which adds classes or functions to the Gradio
|
||||
documentation at www.gradio.app/docs.
|
||||
@ -52,6 +73,7 @@ def document(*fns, inherit=False):
|
||||
- Put @document("fn1", "fn2") above a class to also document methods fn1 and fn2.
|
||||
- Put @document("*fn3") with an asterisk above a class to document the instance attribute methods f3.
|
||||
"""
|
||||
_documentation_group = documentation_group
|
||||
|
||||
def inner_doc(cls):
|
||||
functions = list(fns)
|
||||
@ -59,6 +81,14 @@ def document(*fns, inherit=False):
|
||||
functions += cls.EVENTS
|
||||
if inherit:
|
||||
classes_inherit_documentation[cls] = None
|
||||
|
||||
documentation_group = _documentation_group # avoid `nonlocal` reassignment
|
||||
if _documentation_group is None:
|
||||
try:
|
||||
modname = inspect.getmodule(cls).__name__ # type: ignore
|
||||
documentation_group = _get_module_documentation_group(modname)
|
||||
except Exception as exc:
|
||||
warnings.warn(f"Could not get documentation group for {cls}: {exc}")
|
||||
classes_to_document[documentation_group].append((cls, functions))
|
||||
return cls
|
||||
|
||||
|
@ -5,14 +5,12 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import FileData
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class SimpleImage(Component):
|
||||
|
@ -24,7 +24,7 @@ import anyio
|
||||
import httpx
|
||||
from anyio import CapacityLimiter
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import (
|
||||
analytics,
|
||||
@ -77,7 +77,6 @@ try:
|
||||
except Exception:
|
||||
spaces = None
|
||||
|
||||
set_documentation_group("blocks")
|
||||
|
||||
if TYPE_CHECKING: # Only import for type checking (is False at runtime).
|
||||
from fastapi.applications import FastAPI
|
||||
|
@ -10,7 +10,7 @@ from typing import AsyncGenerator, Callable, Literal, Union, cast
|
||||
|
||||
import anyio
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.blocks import Blocks
|
||||
from gradio.components import (
|
||||
@ -30,8 +30,6 @@ from gradio.routes import Request
|
||||
from gradio.themes import ThemeClass as Theme
|
||||
from gradio.utils import SyncToAsyncIterator, async_iteration
|
||||
|
||||
set_documentation_group("chatinterface")
|
||||
|
||||
|
||||
@document()
|
||||
class ChatInterface(Blocks):
|
||||
|
@ -6,14 +6,14 @@ from typing import Any, List
|
||||
|
||||
import numpy as np
|
||||
import PIL.Image
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import processing_utils, utils
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import FileData, GradioModel
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
PIL.Image.init() # fixes https://github.com/gradio-app/gradio/issues/2843
|
||||
|
||||
|
||||
class Annotation(GradioModel):
|
||||
|
@ -9,7 +9,7 @@ from typing import Any, Callable, Literal
|
||||
import httpx
|
||||
import numpy as np
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import processing_utils, utils
|
||||
from gradio.components.base import Component, StreamingInput, StreamingOutput
|
||||
@ -17,8 +17,6 @@ from gradio.data_classes import FileData
|
||||
from gradio.events import Events
|
||||
from gradio.exceptions import Error
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class WaveformOptions:
|
||||
|
@ -6,12 +6,10 @@ from typing import Any, Callable, Literal
|
||||
|
||||
import altair as alt
|
||||
import pandas as pd
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.plot import AltairPlot, AltairPlotData, Plot
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class BarPlot(Plot):
|
||||
|
@ -14,8 +14,6 @@ from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, Callable
|
||||
|
||||
from gradio_client.documentation import set_documentation_group
|
||||
|
||||
from gradio import utils
|
||||
from gradio.blocks import Block, BlockContext
|
||||
from gradio.component_meta import ComponentMeta
|
||||
@ -32,9 +30,6 @@ if TYPE_CHECKING:
|
||||
data: list[list[str | int | bool]]
|
||||
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
class _Keywords(Enum):
|
||||
NO_VALUE = "NO_VALUE" # Used as a sentinel to determine if nothing is provided as a argument for `value` in `Component.update()`
|
||||
FINISHED_ITERATING = "FINISHED_ITERATING" # Used to skip processing of a component's value (needed for generators + state)
|
||||
|
@ -4,13 +4,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Button(Component):
|
||||
|
@ -7,15 +7,13 @@ from pathlib import Path
|
||||
from typing import Any, Callable, List, Literal, Optional, Tuple, Union
|
||||
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import processing_utils, utils
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import FileData, GradioModel, GradioRootModel
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
class FileMessage(GradioModel):
|
||||
file: FileData
|
||||
|
@ -4,13 +4,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import FormComponent
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Checkbox(FormComponent):
|
||||
|
@ -4,13 +4,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import FormComponent
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class CheckboxGroup(FormComponent):
|
||||
|
@ -6,15 +6,13 @@ import copy
|
||||
import json
|
||||
from typing import Any, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components import Button, Component
|
||||
from gradio.context import Context
|
||||
from gradio.data_classes import GradioModel, GradioRootModel
|
||||
from gradio.utils import resolve_singleton
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document("add")
|
||||
class ClearButton(Button):
|
||||
|
@ -5,13 +5,11 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
from typing import Any, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document("languages")
|
||||
class Code(Component):
|
||||
|
@ -4,13 +4,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class ColorPicker(Component):
|
||||
|
@ -18,7 +18,7 @@ from typing import (
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import semantic_version
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from pandas.io.formats.style import Styler
|
||||
|
||||
from gradio.components import Component
|
||||
@ -48,9 +48,6 @@ class DataframeData(GradioModel):
|
||||
metadata: Optional[Dict[str, Optional[List[Any]]]] = None
|
||||
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Dataframe(Component):
|
||||
"""
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import processing_utils
|
||||
from gradio.components.base import (
|
||||
@ -13,8 +13,6 @@ from gradio.components.base import (
|
||||
)
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Dataset(Component):
|
||||
|
@ -5,13 +5,11 @@ from __future__ import annotations
|
||||
import warnings
|
||||
from typing import Any, Callable, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import FormComponent
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Dropdown(FormComponent):
|
||||
|
@ -4,14 +4,12 @@ from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components import Button
|
||||
from gradio.context import Context
|
||||
from gradio.utils import get_space
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class DuplicateButton(Button):
|
||||
|
@ -7,15 +7,13 @@ import warnings
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import FileData, ListFiles
|
||||
from gradio.events import Events
|
||||
from gradio.utils import NamedString
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class File(Component):
|
||||
|
@ -9,13 +9,11 @@ import warnings
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, List, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component, server
|
||||
from gradio.data_classes import GradioRootModel
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
class FileExplorerData(GradioRootModel):
|
||||
root: List[List[str]]
|
||||
|
@ -8,7 +8,7 @@ from urllib.parse import urlparse
|
||||
|
||||
import numpy as np
|
||||
import PIL.Image
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from gradio_client.utils import is_http_url_like
|
||||
|
||||
from gradio import processing_utils, utils
|
||||
@ -16,9 +16,6 @@ from gradio.components.base import Component
|
||||
from gradio.data_classes import FileData, GradioModel, GradioRootModel
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
GalleryImageType = Union[np.ndarray, PIL.Image.Image, Path, str]
|
||||
CaptionedGalleryImageType = Tuple[GalleryImageType, str]
|
||||
|
||||
|
@ -4,14 +4,12 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable, List, Union
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import GradioModel, GradioRootModel
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
class HighlightedToken(GradioModel):
|
||||
token: str
|
||||
|
@ -4,13 +4,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class HTML(Component):
|
||||
|
@ -8,7 +8,7 @@ from typing import Any, Literal, cast
|
||||
|
||||
import numpy as np
|
||||
import PIL.Image
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from PIL import ImageOps
|
||||
|
||||
from gradio import image_utils, utils
|
||||
@ -16,7 +16,7 @@ from gradio.components.base import Component, StreamingInput
|
||||
from gradio.data_classes import FileData
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
PIL.Image.init() # fixes https://github.com/gradio-app/gradio/issues/2843
|
||||
|
||||
|
||||
@document()
|
||||
|
@ -9,16 +9,13 @@ from typing import Any, Iterable, List, Literal, Optional, TypedDict, Union, cas
|
||||
|
||||
import numpy as np
|
||||
import PIL.Image
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import image_utils, utils
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import FileData, GradioModel
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
ImageType = Union[np.ndarray, PIL.Image.Image, str]
|
||||
|
||||
|
||||
|
@ -6,13 +6,11 @@ import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class JSON(Component):
|
||||
|
@ -7,14 +7,12 @@ import operator
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, List, Optional, Union
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import GradioModel
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
class LabelConfidence(GradioModel):
|
||||
label: Optional[Union[str, int, float]] = None
|
||||
|
@ -6,12 +6,10 @@ from typing import Any, Callable, Literal
|
||||
|
||||
import altair as alt
|
||||
import pandas as pd
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.plot import AltairPlot, AltairPlotData, Plot
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class LinePlot(Plot):
|
||||
|
@ -5,14 +5,12 @@ import json
|
||||
import warnings
|
||||
from typing import Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components import Button
|
||||
from gradio.context import Context
|
||||
from gradio.routes import Request
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class LoginButton(Button):
|
||||
|
@ -4,12 +4,10 @@ from __future__ import annotations
|
||||
import warnings
|
||||
from typing import Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components import Button
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class LogoutButton(Button):
|
||||
|
@ -5,13 +5,11 @@ from __future__ import annotations
|
||||
import inspect
|
||||
from typing import Any, Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Markdown(Component):
|
||||
|
@ -5,14 +5,12 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import FileData
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Model3D(Component):
|
||||
|
@ -4,14 +4,12 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import FormComponent
|
||||
from gradio.events import Events
|
||||
from gradio.exceptions import Error
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Number(FormComponent):
|
||||
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Literal, TypedDict
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.events import Events
|
||||
@ -14,9 +14,6 @@ class Parameter(TypedDict):
|
||||
default: str | None
|
||||
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class ParamViewer(Component):
|
||||
"""
|
||||
|
@ -7,15 +7,13 @@ from types import ModuleType
|
||||
from typing import Any, Literal
|
||||
|
||||
import altair as alt
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import processing_utils
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import GradioModel
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
class PlotData(GradioModel):
|
||||
type: Literal["altair", "bokeh", "plotly", "matplotlib"]
|
||||
|
@ -4,13 +4,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import FormComponent
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Radio(FormComponent):
|
||||
|
@ -6,13 +6,11 @@ from typing import Any, Callable, Literal
|
||||
|
||||
import altair as alt
|
||||
import pandas as pd
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from pandas.api.types import is_numeric_dtype
|
||||
|
||||
from gradio.components.plot import AltairPlot, AltairPlotData, Plot
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class ScatterPlot(Plot):
|
||||
|
@ -6,13 +6,11 @@ import math
|
||||
import random
|
||||
from typing import Any, Callable
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import FormComponent
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Slider(FormComponent):
|
||||
|
@ -5,12 +5,10 @@ from __future__ import annotations
|
||||
from copy import deepcopy
|
||||
from typing import Any
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class State(Component):
|
||||
|
@ -4,13 +4,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import FormComponent
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class Textbox(FormComponent):
|
||||
|
@ -7,15 +7,13 @@ import warnings
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.components.base import Component
|
||||
from gradio.data_classes import FileData, ListFiles
|
||||
from gradio.events import Events
|
||||
from gradio.utils import NamedString
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
@document()
|
||||
class UploadButton(Component):
|
||||
|
@ -8,7 +8,7 @@ from pathlib import Path
|
||||
from typing import Any, Callable, Literal, Optional
|
||||
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
import gradio as gr
|
||||
from gradio import processing_utils, utils, wasm_utils
|
||||
@ -20,8 +20,6 @@ if not wasm_utils.IS_WASM:
|
||||
# TODO: Support ffmpeg on Wasm
|
||||
from ffmpy import FFmpeg
|
||||
|
||||
set_documentation_group("component")
|
||||
|
||||
|
||||
class VideoData(GradioModel):
|
||||
video: FileData
|
||||
|
@ -1,6 +1,4 @@
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
|
||||
set_documentation_group("helpers")
|
||||
from gradio_client.documentation import document
|
||||
|
||||
|
||||
class DuplicateBlockError(ValueError):
|
||||
@ -61,10 +59,8 @@ class GradioVersionIncompatibleError(Exception):
|
||||
|
||||
InvalidApiName = InvalidApiNameError # backwards compatibility
|
||||
|
||||
set_documentation_group("modals")
|
||||
|
||||
|
||||
@document()
|
||||
@document(documentation_group="modals")
|
||||
class Error(Exception):
|
||||
"""
|
||||
This class allows you to pass custom error messages to the user. You can do so by raising a gr.Error("custom message") anywhere in the code, and when that line is executed the custom message will appear in a modal on the demo.
|
||||
|
@ -15,7 +15,7 @@ import httpx
|
||||
from gradio_client import Client
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.client import Endpoint
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from packaging import version
|
||||
|
||||
import gradio
|
||||
@ -42,9 +42,6 @@ if TYPE_CHECKING:
|
||||
from gradio.interface import Interface
|
||||
|
||||
|
||||
set_documentation_group("helpers")
|
||||
|
||||
|
||||
@document()
|
||||
def load(
|
||||
name: str,
|
||||
|
@ -14,7 +14,7 @@ from typing import TYPE_CHECKING, Any
|
||||
import filelock
|
||||
import huggingface_hub
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
import gradio as gr
|
||||
from gradio import utils
|
||||
@ -22,8 +22,6 @@ from gradio import utils
|
||||
if TYPE_CHECKING:
|
||||
from gradio.components import Component
|
||||
|
||||
set_documentation_group("flagging")
|
||||
|
||||
|
||||
class FlaggingCallback(ABC):
|
||||
"""
|
||||
|
@ -19,7 +19,7 @@ import numpy as np
|
||||
import PIL
|
||||
import PIL.Image
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import components, oauth, processing_utils, routes, utils, wasm_utils
|
||||
from gradio.context import Context, LocalContext
|
||||
@ -33,8 +33,6 @@ if TYPE_CHECKING: # Only import for type checking (to avoid circular imports).
|
||||
|
||||
LOG_FILE = "log.csv"
|
||||
|
||||
set_documentation_group("helpers")
|
||||
|
||||
|
||||
def create_examples(
|
||||
examples: list[Any] | list[list[Any]] | str,
|
||||
@ -1118,10 +1116,7 @@ def log_message(message: str, level: Literal["info", "warning"] = "info"):
|
||||
blocks._queue.log_message(event_id=event_id, log=message, level=level)
|
||||
|
||||
|
||||
set_documentation_group("modals")
|
||||
|
||||
|
||||
@document()
|
||||
@document(documentation_group="modals")
|
||||
def Warning(message: str = "Warning issued."): # noqa: N802
|
||||
"""
|
||||
This function allows you to pass custom warning messages to the user. You can do so simply by writing `gr.Warning('message here')` in your function, and when that line is executed the custom message will appear in a modal on the demo. The modal is yellow by default and has the heading: "Warning." Queue must be enabled for this behavior; otherwise, the warning will be printed to the console using the `warnings` library.
|
||||
@ -1141,7 +1136,7 @@ def Warning(message: str = "Warning issued."): # noqa: N802
|
||||
log_message(message, level="warning")
|
||||
|
||||
|
||||
@document()
|
||||
@document(documentation_group="modals")
|
||||
def Info(message: str = "Info issued."): # noqa: N802
|
||||
"""
|
||||
This function allows you to pass custom info messages to the user. You can do so simply by writing `gr.Info('message here')` in your function, and when that line is executed the custom message will appear in a modal on the demo. The modal is gray by default and has the heading: "Info." Queue must be enabled for this behavior; otherwise, the message will be printed to the console.
|
||||
|
@ -11,7 +11,7 @@ import warnings
|
||||
import weakref
|
||||
from typing import TYPE_CHECKING, Any, Callable, Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio import Examples, utils
|
||||
from gradio.blocks import Blocks
|
||||
@ -32,8 +32,6 @@ from gradio.layouts import Accordion, Column, Row, Tab, Tabs
|
||||
from gradio.pipelines import load_from_pipeline
|
||||
from gradio.themes import ThemeClass as Theme
|
||||
|
||||
set_documentation_group("interface")
|
||||
|
||||
if TYPE_CHECKING: # Only import for type checking (is False at runtime).
|
||||
from transformers.pipelines.base import Pipeline
|
||||
|
||||
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.blocks import BlockContext
|
||||
from gradio.component_meta import ComponentMeta
|
||||
@ -10,8 +10,6 @@ from gradio.component_meta import ComponentMeta
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
set_documentation_group("layout")
|
||||
|
||||
|
||||
@document()
|
||||
class Accordion(BlockContext, metaclass=ComponentMeta):
|
||||
|
@ -3,13 +3,11 @@ from __future__ import annotations
|
||||
import warnings
|
||||
from typing import Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.blocks import BlockContext
|
||||
from gradio.component_meta import ComponentMeta
|
||||
|
||||
set_documentation_group("layout")
|
||||
|
||||
|
||||
@document()
|
||||
class Column(BlockContext, metaclass=ComponentMeta):
|
||||
|
@ -2,8 +2,6 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from gradio_client.documentation import set_documentation_group
|
||||
|
||||
from gradio.blocks import BlockContext
|
||||
from gradio.component_meta import ComponentMeta
|
||||
from gradio.layouts.row import Row
|
||||
@ -11,8 +9,6 @@ from gradio.layouts.row import Row
|
||||
if TYPE_CHECKING:
|
||||
from gradio.blocks import Block
|
||||
|
||||
set_documentation_group("layout")
|
||||
|
||||
|
||||
class Form(BlockContext, metaclass=ComponentMeta):
|
||||
EVENTS = []
|
||||
|
@ -1,12 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.blocks import BlockContext
|
||||
from gradio.component_meta import ComponentMeta
|
||||
|
||||
set_documentation_group("layout")
|
||||
|
||||
|
||||
@document()
|
||||
class Group(BlockContext, metaclass=ComponentMeta):
|
||||
|
@ -2,13 +2,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.blocks import BlockContext
|
||||
from gradio.component_meta import ComponentMeta
|
||||
|
||||
set_documentation_group("layout")
|
||||
|
||||
|
||||
@document()
|
||||
class Row(BlockContext, metaclass=ComponentMeta):
|
||||
|
@ -1,13 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
|
||||
from gradio.blocks import BlockContext
|
||||
from gradio.component_meta import ComponentMeta
|
||||
from gradio.events import Events
|
||||
|
||||
set_documentation_group("layout")
|
||||
|
||||
|
||||
class Tabs(BlockContext, metaclass=ComponentMeta):
|
||||
"""
|
||||
|
@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, AsyncGenerator, BinaryIO, List, Optional, Tupl
|
||||
import fastapi
|
||||
import httpx
|
||||
import multipart
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from multipart.multipart import parse_options_header
|
||||
from starlette.datastructures import FormData, Headers, UploadFile
|
||||
from starlette.formparsers import MultiPartException, MultipartPart
|
||||
@ -25,8 +25,6 @@ if TYPE_CHECKING:
|
||||
from gradio.blocks import Blocks
|
||||
from gradio.routes import App
|
||||
|
||||
set_documentation_group("routes")
|
||||
|
||||
|
||||
class Obj:
|
||||
"""
|
||||
|
@ -41,7 +41,7 @@ from fastapi.responses import (
|
||||
from fastapi.security import OAuth2PasswordRequestForm
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from gradio_client import utils as client_utils
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from gradio_client.utils import ServerMessage
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
from multipart.multipart import parse_options_header
|
||||
@ -887,9 +887,6 @@ def get_types(cls_set: List[Type]):
|
||||
return docset, types
|
||||
|
||||
|
||||
set_documentation_group("routes")
|
||||
|
||||
|
||||
@document()
|
||||
def mount_gradio_app(
|
||||
app: fastapi.FastAPI,
|
||||
|
@ -10,7 +10,7 @@ from typing import Iterable
|
||||
|
||||
import huggingface_hub
|
||||
import semantic_version as semver
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
from gradio_client.documentation import document
|
||||
from huggingface_hub import CommitOperationAdd
|
||||
|
||||
from gradio.themes.utils import (
|
||||
@ -22,8 +22,6 @@ from gradio.themes.utils import (
|
||||
)
|
||||
from gradio.themes.utils.readme_content import README_CONTENT
|
||||
|
||||
set_documentation_group("themes")
|
||||
|
||||
|
||||
class ThemeClass:
|
||||
def __init__(self):
|
||||
|
@ -21,7 +21,7 @@ Tip: If you inherit from `BlockContext`, you also need to set the metaclass to b
|
||||
from gradio.blocks import BlockContext
|
||||
from gradio.component_meta import ComponentMeta
|
||||
|
||||
set_documentation_group("layout")
|
||||
|
||||
|
||||
|
||||
@document()
|
||||
|
Loading…
x
Reference in New Issue
Block a user