Skip to content

Commit

Permalink
Renaming -C to -N and passing it to sphinx-build.
Browse files Browse the repository at this point in the history
When user requests to disable colors in sphinx-versioning, they'll
expect sphinx-build to also not show colors (no colors anywhere at all).
Fixing this.

Renaming --no-colors short option -C to -N to be consistent with
sphinx-build.

Fixes #16
  • Loading branch information
Robpol86 committed Aug 14, 2016
1 parent 268d7ed commit 5136e3e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ Changed
* ``--sort`` no longer takes a comma separated string. Now specify multiple times (like ``--grm-exclude``).
* Renamed ``--sort`` value "chrono" to "time".
* Reordered positional command line arguments. Moved ``REL_SOURCE`` before the destination arguments.
* Renamed command line option ``-C`` to ``-N`` for consistency with sphinx-build.

Fixed
* Exposing sphinx-build verbosity to SCVersioning. Specify one ``-v`` to make SCVersioning verbose and two or more
to make sphinx-build verbose.
* Using ``--no-colors`` also turns off colors from sphinx-build.
* https://github.com/Robpol86/sphinxcontrib-versioning/issues/16

1.1.0 - 2016-08-07
------------------
Expand Down
10 changes: 5 additions & 5 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ be specified before the build/push command or else you'll get an error.

Change the current working directory of the program to this path.

.. option:: -C, --no-colors

By default INFO, WARNING, and ERROR log/print statements use console colors. Use this argument to disable colors and
log/print plain text.

.. option:: -g <directory>, --git-root <directory>

Path to directory in the local repo. Default is the current working directory.

.. option:: -N, --no-colors

By default INFO, WARNING, and ERROR log/print statements use console colors. Use this argument to disable colors and
log/print plain text.

.. option:: -v, --verbose

Enable verbose/debug logging with timestamps and git command outputs. Implies :option:`--no-colors`. If specified
Expand Down
4 changes: 2 additions & 2 deletions sphinxcontrib/versioning/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def get_params(self, ctx):

@click.group(cls=ClickGroup)
@click.option('-c', '--chdir', help='Make this the current working directory before running.', type=IS_EXISTS_DIR)
@click.option('-C', '--no-colors', help='Disable colors in the terminal output.', is_flag=True)
@click.option('-g', '--git-root', help='Path to directory in the local repo. Default is CWD.', type=IS_EXISTS_DIR)
@click.option('-N', '--no-colors', help='Disable colors in the terminal output.', is_flag=True)
@click.option('-v', '--verbose', help='Debug logging. Specify more than once for more logging.', count=True)
@click.version_option(version=__version__)
@click.make_pass_decorator(Config, ensure=True)
Expand All @@ -120,7 +120,7 @@ def cli(config, **options):
Supports only building locally with the "build" sub command or build and push to origin with the "push" sub command.
For more information for either run them with their own --help.
The options below are global and must be specified before the sub command name (e.g. -C build ...).
The options below are global and must be specified before the sub command name (e.g. -N build ...).
\f
:param sphinxcontrib.versioning.lib.Config config: Runtime configuration.
Expand Down
2 changes: 2 additions & 0 deletions sphinxcontrib/versioning/sphinx_.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def _build(argv, versions, current_name):
config = Config.from_context()
if config.verbose > 1:
argv += ('-v',) * (config.verbose - 1)
if config.no_colors:
argv += ('-N',)

# Build.
result = build_main(argv)
Expand Down
2 changes: 1 addition & 1 deletion tests/test__main__/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_global_options(tmpdir, local_empty, run, push):
empty = tmpdir.ensure_dir('empty')
repo = tmpdir.ensure_dir('repo')
run(repo, ['git', 'init'])
args = ['-c', str(empty), '-C', '-g', str(repo), '-v', '-v'] + args
args = ['-c', str(empty), '-N', '-g', str(repo), '-v', '-v'] + args
result = CliRunner().invoke(cli, args)
config = result.exception.args[0]
assert config.chdir == str(empty)
Expand Down
12 changes: 6 additions & 6 deletions tests/test__main__/test_main_build_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,23 +404,23 @@ def test_error_bad_path(tmpdir, run):
:param run: conftest fixture.
"""
with pytest.raises(CalledProcessError) as exc:
run(tmpdir, ['sphinx-versioning', '-C', '-c', 'unknown', 'build', '.', str(tmpdir)])
run(tmpdir, ['sphinx-versioning', '-N', '-c', 'unknown', 'build', '.', str(tmpdir)])
assert 'Directory "unknown" does not exist.\n' in exc.value.output

tmpdir.ensure('is_file')
with pytest.raises(CalledProcessError) as exc:
run(tmpdir, ['sphinx-versioning', '-C', '-c', 'is_file', 'build', '.', str(tmpdir)])
run(tmpdir, ['sphinx-versioning', '-N', '-c', 'is_file', 'build', '.', str(tmpdir)])
assert 'Directory "is_file" is a file.\n' in exc.value.output

with pytest.raises(CalledProcessError) as exc:
run(tmpdir, ['sphinx-versioning', '-C', 'build', '.', str(tmpdir)])
run(tmpdir, ['sphinx-versioning', '-N', 'build', '.', str(tmpdir)])
assert 'Failed to find local git repository root in {}.'.format(repr(str(tmpdir))) in exc.value.output

repo = tmpdir.ensure_dir('repo')
run(repo, ['git', 'init'])
empty = tmpdir.ensure_dir('empty')
with pytest.raises(CalledProcessError) as exc:
run(repo, ['sphinx-versioning', '-C', '-g', str(empty), 'build', '.', str(tmpdir)])
run(repo, ['sphinx-versioning', '-N', '-g', str(empty), 'build', '.', str(tmpdir)])
assert 'Failed to find local git repository root in {}.'.format(repr(str(empty))) in exc.value.output


Expand All @@ -432,7 +432,7 @@ def test_error_no_docs_found(tmpdir, local, run):
:param run: conftest fixture.
"""
with pytest.raises(CalledProcessError) as exc:
run(local, ['sphinx-versioning', '-C', '-v', 'build', '.', str(tmpdir)])
run(local, ['sphinx-versioning', '-N', '-v', 'build', '.', str(tmpdir)])
assert 'No docs found in any remote branch/tag. Nothing to do.\n' in exc.value.output


Expand All @@ -444,5 +444,5 @@ def test_error_bad_root_ref(tmpdir, local_docs, run):
:param run: conftest fixture.
"""
with pytest.raises(CalledProcessError) as exc:
run(local_docs, ['sphinx-versioning', '-C', '-v', 'build', '.', str(tmpdir), '-r', 'unknown'])
run(local_docs, ['sphinx-versioning', '-N', '-v', 'build', '.', str(tmpdir), '-r', 'unknown'])
assert 'Root ref unknown not found in: master\n' in exc.value.output

0 comments on commit 5136e3e

Please sign in to comment.