|
| 1 | +# get_object {#sec-get_object} |
| 2 | + |
| 3 | +`get_object(module: str, object_name: str, parser: str = 'numpy')` |
| 4 | + |
| 5 | +Fetch a griffe object. |
| 6 | + |
| 7 | +## Parameters |
| 8 | + |
| 9 | +| Name | Type | Description | Default | |
| 10 | +|---------------|--------|----------------------------|-----------| |
| 11 | +| `module` | str | A module name. | required | |
| 12 | +| `object_name` | str | A function name. | required | |
| 13 | +| `parser` | str | A docstring parser to use. | `'numpy'` | |
| 14 | + |
| 15 | +See Also |
| 16 | +-------- |
| 17 | +get_function: a deprecated function. |
| 18 | + |
| 19 | +## Examples |
| 20 | + |
| 21 | +```python |
| 22 | +>>> get_function("quartodoc", "get_function") |
| 23 | +<Function('get_function', ... |
| 24 | +``` |
| 25 | + |
| 26 | +# create_inventory {#sec-create_inventory} |
| 27 | + |
| 28 | +`create_inventory(project: str, version: str, items: list[dc.Object | dc.Alias], uri: str | Callable[dc.Object, str] = <function <lambda> at 0x105878700>, dispname: str | Callable[dc.Object, str] = '-')` |
| 29 | + |
| 30 | +Return a sphinx inventory file. |
| 31 | + |
| 32 | +## Parameters |
| 33 | + |
| 34 | +| Name | Type | Description | Default | |
| 35 | +|------------|--------------------------------|----------------------------------------------------------------|--------------------------------------| |
| 36 | +| `project` | str | Name of the project (often the package name). | required | |
| 37 | +| `version` | str | Version of the project (often the package version). | required | |
| 38 | +| `items` | list[dc.Object | dc.Alias] | A docstring parser to use. | required | |
| 39 | +| `uri` | str | Callable[dc.Object, str] | Link relative to the docs where the items documentation lives. | `<function <lambda> at 0x105878700>` | |
| 40 | +| `dispname` | str | Callable[dc.Object, str] | Name to be shown when a link to the item is made. | `'-'` | |
| 41 | +
|
| 42 | +## Examples |
| 43 | + |
| 44 | +```python |
| 45 | +>>> f_obj = get_object("quartodoc", "create_inventory") |
| 46 | +>>> inv = create_inventory("example", "0.0", [f_obj]) |
| 47 | +>>> inv |
| 48 | +Inventory(project='example', version='0.0', source_type=<SourceTypes.Manual: 'manual'>) |
| 49 | +``` |
| 50 | + |
| 51 | +To preview the inventory, we can convert it to a dictionary: |
| 52 | + |
| 53 | +```python |
| 54 | +>>> _to_clean_dict(inv) |
| 55 | +{'project': 'example', |
| 56 | + 'version': '0.0', |
| 57 | + 'count': 1, |
| 58 | + 'items': [{'name': 'quartodoc.create_inventory', |
| 59 | + 'domain': 'py', |
| 60 | + 'role': 'function', |
| 61 | + 'priority': '1', |
| 62 | + 'uri': 'quartodoc.create_inventory.html', |
| 63 | + 'dispname': '-'}]} |
| 64 | +``` |
| 65 | + |
| 66 | +# convert_inventory {#sec-convert_inventory} |
| 67 | + |
| 68 | +`convert_inventory(in_name: Union[str, soi.Inventory], out_name=None)` |
| 69 | + |
| 70 | +Convert a sphinx inventory file to json. |
| 71 | + |
| 72 | +## Parameters |
| 73 | + |
| 74 | +| Name | Type | Description | Default | |
| 75 | +|------------|---------------------------|-------------------------|-----------| |
| 76 | +| `in_name` | Union[str, soi.Inventory] | Name of inventory file. | required | |
| 77 | +| `out_name` | | Output file name. | `None` | |
| 78 | + |
| 79 | +# MdRenderer {#sec-MdRenderer} |
| 80 | + |
| 81 | +`MdRenderer(self, header_level: int = 2, show_signature: bool = True, hook_pre=None)` |
| 82 | + |
| 83 | +Render docstrings to markdown. |
| 84 | + |
| 85 | +## Parameters |
| 86 | + |
| 87 | +| Name | Type | Description | Default | |
| 88 | +|------------------|--------|--------------------------------------------------|-----------| |
| 89 | +| `header_level` | int | The level of the header (e.g. 1 is the biggest). | `2` | |
| 90 | +| `show_signature` | bool | Whether to show the function signature. | `True` | |
| 91 | + |
| 92 | +## Examples |
| 93 | + |
| 94 | +```python |
| 95 | +>>> from quartodoc import MdRenderer, get_object |
| 96 | +>>> renderer = MdRenderer(header_level=2) |
| 97 | +>>> f = get_object("quartodoc", "get_object") |
| 98 | +>>> print(renderer.to_md(f)[:81]) |
| 99 | +## get_object |
| 100 | +`get_object(module: str, object_name: str, parser: str = 'numpy')` |
| 101 | +``` |
0 commit comments