Skip to content

Commit

Permalink
Merge branch 'main' into Add-infinity-target-shape-#179
Browse files Browse the repository at this point in the history
  • Loading branch information
MauriceDeVr authored Jul 13, 2024
2 parents dbb735c + 2f32cd9 commit 0853d0a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 35 deletions.
7 changes: 4 additions & 3 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
CLI Reference
=============

.. argparse::
:ref: data_morph.cli._generate_parser_for_docs
.. sphinx_argparse_cli::
:module: data_morph.cli
:func: generate_parser
:prog: data-morph
:noepilog:
:group_title_prefix:

----

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx_copybutton',
'sphinxarg.ext',
'sphinx_argparse_cli',
'matplotlib.sphinxext.plot_directive',
]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ optional-dependencies.dev = [
optional-dependencies.docs = [
"pydata-sphinx-theme>=0.15.3",
"sphinx>=7.2.6",
"sphinx-argparse>=0.4.0",
"sphinx-argparse-cli>=1.16.0",
"sphinx-copybutton>=0.5.1",
]
urls."Bug Tracker" = "https://github.com/stefmolin/data-morph/issues"
Expand Down
24 changes: 0 additions & 24 deletions src/data_morph/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import argparse
import sys
import textwrap
from typing import Sequence, Union

from . import __version__
Expand All @@ -18,8 +17,6 @@
'freeze': 0,
}

USAGE_WIDTH_FOR_DOCS = 80


def generate_parser() -> argparse.ArgumentParser:
"""
Expand Down Expand Up @@ -209,27 +206,6 @@ def generate_parser() -> argparse.ArgumentParser:
return parser


def _generate_parser_for_docs() -> argparse.ArgumentParser:
"""
Generate an argument parser for the documentation only.
Returns
-------
argparse.argparse.ArgumentParser
Modified argument parser class for the documentation.
"""
parser = generate_parser()
usage_text = parser.format_usage()
parser.format_usage = lambda: textwrap.fill(
usage_text.replace(' ', ' '),
width=USAGE_WIDTH_FOR_DOCS,
subsequent_indent='\t',
break_on_hyphens=False,
break_long_words=False,
)
return parser


def main(argv: Union[Sequence[str], None] = None) -> None:
"""
Run Data Morph as a script.
Expand Down
6 changes: 0 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ def test_cli_version(capsys):
assert f'data-morph {__version__}' == capsys.readouterr().out.strip()


def test_cli_usage_wrap_for_docs():
"""Confirm that the usage wrapping for the docs is working."""
usage_text = cli._generate_parser_for_docs().format_usage()
assert all(len(line) <= cli.USAGE_WIDTH_FOR_DOCS for line in usage_text.split('\n'))


def test_cli_bad_shape():
"""Test that invalid target shapes raise a ValueError."""
with pytest.raises(ValueError, match='No valid target shapes were provided.'):
Expand Down

0 comments on commit 0853d0a

Please sign in to comment.