<commit_before># -*- coding: utf-8 -*-
import os
import sys
from invoke import task, run

docs_dir = 'docs'
build_dir = os.path.join(docs_dir, '_build')

@task
def test():
    """Run the tests."""
    flake()
    run('python setup.py test', echo=True, pty=True)

@task
def flake():
    """Run flake8 on codebase."""
    run('flake8 .', echo=True)

@task
def watch():
    """Run tests when a file changes. Requires pytest-xdist."""
    run('py.test -f tests/', pty=True)

@task
def clean():
    run("rm -rf build")
    run("rm -rf dist")
    run("rm -rf marshmallow.egg-info")
    clean_docs()
    print("Cleaned up.")

@task
def clean_docs():
    run("rm -rf %s" % build_dir)

@task
def browse_docs():
    platform = str(sys.platform).lower()
    command = {
        'darwin': 'open ',
        'linux': 'idle ',
        'win32': '',
    }
    cmd = command.get(platform)
    if cmd:
        run("{0}{1}".format(cmd, os.path.join(build_dir, 'index.html')))
    else:
        print('Unsure how to open the built file on this operating system.')
        sys.exit(1)

@task
def docs(clean=False, browse=False, watch=False):
    """Build the docs."""
    if clean:
        clean_docs()
    run("sphinx-build %s %s" % (docs_dir, build_dir), pty=True)
    if browse:
        browse_docs()
    if watch:
        watch_docs()

@task
def watch_docs():
    """Run build the docs when a file changes."""
    try:
        import sphinx_autobuild  # noqa<commit_msg>Use webbrowser module to open docs<commit_after># -*- coding: utf-8 -*-
import os
import sys
import webbrowser

from invoke import task, run

docs_dir = 'docs'
build_dir = os.path.join(docs_dir, '_build')

@task
def test():
    """Run the tests."""
    flake()
    run('python setup.py test', echo=True, pty=True)

@task
def flake():
    """Run flake8 on codebase."""
    run('flake8 .', echo=True)

@task
def watch():
    """Run tests when a file changes. Requires pytest-xdist."""
    run('py.test -f tests/', pty=True)

@task
def clean():
    run("rm -rf build")
    run("rm -rf dist")
    run("rm -rf marshmallow.egg-info")
    clean_docs()
    print("Cleaned up.")

@task
def clean_docs():
    run("rm -rf %s" % build_dir)

@task
def browse_docs():
    path = os.path.join(build_dir, 'index.html')
    webbrowser.open_new_tab(path)

@task
def docs(clean=False, browse=False, watch=False):
    """Build the docs."""
    if clean:
        clean_docs()
    run("sphinx-build %s %s" % (docs_dir, build_dir), pty=True)
    if browse:
        browse_docs()
    if watch:
        watch_docs()

@task
def watch_docs():
    """Run build the docs when a file changes."""
    try:
        import sphinx_autobuild  # noqa
{'fraction_non_alphanumeric': 0.16279069767441862, 'fraction_numerical': 0.004126031507876969, 'mean_word_length': 2.8820960698689957, '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': '6729011', 'n_tokens_mistral': 966, 'n_tokens_neox': 946, 'n_words': 270}