The Docker image to automatically create a representation for GDScript solutions submitted to Exercism.
The representer is written in Python.
It relies on gdtoolkit 4.5.0 and lark 1.3.1.
It represents the solution using Lark's pretty() output.
- Comments: The generated AST does not include comments so comments are removed.
- Whitespace: The generated AST does not include input whitespace so whitespace is normalized.
- Docstrings: Module docstrings are dropped from the output.
- String expressions: Function docstrings are treated as any "string expression". String expressions (expressions that contain only a string) are dropped.
- Variable names: Function variables are replaced with placeholders. This does not cover module variables or class variables.
- Function names: User defined functions have their names replaced with placeholders.
To create a representation for a single solution, do the following:
- Open a terminal in the project's root
- Run
./bin/run.sh <exercise-slug> <solution-dir> <output-dir>
Once the representer has finished, its results will be written to <output-dir>/representation.txt and <output-dir>/mapping.json.
This script is provided for testing purposes, as it mimics how representers run in Exercism's production environment.
To create a representation for a single solution using the Docker image, do the following:
- Open a terminal in the project's root
- Run
./bin/run-in-docker.sh <exercise-slug> <solution-dir> <output-dir>
Once the representer has finished, its results will be written to <output-dir>/representation.txt and <output-dir>/mapping.json.
To run the tests to verify the behavior of the representer, do the following:
- Open a terminal in the project's root
- Run
./bin/run-tests.sh
These are golden tests that compare the representation.txt and mapping.json generated by running the current state of the code against the "known good" tests/<test-name>/expected_representation.txt and tests/<test-name>/expected_mapping.json. All files created during the test run itself are discarded.
When you've made modifications to the code that will result in a new "golden" state, you'll need to generate and commit a new tests/<test-name>/expected_representation.txt and tests/<test-name>/expected_mapping.json file.
This script is provided for testing purposes, as it mimics how representers run in Exercism's production environment.
To run the tests to verify the behavior of the representer using the Docker image, do the following:
- Open a terminal in the project's root
- Run
./bin/run-tests-in-docker.sh
These are golden tests that compare the representation.txt and mapping.json generated by running the current state of the code against the "known good" tests/<test-name>/expected_representation.txt and tests/<test-name>/expected_mapping.json. All files created during the test run itself are discarded.
When you've made modifications to the code that will result in a new "golden" state, you'll need to generate and commit a new tests/<test-name>/expected_representation.txt and tests/<test-name>/expected_mapping.json file.
There are two scripts you can use to benchmark the representer:
./bin/benchmark.sh: benchmark the representer code./bin/benchmark-in-docker.sh: benchmark the Docker image
These scripts can give a rough estimation of the representer's performance. Bear in mind though that the performance on Exercism's production servers is often lower.