nsidc / qgreenland

Source code for generating the QGreenland package hosted at https://qgreenland.org/
https://qgreenland.readthedocs.io
Other
36 stars 9 forks source link

Improve developer experience of `__settings__.py` layer order #672

Closed MattF-NSIDC closed 1 year ago

MattF-NSIDC commented 1 year ago

When defining custom layer order with __settings__py (the default is alphabetical), there's some string magic going on. E.g.:

order = [
    ":foo",  # Must match the id of layer defined by a python file in this dir (not a subdir)
    ":bar",
    "More Layers",  # Must match a subdirectory name
]

Instead, I think we should have a trivial class, e.g. LayerIdentifier, that we can use to remove the magic by giving readers a name instead of just a symbol. The class can perhaps handle some degree of validation? The class can also have a helpful docstring. Instead of checking string.startswith to determine if something is a

What about also a LayerGroupIdentifier class?

order = [
    LayerIdentifier("foo"),  # Must match the id of layer defined by a python file in this dir (not a subdir)
    LayerIdentifier("bar"),
    LayerGroupIdentifier("More Layers"),  # Must match a subdirectory name
]
MattF-NSIDC commented 1 year ago

Resolved by #684