-
Notifications
You must be signed in to change notification settings - Fork 96
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
Formatter specific defaults #662
Comments
Maybe a good compromise would be to provide values for the formatters we support and have a fallback to the
? The main worry there would be that it's going to be slower if we keep trying to format everything twice. EDIT: |
Could formatters set their own defaults? For instance, if the relevant options internally become dictionaries mapping formatters to values, a third-party formatter could get the defaults with
Hmm... that's a tougher one. I guess some sort of fallback option might be useful there. It would be important for such third-party extensions to make explicit for what formatters they supply defaults. Authors should also be encouraged to provide defaults for at least
I think papis itself should ship values for all options and formatters that are included in papis itself. Third-party formatters should be expected to provide defaults for all options that are shipped with papis. Support for third-party 'commands / exporters / downloaders /' would be optional, and if a case is encountered for which no value exists, fallback to the You're right, getting this all right does seem quite complicated. I guess it would make sense to internally structure the relevant options as dictionaries, mapping formatters to values. But that would both break existing configs and be unnecessarily confusing for users. So, it would make sense to allow users to set options' values with just a string, which would then set the value for whatever formatter is set as the one to be used (or for the
I was just going to say that. But I don't think we need to fallback like that. If the options are dictionaries, we can just use whatever is defined and fallback if a value is missing for a given formatter. (Some of this is probably a bit hard to parse and just me thinking out loud. Let me know if/where that's the case 😅) |
It seems like that allowing local formatter would be the simplest solution 😅, for both papis and third-part plugin extensions. As far as I am concerned, the format string provided by user (or the defaults by papis) is some kind of function/mapping that maps the doc meta info to a string. That being said, the string itself does not make sense --- it is bound with its formatter. And allowing third-part formatter to set defaults may cause inconsistent problem due to carelessness of its developer, or updates in defaults from papis. Maintaining consistent defaults between formatters (especially for third-part ones) would be a problem. The assumption behind the logic that every formatter provides defaults for basic options is that all the formatters can do what python formatter can do at least. An extreme example would be a formatter that supports words slicing (which python formatter lacks) but unable to do character slicing (which python formatter can). I know little about plugins/extensions, so let me know if there is any misunderstandings. |
Yeah, I like that idea too, but I don't particularly like the Maybe we can add that to the configuration key instead of the configuration value? Something like
(only one of these should be defined) and then have a
Yeah, that's a good point. The defaults change over time, so it would be quite confusing for a user to change their formatter and suddenly get new values in various places :\ |
Oh I see! It is a issue about how to represent a compound structure in ini file indeed. It reminds me of TOML's dotted key. How about this document-description-format = <FORMAT_STR>
document-description-format.formatter = <FORMATTER_NAME> It seems to be more natural. 😃 |
Yeah, that looks nicer! @jghauser @alejandrogallo What do you think about a scheme like this that lets you select the formatter? It doesn't solve the original problem of providing correct defaults for each formatter, but that seems rather complicated and error prone :\ This would solve making some settings, e.g. |
I really like this syntax. And I think it makes a lot of sense to handle setting a mix and match combo of formatters that way. I still think providing sensible config defaults would be a nice thing to have, but I can see that the benefits may not outweigh the added complexity. I guess if we note in the docs very clearly that the preferred way to get nicer formatting for e.g. the |
this makes a lot of sense, I support this. We have to put a full example in the example configuration on the docs. |
Definitely needs a bunch of docs to make it clear how it works, but otherwise should be pretty nice!
@jghauser Maybe we can have a
@OopsYao Do you have time to implement something like this? |
Being busy recently, but I’m very glad to implement this, and I’ll probably work on it one week later or two. And it occurs to me that, though it is technically possible to implement something like document-description-format = <FORMAT_STR>
document-description-format.formatter = <FORMATTER_NAME> it is not a good data model in the sense that # Use local formatter
document-description-format.content = <FORMAT_STR>
document-description-format.formatter = <FORMATTER_NAME>
# Use global formatter
document-description-format = <FORMAT_STR> And we can throw an error of duplicated keys or let the later one take precedence (depending on how papis handle duplicated config keys conventionally) when both |
That's quite ok! Let us know if you need any help or can't get to it.
I'm not particularly worried about that. If we ever decide to move to another format, we'll likely have to write some converter which can take care of any issues like that. So for the moment, we'd just need something simple to implement and understand.
Not a super big fan of this because you always have to remember to write both, which can get tiring if there's a dozen or so settings to modify. |
Originally posted by @jghauser in #661 (comment)
Currently the defaults in
papis/defaults.py
use thepython
formatter and setting any other formatter means the user needs to provide values for all of these. Ideally we would help them along by setting some values ourselves.This is a bit difficult to do 100% because formatters and options can be provided by third-party plugins. Possible issues:
The text was updated successfully, but these errors were encountered: