<commit_before>"""Implements the ``package-docs`` CLI for single-package documentation builds
in the LSST Stack.
"""

__all__ = ('main',)

import logging
import os
import shutil
import sys

import click

from ..sphinxrunner import run_sphinx


# Add -h as a help shortcut option
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])


@click.group(context_settings=CONTEXT_SETTINGS)
@click.option(
    '-d', '--dir', 'root_dir',
    type=click.Path(exists=True, file_okay=False, dir_okay=True,
                    resolve_path=True),
    default='.',
    help='Root Sphinx doc/ directory'
)
@click.option(
    '-v', '--verbose',
    is_flag=True,
    help='Enable verbose output (debug-level logging)'
)
@click.version_option()
@click.pass_context
def main(ctx, root_dir, verbose):
    """package-docs is a CLI for building single-package previews of
    documentation in the LSST Stack.
    """
    # Subcommands should use the click.pass_obj decorator to get this
    # ctx.obj object as the first argument.
    ctx.obj = {'root_dir': root_dir,
               'verbose': verbose}

    # Set up application logging. This ensures that only documenteer's
    # logger is activated. If necessary, we can add other app's loggers too.
    if verbose:
        log_level = logging.DEBUG
    else:
        log_level = logging.INFO
    logger = logging.getLogger('documenteer')
    logger.addHandler(logging.StreamHandler())
    logger.setLevel(log_level)


@main.command()
@click.argument('topic', default=None, required=False, nargs=1)
@click.pass_context<commit_msg>Add discover_package_doc_dir to package-docs CLI<commit_after>"""Implements the ``package-docs`` CLI for single-package documentation builds
in the LSST Stack.
"""

__all__ = ('main',)

import logging
import os
import shutil
import sys

import click

from ..sphinxrunner import run_sphinx
from .rootdiscovery import discover_package_doc_dir


# Add -h as a help shortcut option
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])


@click.group(context_settings=CONTEXT_SETTINGS)
@click.option(
    '-d', '--dir', 'root_dir',
    type=click.Path(exists=True, file_okay=False, dir_okay=True,
                    resolve_path=True),
    default='.',
    help="Root Sphinx doc/ directory. You don't need to set this argument "
         "explicitly as long as the current working directory is either the "
         "root of the package, the doc/ directory, or a subdirectory of doc/."
)
@click.option(
    '-v', '--verbose',
    is_flag=True,
    help='Enable verbose output (debug-level logging)'
)
@click.version_option()
@click.pass_context
def main(ctx, root_dir, verbose):
    """package-docs is a CLI for building single-package previews of
    documentation in the LSST Stack.
    """
    root_dir = discover_package_doc_dir(root_dir)

    # Subcommands should use the click.pass_obj decorator to get this
    # ctx.obj object as the first argument.
    ctx.obj = {'root_dir': root_dir,
               'verbose': verbose}

    # Set up application logging. This ensures that only documenteer's
    # logger is activated. If necessary, we can add other app's loggers too.
    if verbose:
        log_level = logging.DEBUG
    else:
        log_level = logging.INFO
    logger = logging.getLogger('documenteer')
    logger.addHandler(logging.StreamHandler())
    logger.setLevel(log_level)


@main.command()
@click.argument('topic', default=None, required=False, nargs=1)
@click.pass_context
{'fraction_non_alphanumeric': 0.11191231612344966, 'fraction_numerical': 0.0005768676088837611, 'mean_word_length': 3.630173564753004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1347542', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1050, 'n_words': 317}