From 5ef1f98441f688cd4be9f23322725c724c22c3d5 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Thu, 9 Feb 2023 16:09:27 +0100 Subject: [PATCH] Update readme and usage hints --- libmei/README.md | 39 ++++++++++++++++++++++++++++-------- libmei/tools/parseschema2.py | 3 +-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/libmei/README.md b/libmei/README.md index ac089b6ed0a..6dce79edade 100644 --- a/libmei/README.md +++ b/libmei/README.md @@ -5,11 +5,11 @@ LibMEI is a C++ library for reading and writing [MEI](http://music-encoding.org) It was originally developed by the [Distributed Digital Music Archives and Libraries Lab](http://ddmal.music.mcgill.ca/) at the Schulich School of Music at McGill University, Montréal, Canada -This is a modified version that is used for generating C++ code for Verovio. The main differences with LibMEI are: +This is a modified version that is used for generating C++ code for Verovio. -1. it generates only attribute classes (Mixin in LibMEI) by default, -2. each attribute has a C++ type deduced from the MEI schema or given in a separated configuration file, -3. it uses the MEI page-based customization not included in the MEI 2013 v2.1.0 (see [MEI](http://www.music-encoding.org)). +1. it generates only attribute classes by default, +2. each attribute has a C++ type deduced from the MEI schema or given in a separated datatypes configuration file, +3. it uses the MEI page-based customization by default. License @@ -21,9 +21,32 @@ Compilation & Usage To generate the code, do: - python3 tools/parseschema2.py mei/develop/mei-verovio_compiled.odd + python3 parseschema2.py ../mei/develop/mei-verovio_compiled.odd + +Where the positional argument points to an ODD file for which you wish to +generate code. Other options are: -* `-o`: specific output directory. It will contain `dist` with the generated files and `addons` with the other files -* `-e`: will generate element classes in addition to the attribute classes. This option disables the generation of the Verovio specific code `attmodule.h/cpp` -* `-ns`: specify the CPP namespaces to be used. This option should only be used with `-o` and `-e`. +* `-c`: A path to a YML config file. + +Config file +----------- + +The config file can contain several options: + +```yaml +debug: true|false # determines the log level while running +output_dir: "../dist" # path to where the output should go +addons_dir: "../addons" # path to an optional addons directory +elements: true|false # whether or not code for element handling should be generated +namespace: "vrv" # the namespace to use in generated CPP code +datatypes: "./datatypes.yml" # path to a datatypes mapping file +basic_odd: "../mei/develop/mei-basic_compiled.odd" # path to an MEI basic ODD file +``` + +For the `basic_odd` option, if provided the generator will generate a map of notes and allowed +attributes within the MEI basic ODD file and write it to a file called `meibasic.h`. + +If the `addons_dir` is provided, the files in that directory will be copied to the output directory. +The files will also have the namespace in the addons replaced with the value provided in the +`namespace` option. \ No newline at end of file diff --git a/libmei/tools/parseschema2.py b/libmei/tools/parseschema2.py index 04ec8c63c5d..06761de561a 100644 --- a/libmei/tools/parseschema2.py +++ b/libmei/tools/parseschema2.py @@ -53,8 +53,7 @@ def main(configure: dict) -> bool: if __name__ == "__main__": - # Custom usage message to show user [compiled] should go before all other flags - p = ArgumentParser(usage='%(prog)s [compiled | -sl] [-e] [-h] [-df DEFINE] [-o OUTDIR] [-d]') + p = ArgumentParser(usage='%(prog)s [-c config path] [compiled odd path]') p.add_argument("compiled", help="A compiled ODD file", type=Path) p.add_argument("-c", "--config", help="Path to a config file", type=Path)