|
11 | 11 | from autodoc2 import __name__ as package_name
|
12 | 12 | from autodoc2 import __version__
|
13 | 13 | from autodoc2.analysis import analyse_module
|
14 |
| -from autodoc2.config import Config |
| 14 | +from autodoc2.config import Config, _load_renderer |
15 | 15 | from autodoc2.db import InMemoryDb, UniqueError
|
16 | 16 | from autodoc2.resolve_all import AllResolver
|
17 | 17 | from autodoc2.utils import WarningSubtypes, yield_modules
|
@@ -197,9 +197,18 @@ def write(
|
197 | 197 | ),
|
198 | 198 | # TODO read from config file, to populate config object
|
199 | 199 | output: Path = typer.Option("_autodoc", help="Folder to write to"),
|
| 200 | + renderer: str = typer.Option( |
| 201 | + "rst", |
| 202 | + "-r", |
| 203 | + "--renderer", |
| 204 | + help="Renderer to use, rst or md", |
| 205 | + callback=lambda x: _load_renderer("render_plugin", x), |
| 206 | + ), |
200 | 207 | clean: bool = typer.Option(False, "-c", "--clean", help="Remove old files"),
|
201 | 208 | ) -> None:
|
202 | 209 | """Create sphinx files for a python module or package."""
|
| 210 | + from autodoc2.render.base import RendererBase |
| 211 | + |
203 | 212 | # gather the module
|
204 | 213 | modules: t.Iterable[t.Tuple[Path, str]]
|
205 | 214 | if path.is_dir():
|
@@ -254,7 +263,7 @@ def write(
|
254 | 263 | def _warn(msg: str, type_: WarningSubtypes) -> None:
|
255 | 264 | progress.console.print(f"[yellow]Warning[/yellow] {msg} [{type_.value}]")
|
256 | 265 |
|
257 |
| - config = Config() |
| 266 | + config = Config(render_plugin=t.cast(RendererBase, renderer)) |
258 | 267 | for mod_name in to_write:
|
259 | 268 | progress.update(task, advance=1, description=mod_name)
|
260 | 269 | content = "\n".join(
|
|
0 commit comments