From ee16f8545bf8b8eff189a2259e7c3aa806a3a2cf Mon Sep 17 00:00:00 2001 From: nsheff Date: Mon, 6 Nov 2023 21:29:28 -0500 Subject: [PATCH] implement abstract targets. Fix #19 --- docs/commands.md | 12 ++++++++++++ markmeld/cli.py | 12 ++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/commands.md b/docs/commands.md index 395924e..9a06ccd 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -48,3 +48,15 @@ targets: - target3 ``` +### Abstract targets + +Another type of target is an *abstract target*, which is a target that can be imported, but not built. Abstract targets can also be `meta` or `raw` targets, so we don't specify them with `type`, but with `abstract: true`. + +For example, `base_target` below is an abstract target that can be used as a template for other concrete targets. You can use abstract targets to set up re-usable parameter sets or other configurations that you can then inheret in other targets. + +```yaml +targets: + targbase_target: + abstract: true + bibfolder: /path/to/bib/ +``` \ No newline at end of file diff --git a/markmeld/cli.py b/markmeld/cli.py index 832202d..5d34ce4 100644 --- a/markmeld/cli.py +++ b/markmeld/cli.py @@ -154,6 +154,8 @@ def main(test_args=None): if "targets" not in cfg: raise TargetError(f"No targets specified in config.") for t, k in cfg["targets"].items(): + if "abstract" in cfg["targets"][t]: + continue sys.stdout.write(t + " ") sys.exit(0) @@ -167,10 +169,12 @@ def main(test_args=None): if args.list: if "targets" not in cfg: raise TargetError(f"No targets specified in config.") - tarlist = { - x: k["description"] if "description" in k else "No description" - for x, k in sorted(cfg["targets"].items()) - } + + tarlist = {} + for t, k in cfg["targets"].items(): + if "abstract" in cfg["targets"][t]: + continue + tarlist[t] = k["description"] if "description" in k else "---" _LOGGER.error(f"Targets:") for k, v in tarlist.items(): _LOGGER.error(f" {k}: {v}")