Skip to content

Commit

Permalink
Run directivegetter on sphinx-lint init directives sourcedir builddir
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Nov 6, 2022
1 parent d5473d7 commit 2f7207a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions sphinxlint/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def parse_args(argv=None):
"""Parse command line argument."""
if argv is None:
argv = sys.argv
if argv[1:2] == ["init", "directives"]:
from directivegetter import collect_directives

raise SystemExit(collect_directives(argv[2:]))

parser = argparse.ArgumentParser(description=__doc__)

enabled_checkers_names = {
Expand Down
4 changes: 2 additions & 2 deletions sphinxlint/directivegetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def setup(app: Sphinx) -> dict[str, bool]:
return {"parallel_read_safe": True, "parallel_write_safe": True}


def collect_directives():
def collect_directives(args=None):
from sphinx import application
from sphinx.application import Sphinx

try:
source_dir, build_dir, *opts = sys.argv[1:]
source_dir, build_dir, *opts = args or sys.argv[1:]
except ValueError:
raise RuntimeError("Two arguments (source dir and build dir) are required.")

Expand Down

0 comments on commit 2f7207a

Please sign in to comment.