-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement defaults file inheritance #6924
Conversation
Thanks for this! On the whole it looks good. I've got a few comments on a first glance through.
|
cc7f472
to
b600e80
Compare
Thanks for the quick response! I have addressed your points, I hope it looks better now. regarding 2.) I simply did not consider that removing the instance would affect backwards compatibility. Keeping it should not be a problem! regarding 3.) I was thinking that using |
Thanks, this is looking good. I had one more thought. Why not allow
or
is possible. See how we currently handle |
b600e80
to
b9fdd90
Compare
Done! I have also added a new command test for this. |
Allow defaults files to inherit options from other defaults files by specifying them with the following syntax: 'defaults: [list of defaults files]'.
b9fdd90
to
b7c49f0
Compare
Great, thanks for your contribution to pandoc! |
This pull request adds an inheritance system for defaults files as requested in #6827.
Motivation
Currently, it is not possible to share a set of options between defaults files in a flexible way. The inheritance system implemented in this branch solves that problem by allowing a defaults file to specify other defaults files to inherit from.
Usage examples
Simple example
See #6827
Multiple defaults files
Assume
defsA.yaml
looks like this:Then calling
pandoc -d defsA
has the same result as callingpandoc -d defsB -d defsC -d defsA
. Note that firstdefsB.yaml
is "applied", followed bydefsC.yaml
and finallydefsA.yaml
.Circular references
Assume:
defsA.yaml
:defsB.yaml
:In this scenario
defsA.yaml
inherits fromdefsB.yaml
and vice versa. As there is no sensible way of resolving this circularity, executingpandoc -d defsA
yields the following error message: "Error: Circular defaults file reference in 'defsB.yaml'.User data directories
Assume:
defsA.yaml
:defsB.yaml
:When calling
pandoc -d defsA
, pandoc searches fordefsB.yaml
andtest.html
inPATH_TO_DATA_DIR_B/defaults
and fordefsC.yaml
inPATH_TO_DATA_DIR_C/defaults
. In other words: specifying a user data directory indefsB.yaml
does not affectdefsA.yaml
.Implementation
The feature is implemented by adjusting/extending the
FromYAML (Opt -> Opt)
instance inPandoc/App/Opt.hs
. I have tried to change as little as possible, but since parsing a YAML file now potentially requires file-IO and keeping track of a graph-like data structure in order to detect circular inheritance, I had to introduceMonadIO
andStateT
to some type signatures.closes #6827