Package: showcode-forge
Showcode ForgeTools for generating code for ShowCode Forge. ShowCode Forge is a community dedicated to creating challenges onShowCode.InstallThis tool requires Python 3.7+. You can download Python fromhereInstall the latest release of the package from PyPi.pipinstallshowcode_forgeValidateValidating is ensuring that your challenge.jsonfile is correct according to the"Tome of Crafting"(aka the how to guide). It verifies that you have all fields correctly filled out, that your unit tests match your parameters and return types and that your points add up.How to run:showcode_forgevalidate[--verbose]filefileis a path ot the.jsonfile--verboseenables additional logging. Without this, if there are no errors, the tool will not output anythingExample usage:showcode_forgevalidate--verbosechallenge.jsonExtractExtracting is turning a challenge.json(provided by the community) into a set of files, includingquestion.htmland generated source and test files for your selected language.How to run:showcode_forgeextract[--languageLANGUAGE][--frameworkFRAMEWORK]filefileis a path to the.jsonfileLANGUAGEis the selected programming language. Currently supported:pyFRAMEWORKis the selected unit testing framework. Currently supported:unittest,pytest,pytest_scforge(see bellow), default:unittestExample usage:showcode_forgeextract--languagepy--frameworkunittestchallenge.jsonCompileCompiling is turning a source, test and question files into a.jsonfile.How to run:showcode_forgecompile[--outputOUTPUT][--languageLANGUAGE][--frameworkFRAMEWORK]source_filetest_filequestion_filesource_fileis a path to the solution file where the correct answer is definedtest_fileis a path to the file that defines unit testsquestion_fileis a path to the file that defines the question rubric text (usually.html)OUTPUTis a path to where the output will be generated (default:challenge.json)LANGUAGEis the programming languagesource_fileandtest_fileare written in. Currently supported:pyFRAMEWORKis the unit testing framework used to define the test cases. Currently supported:pytest_scforge(see bellow)Example usage:showcode_forge compile --language py --framework pytest_scforge --output my_awesome_challenge.json solution.py tests.py question.htmlUsing Pytest with ShowCode ForgeThe current only supported compiler is a modified version ofpytest. Here is how you would normally write a challenge usingpytest:importpytestfromsolutionimportSolution@pytest.mark.parametrize("count,expected_result",[(3,"1, 2, Fizz"),(7,"1, 2, Fizz, 4, Buzz, Fizz, 7"),(0,"")])deftest_fizzbuzz(count,expected_result):s=Solution()asserts.fizzbuzz(count)==expected_resultYou would run this, by runningpytestin the command line.WithShowCode Forgehere is what the same test looks like:fromshowcode_forgeimportchallenge,TestCasefromsolutionimportSolution@challenge("count,expected_result",[TestCase([3],"1, 2, Fizz","Simple public case",is_public=True),TestCase([7],"1, 2, Fizz, 4, Buzz, Fizz, 7","More complex private case",points=2),TestCase([0],"","Empty case",points=3)])deftest_fizzbuzz(count,expected_result):s=Solution()asserts.fizzbuzz(count)==expected_resultThis runs exactly the same if you runpytestin the command line.@challengegeneratespytesttest cases behind the scenes.It uses the parameter declaration and the various test cases to infer parameter names and types. It automatically calculates the point total as well. Ifpointsis not specified, it defaults to 1. Ifis_publicis not specified it defaults toFalse.It does not support every field currently. You will have to manually edit the.jsonto set thetitle,classNameandmethodName.difficultyis infered from total points, but can be updated.ScaffoldScaffolding sets up the files needed to develop a challenge with the some starting boilerplate code in place.How to run:showcode_forgescaffold[-h][--argumentARGUMENT[ARGUMENT...]][--resultRESULT][--output_dirOUTPUT_DIR][--languageLANGUAGE][--frameworkFRAMEWORK][--question_file_type{html,md}]class_namemethod_nameclass_nameis the name of the tested classmethod_nameis the name of the tested method in the tested classARGUMENTis a list of argument names that the tested method takesRESULTis the name of the result produced by the tested methodOUTPUT_DIRis the directory where the output is generated. If not specified, it will be generated in the current directoryLANGUAGEis the programming language the files will be generated in. Currently supported:pyFRAMEWORKis the unit testing framework used to define the test cases. Currently supported:pytest_scforge(see above)QUESTION_FILE_TYPEis the type of markup used for the question file. Currently supported:html,md(Markdown)Example usage:python-mshowcode_forgescaffold"ClassName""solve_challenge"--argument"arg_1""arg_2""arg_3"--languagepy--frameworkpytest_scforgeContributeContributions, bug fixes and support for more languages are welcome!How to contributeRunning locallyRun this package locally to test it, in the root of the project:python -m showcode_forge [arguments]