Skip to content

Commit

Permalink
feat: Allow passing extensions config as JSON on the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Nov 28, 2021
1 parent 7f0064c commit 9a7fa8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/griffe/agents/extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""This module is the public interface to import elements from the base."""

from griffe.agents.extensions.base import Extension, Extensions, When, load_extensions
from griffe.agents.extensions.base import Extension, Extensions, When, load_extension, load_extensions

__all__ = ["Extensions", "Extension", "When", "load_extensions"] # noqa: WPS410
__all__ = ["Extensions", "Extension", "When", "load_extension", "load_extensions"] # noqa: WPS410
10 changes: 9 additions & 1 deletion src/griffe/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from typing import Any, Sequence

from griffe.agents.extensions import Extensions
from griffe.agents.extensions.base import load_extensions
from griffe.docstrings.parsers import Parser
from griffe.encoders import Encoder
from griffe.loader import AsyncGriffeLoader, GriffeLoader
Expand Down Expand Up @@ -108,6 +109,13 @@ def get_parser() -> argparse.ArgumentParser:
action="store_true",
help="Whether to append sys.path to search paths specified with -s.",
)
parser.add_argument(
"-e",
"--extensions",
default={},
type=json.loads,
help="A list of extensions to use.",
)
parser.add_argument(
"-f",
"--full",
Expand Down Expand Up @@ -180,7 +188,7 @@ def main(args: list[str] | None = None) -> int: # noqa: WPS231
if opts.append_sys_path:
search.extend(sys.path)

extensions = Extensions()
extensions = load_extensions(opts.extensions)

if opts.async_loader:
loop = asyncio.get_event_loop()
Expand Down

0 comments on commit 9a7fa8b

Please # to comment.