Skip to content

Provide infrastructure and convert examples for configuring Python example scripts using embedded Ruby (#554)

Wuttke, Joachim requested to merge auto2 into main

This resolves #554 (closed): remove test-related overhead from published examples.

We need to configure scripts so that they can be run in different modes: Interactively by our users; in batch mode with reduced grid size as called by our automatized tests; in batch mode with full grid size to generate figures for the online docs.

Up to now, this configuration is done with command line arguments; most importantly sim_n to set the bin size. The mechanism behind the scenes is complicated, unflexible, and requires the obscure statement bp.parse_args() in each user script.

Here a new mechanism is proposed. This MR provides the infrastructure and a first converted example script. In the new mechanism, example sources contain macro code that is expanded in the configuration step. In consequence, we now have different directories under Examples/, namely src/ for the sources, public/ for the publishable versions, and testable/ for the mini-grid versions.

The macro expansion is done by the embedded Ruby interpreter erb. Macros are ruby code, enclosed in <% and %>.

Only developers need erb. Configured examples are part of the source distribution. This is similar to Swig, which also is only run by developers, with results in directory auto/ also part of the source distribution.

Edited by Wuttke, Joachim

Merge request reports