Skip to content

Commit 0ccfb76

Browse files
authored
Merge pull request #18 from bcdev/forman-improce_docs
Improve docs
2 parents de5c4e5 + e6bbaac commit 0ccfb76

File tree

15 files changed

+90
-53
lines changed

15 files changed

+90
-53
lines changed

CHANGES.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# XRLint Change History
22

3-
## Version 0.2.0 (in development)
3+
## Version 0.2.0 (14.01.2025)
44

5-
- Make all docstrings comply to google-style
65
- Rule description is now your `RuleOp`'s docstring
76
if `description` is not explicitly provided.
87
- Supporting _virtual plugins_: plugins provided by Python
98
dictionaries with rules defined by the `RuleOp` classes.
109
- Added more configuration examples in the `examples` folder.
11-
- Introduced utilities `ValueConstructible` and
10+
- All `xcube` rules now have references into the
11+
xcube dataset specification.
12+
- Introduced mixin classes `ValueConstructible` and
1213
derived `MappingConstructible` which greatly simplify
13-
flexible instantiation of configuration objects and their
14-
children from Python and JSON/YAML values.
14+
flexible instantiation of XRLint's configuration objects
15+
and their children from Python and JSON/YAML values.
16+
- Made all docstrings comply to google-style.
1517

1618
## Version 0.1.0 (09.01.2025)
1719

docs/rule-ref.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
3737
### :material-bug: `any-spatial-data-var`
3838

3939
A datacube should have spatial data variables.
40+
[More information.](https://xcube.readthedocs.io/en/latest/cubespec.html#data-model-and-format)
4041

4142
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:
4243

4344
### :material-bug: `cube-dims-order`
4445

4546
Order of dimensions in spatio-temporal datacube variables should be [time, ..., y, x].
47+
[More information.](https://xcube.readthedocs.io/en/latest/cubespec.html#data-model-and-format)
4648

4749
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:
4850

@@ -56,24 +58,28 @@ Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
5658
### :material-lightbulb: `grid-mapping-naming`
5759

5860
Grid mapping variables should be called 'spatial_ref' or 'crs' for compatibility with rioxarray and other packages.
61+
[More information.](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)
5962

6063
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
6164

6265
### :material-bug: `increasing-time`
6366

6467
Time coordinate labels should be monotonically increasing.
68+
[More information.](https://xcube.readthedocs.io/en/latest/cubespec.html#temporal-reference)
6569

6670
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:
6771

6872
### :material-bug: `lat-lon-naming`
6973

7074
Latitude and longitude coordinates and dimensions should be called 'lat' and 'lon'.
75+
[More information.](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)
7176

7277
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:
7378

7479
### :material-bug: `single-grid-mapping`
7580

7681
A single grid mapping shall be used for all spatial data variables of a datacube.
82+
[More information.](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)
7783

7884
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:
7985

docs/todo.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
## Desired
1212

1313
- project logo
14-
- if configuration for given FILE is empty,
15-
report an error, see TODO in CLI main tests
16-
- use `RuleMeta.docs_url` in formatters to create links
17-
- implement xarray backend for xcube 'levels' format
18-
so can validate them too
14+
- support validating xcube 'levels' format. Options:
15+
- implement xarray backend so we can open them using `xr.open_dataset`
16+
with `opener_options: {"engine": "xc-levels"}`.
17+
- implement a `xrlint.processor.Processor` for that purpose.
1918
- add some more tests so we reach 99% coverage
2019
- support rule op args/kwargs schema validation
2120
- Support `RuleTest.expected`, it is currently unused

xrlint/formatter.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,26 @@ def format(
4141
"""
4242

4343

44-
@dataclass(frozen=True, kw_only=True)
44+
@dataclass(kw_only=True)
4545
class FormatterMeta:
4646
"""Formatter metadata."""
4747

4848
name: str
4949
"""Formatter name."""
50+
5051
version: str = "0.0.0"
5152
"""Formatter version."""
53+
5254
schema: dict[str, Any] | list[dict[str, Any]] | bool | None = None
5355
"""Formatter options schema."""
5456

57+
ref: str | None = None
58+
"""Formatter reference.
59+
Specifies the location from where the formatter can be
60+
dynamically imported.
61+
Must have the form "<module>:<attr>", if given.
62+
"""
63+
5564

5665
@dataclass(frozen=True, kw_only=True)
5766
class Formatter:
@@ -69,6 +78,7 @@ class FormatterRegistry(Mapping[str, Formatter]):
6978
def __init__(self):
7079
self._registrations = {}
7180

81+
# TODO: fix this code duplication in define_rule()
7282
def define_formatter(
7383
self,
7484
name: str | None = None,

xrlint/plugin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class PluginMeta(MappingConstructible, JsonSerializable):
1919
"""Plugin version."""
2020

2121
ref: str | None = None
22-
"""Plugin module reference.
23-
Specifies the location from where the plugin can be loaded.
24-
Must have the form "<module>:<attr>".
22+
"""Plugin reference.
23+
Specifies the location from where the plugin can be
24+
dynamically imported.
25+
Must have the form "<module>:<attr>", if given.
2526
"""
2627

2728
@classmethod

xrlint/plugins/xcube/rules/any_spatial_data_var.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
version="1.0.0",
1010
type="problem",
1111
description="A datacube should have spatial data variables.",
12+
docs_url=(
13+
"https://xcube.readthedocs.io/en/latest/cubespec.html#data-model-and-format"
14+
),
1215
)
1316
class AnySpatialDataVar(RuleOp):
1417
def dataset(self, ctx: RuleContext, node: DatasetNode):

xrlint/plugins/xcube/rules/cube_dims_order.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
f"Order of dimensions in spatio-temporal datacube variables"
1313
f" should be [{T_NAME}, ..., {Y_NAME}, {X_NAME}]."
1414
),
15+
docs_url=(
16+
"https://xcube.readthedocs.io/en/latest/cubespec.html#data-model-and-format"
17+
),
1518
)
1619
class CubeDimsOrder(RuleOp):
1720
def data_array(self, ctx: RuleContext, node: DataArrayNode):

xrlint/plugins/xcube/rules/grid_mapping_naming.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
f"Grid mapping variables should be called {GM_NAMES_TEXT}"
1313
f" for compatibility with rioxarray and other packages."
1414
),
15+
docs_url="https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference",
1516
)
1617
class GridMappingNaming(RuleOp):
1718
def dataset(self, ctx: RuleContext, node: DatasetNode):

xrlint/plugins/xcube/rules/increasing_time.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
version="1.0.0",
1515
type="problem",
1616
description="Time coordinate labels should be monotonically increasing.",
17+
docs_url=(
18+
"https://xcube.readthedocs.io/en/latest/cubespec.html#temporal-reference"
19+
),
1720
)
1821
class IncreasingTime(RuleOp):
1922
def data_array(self, ctx: RuleContext, node: DataArrayNode):

xrlint/plugins/xcube/rules/lat_lon_naming.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
f"Latitude and longitude coordinates and dimensions"
1616
f" should be called {LAT_NAME !r} and {LON_NAME !r}."
1717
),
18+
docs_url="https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference",
1819
)
1920
class LatLonNaming(RuleOp):
2021
def dataset(self, ctx: RuleContext, node: DatasetNode):

0 commit comments

Comments
 (0)