Skip to content

Commit

Permalink
Merge pull request #27 from QuantEcon/add-clean
Browse files Browse the repository at this point in the history
FEAT: add make clean option, increase verbosity when issuing commands
  • Loading branch information
mmcky committed Aug 2, 2019
2 parents 01d7ec3 + 3dec183 commit a05bfa6
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions jupinx/cmd/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ def get_parser() -> argparse.ArgumentParser:
)
parser.add_argument('directory', nargs='?', type=str, default='./', action='store',
help="provide path to a project directory (optional)")
parser.add_argument('-c', '--coverage', action='store_true', dest='coverage',
help="compile coverage report for project (result: _build/coverage/reports/{filename}.json")
parser.add_argument('-c', '--clean', action='store_true', dest='clean',
help="Clean build so sphinx recompiles all source documents")
parser.add_argument('-n', '--notebooks', action='store_true', dest='jupyter',
help="compile a collection of Jupyter notebooks (result: _build/jupyter)")
parser.add_argument('-t', '--coverage-tests', action='store_true', dest='coverage',
help="compile execution test report for project (result: _build/coverage/reports/{filename}.json)")
parser.add_argument('-w', '--website', action='store_true', dest='website',
help="compile a website through Jupyter notebooks (result: _build/website/")
parser.add_argument('--version', action='version', dest='show_version',
Expand Down Expand Up @@ -87,14 +89,22 @@ def handle_make_parallel(cmd, arg_dict):
exit()
if sys.version_info.major == 2:
if 'parallel' in arg_dict:
subprocess.call(['make', cmd, 'parallel=' + str(arg_dict['parallel'])], cwd=arg_dict['directory'])
cmd = ['make', cmd, 'parallel=' + str(arg_dict['parallel'])]
print("Running: " + " ".join(cmd))
subprocess.call(cmd, cwd=arg_dict['directory'])
else:
subprocess.call(['make', cmd], cwd=arg_dict['directory'])
cmd = ['make', cmd]
print("Running: " + " ".join(cmd))
subprocess.call(cmd, cwd=arg_dict['directory'])
else:
if 'parallel' in arg_dict:
subprocess.run(['make', cmd, 'parallel=' + str(arg_dict['parallel'])], cwd=arg_dict['directory'])
cmd = ['make', cmd, 'parallel=' + str(arg_dict['parallel'])]
print("Running: " + " ".join(cmd))
subprocess.run(cmd, cwd=arg_dict['directory'])
else:
subprocess.run(['make', cmd], cwd=arg_dict['directory'])
cmd = ['make', cmd]
print("Running: " + " ".join(cmd))
subprocess.run(cmd, cwd=arg_dict['directory'])

def handle_make_preview(arg_dict):
"""
Expand Down Expand Up @@ -143,6 +153,16 @@ def make_file_actions(arg_dict: Dict):
Support sphinx-build directly using Invoke or some other library in the future
will allow for advanced configuration options to be available through this tool.
"""
if 'clean' in arg_dict:
if sys.version_info.major == 2:
cmd = ['make', 'clean']
print("Running: " + " ".join(cmd))
subprocess.call(cmd, cwd=arg_dict['directory'])
else:
cmd = ['make', 'clean']
print("Running: " + " ".join(cmd))
subprocess.run(cmd, cwd=arg_dict['directory'])

if 'coverage' in arg_dict:
handle_make_parallel('coverage', arg_dict)

Expand All @@ -155,6 +175,7 @@ def make_file_actions(arg_dict: Dict):
if 'view' in arg_dict:
handle_make_preview(arg_dict)


def deleteDefaultValues(d):
valid = False

Expand Down

0 comments on commit a05bfa6

Please sign in to comment.