<commit_before>import os
import os.path
import subprocess
import argparse
import shutil
import markdown # this is a pip package you'll need
from datetime import date

parser = argparse.ArgumentParser(description='Runs the java client doc generation script.')
parser.add_argument('game', action='store', help='the name of the game you want to document. Must exist in ../games/')

args = parser.parse_args()

game_name = args.game[0].upper() + args.game[1:]
lower_game_name = game_name[0].lower() + game_name[1:]

output_path = "./output"
if os.path.isdir(output_path):
    shutil.rmtree(output_path)

with open('../README.md', 'r') as readme_file:
    readme_md = readme_file.read()

readme_md = readme_md.replace("GAME_NAME", game_name).replace("game_name", lower_game_name)

temp_readme_html_path = os.path.join("..", "games", lower_game_name, "package.html")

with open(temp_readme_html_path, "w+") as readme_html:
    readme_html.write("<html><head></head><body>" + markdown.markdown(readme_md) + "</body></html>")

subprocess.call(["javadoc -d {output_path} -use -windowtitle \"{game_name} Java Client Documentation\" -header \"<h1>{game_name} Java Client Documentation</h1>\" -bottom \"&copy; {year} MST ACM SIG-GAME\" -sourcepath .. games.{lower_game_name}".format(
    output_path=output_path,
    game_name=game_name,
    lower_game_name=lower_game_name,
    year=date.today().year,
)], shell=True)

os.remove(temp_readme_html_path)<commit_msg>Update generate_docs.py to use exit codes on errors<commit_after>import os
import os.path
import subprocess
import argparse
import shutil
import markdown # this is a pip package you'll need
from datetime import date
import sys

def run(*args, **kwargs):
    error_code = subprocess.call(*args, **kwargs)
    if error_code != 0: # an error happened
        sys.exit(error_code)

parser = argparse.ArgumentParser(description='Runs the java client doc generation script.')
parser.add_argument('game', action='store', help='the name of the game you want to document. Must exist in ../games/')

args = parser.parse_args()

game_name = args.game[0].upper() + args.game[1:]
lower_game_name = game_name[0].lower() + game_name[1:]

output_path = "./output"
if os.path.isdir(output_path):
    shutil.rmtree(output_path)

with open('../README.md', 'r') as readme_file:
    readme_md = readme_file.read()

readme_md = readme_md.replace("GAME_NAME", game_name).replace("game_name", lower_game_name)

temp_readme_html_path = os.path.join("..", "games", lower_game_name, "package.html")

with open(temp_readme_html_path, "w+") as readme_html:
    readme_html.write("<html><head></head><body>" + markdown.markdown(readme_md) + "</body></html>")

run(["javadoc -d {output_path} -use -windowtitle \"{game_name} Java Client Documentation\" -header \"<h1>{game_name} Java Client Documentation</h1>\" -bottom \"&copy; {year} MST ACM SIG-GAME\" -sourcepath .. games.{lower_game_name}".format(
    output_path=output_path,
    game_name=game_name,
    lower_game_name=lower_game_name,
    year=date.today().year,
)], shell=True)

os.remove(temp_readme_html_path)
{'fraction_non_alphanumeric': 0.1475250727919767, 'fraction_numerical': 0.0042057586541572305, 'mean_word_length': 5.349075975359343, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '7352094', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1055, 'n_words': 243}