| 1 |
import typing as t |
| 2 |
from pydoc import locate |
| 3 |
|
| 4 |
from ..utils import read_sphinx_params |
| 5 |
from .add_content_directive import AddContentDirective |
| 6 |
|
| 7 |
|
| 8 |
class CopyParams(AddContentDirective): |
| 9 |
has_content = True |
| 10 |
required_arguments = 1 |
| 11 |
optional_arguments = 0 |
| 12 |
|
| 13 |
def gen_rst(self) -> t.Iterator[str]: |
| 14 |
source_object_name: str = self.arguments[0] |
| 15 |
if not source_object_name.startswith("globus_sdk"): |
| 16 |
source_object_name = f"globus_sdk.{source_object_name}" |
| 17 |
|
| 18 |
source_object = locate(source_object_name) |
| 19 |
|
| 20 |
content: t.Iterable[str] |
| 21 |
if self.content: |
| 22 |
content = iter(self.content) |
| 23 |
else: |
| 24 |
content = () |
| 25 |
|
| 26 |
for line in content: |
| 27 |
if line.strip() == "<YIELD>": |
| 28 |
break |
| 29 |
yield line |
| 30 |
|
| 31 |
yield from read_sphinx_params(source_object.__doc__) |
| 32 |
|
| 33 |
for line in content: |
| 34 |
yield line |