Skip to content

Commit

Permalink
implement abstract targets. Fix #19
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Nov 7, 2023
1 parent 0ebee6f commit ee16f85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 12 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
```
12 changes: 8 additions & 4 deletions markmeld/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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}")
Expand Down

0 comments on commit ee16f85

Please sign in to comment.