Skip to content

Commit 64e58e1

Browse files
authored
Merge pull request #14 from bcdev/forman-update_api_docs
Update API docs
2 parents 9b8d5f4 + 650efd6 commit 64e58e1

File tree

20 files changed

+241
-176
lines changed

20 files changed

+241
-176
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# XRLint Change History
22

3+
## Version 0.2.0 (in development)
4+
5+
- Make all docstrings comply to google-style
6+
37
## Version 0.1.0 (09.01.2025)
48

59
- Added CLI option `--print-config PATH`, see same option in ESLint

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
XRLint is a [linting](https://en.wikipedia.org/wiki/Lint_(software))
1111
tool and library for [xarray]() datasets.
12-
Its design is heavily inspired by [ESLint](https://eslint.org/).
12+
Its design is heavily inspired by the awesome [ESLint](https://eslint.org/).
1313

1414

1515
## Features
@@ -23,13 +23,13 @@ Its design is heavily inspired by [ESLint](https://eslint.org/).
2323

2424
## Inbuilt Rules
2525

26-
The following rule plugins are currently built into the code base:
26+
The following plugins provide XRLint's [inbuilt rules](https://bcdev.github.io/xrlint/rule-ref/):
2727

28-
- `xrlint.plugins.core`: Implementing the rules for
28+
- `xrlint.plugins.core`: implementing the rules for
2929
[tidy data](https://tutorial.xarray.dev/intermediate/data_cleaning/05.1_intro.html)
3030
and the
3131
[CF-Conventions](https://cfconventions.org/cf-conventions/cf-conventions.html).
32-
- `xrlint.plugins.core`: Implementing the rules for
32+
- `xrlint.plugins.core`: implementing the rules for
3333
[xcube datasets](https://xcube.readthedocs.io/en/latest/cubespec.html).
3434
Note, this plugin is fully optional. You must manually configure
3535
it to apply its rules. It may be moved into a separate GitHub repo

docs/api.md

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,95 @@
11
# Python API
22

3-
All described objects can be imported from the `xrlint.all` module.
4-
5-
## Class `XRLint`
6-
3+
This chapter provides a plain reference for the XRLint Python API.
4+
5+
## Overview
6+
7+
- The top-level API component is the class [XRLint][xrlint.cli.engine.XRLint]
8+
which encapsulates the functionality of the [XRLint CLI](cli.md).
9+
- The `linter` module provides the functionality for linting a single
10+
dataset:
11+
[new_linter()][xrlint.linter.new_linter] factory function and the
12+
[Linter][xrlint.linter.Linter] class.
13+
- The `plugin` module provides plugin related classes:
14+
[Plugin][xrlint.plugin.Plugin] and its
15+
metadata [PluginMeta][xrlint.plugin.PluginMeta].
16+
- The `config` module provides classes that represent
17+
configuration information and provide related functionality:
18+
[Config][xrlint.config.Config] and [ConfigList][xrlint.config.ConfigList].
19+
- The `rule` module provides rule related classes:
20+
[Rule][xrlint.rule.Rule] comprising rule metadata
21+
[RuleMeta][xrlint.rule.RuleMeta] and the rule operation
22+
[RuleOp][xrlint.rule.RuleOp], as well as related to the latter
23+
[RuleContext][xrlint.rule.RuleContext] and [RuleExit][xrlint.rule.RuleExit].
24+
- The `node` module defines the nodes passed to [xrlint.rule.RuleOp]:
25+
base classes [None][xrlint.node.Node], [XarrayNode][xrlint.node.XarrayNode]
26+
and the specific [DatasetNode][xrlint.node.DatasetNode],
27+
[DataArray][xrlint.node.DataArrayNode], [AttrsNode][xrlint.node.AttrsNode],
28+
and [AttrNode][xrlint.node.AttrNode] nodes.
29+
- The `processor` module provides processor related classes:
30+
[Processor][xrlint.processor.Processor] comprising processor metadata
31+
[ProcessorMeta][xrlint.processor.ProcessorMeta]
32+
and the processor operation [ProcessorOp][xrlint.processor.ProcessorOp].
33+
- The `result` module provides data classes that are used to
34+
represent validation results:
35+
[Result][xrlint.result.Result] composed of [Messages][xrlint.result.Message],
36+
which again may contain [Suggestions][xrlint.result.Suggestion].
37+
- Finally, the `testing` module provides classes for rule testing:
38+
[RuleTester][xrlint.testing.RuleTester] that is made up
39+
of [RuleTest][xrlint.testing.RuleTest]s.
40+
41+
Note: the `xrlint.all` convenience module exports all of the above from a
42+
single module.
43+
744
::: xrlint.cli.engine.XRLint
845

9-
## Function `new_linter()`
10-
1146
::: xrlint.linter.new_linter
1247

13-
## Class `Linter`
14-
1548
::: xrlint.linter.Linter
1649

17-
## Class `Config`
18-
1950
::: xrlint.config.Config
2051

21-
## Class `ConfigList`
22-
2352
::: xrlint.config.ConfigList
2453

25-
## Class `Plugin`
26-
27-
::: xrlint.plugin.Plugin
28-
29-
## Class `PluginMeta`
30-
31-
::: xrlint.plugin.PluginMeta
54+
::: xrlint.rule.Rule
3255

33-
## Class `Processor`
56+
::: xrlint.rule.RuleMeta
3457

35-
::: xrlint.processor.Processor
58+
::: xrlint.rule.RuleOp
3659

37-
## Class `ProcessorMeta`
60+
::: xrlint.rule.RuleContext
3861

39-
::: xrlint.processor.ProcessorMeta
62+
::: xrlint.rule.RuleExit
4063

41-
## Class `ProcessorOp`
64+
::: xrlint.node.Node
4265

43-
::: xrlint.processor.ProcessorOp
66+
::: xrlint.node.XarrayNode
4467

45-
## Class `RuleConfig`
68+
::: xrlint.node.DatasetNode
4669

47-
::: xrlint.rule.RuleConfig
70+
::: xrlint.node.DataArrayNode
4871

49-
## Class `Rule`
72+
::: xrlint.node.AttrsNode
5073

51-
::: xrlint.rule.Rule
74+
::: xrlint.node.AttrNode
5275

53-
## Class `RuleMeta`
76+
::: xrlint.plugin.Plugin
5477

55-
::: xrlint.rule.RuleMeta
78+
::: xrlint.plugin.PluginMeta
5679

57-
## Class `RuleOp`
80+
::: xrlint.processor.Processor
5881

59-
::: xrlint.rule.RuleOp
82+
::: xrlint.processor.ProcessorMeta
83+
84+
::: xrlint.processor.ProcessorOp
6085

61-
## Class `RuleContext`
86+
::: xrlint.result.Result
6287

63-
::: xrlint.rule.RuleContext
88+
::: xrlint.result.Message
6489

65-
## Class `RuleTester`
90+
::: xrlint.result.Suggestion
6691

6792
::: xrlint.testing.RuleTester
6893

69-
## Class `RuleTest`
70-
7194
::: xrlint.testing.RuleTest
7295

73-
## Class `Result`
74-
75-
::: xrlint.result.Result
76-
77-
## Class `Message`
78-
79-
::: xrlint.result.Message
80-
81-
## Class `Suggestion`
82-
83-
::: xrlint.result.Suggestion
84-

docs/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
XRLint is a [linting](https://en.wikipedia.org/wiki/Lint_(software))
55
tool and library for [xarray]() datasets.
6-
Its design is heavily inspired by [ESLint](https://eslint.org/).
6+
Its design is heavily inspired by the awesome [ESLint](https://eslint.org/).
77

88

99
## Features
@@ -18,13 +18,13 @@ Its design is heavily inspired by [ESLint](https://eslint.org/).
1818

1919
## Inbuilt Rules
2020

21-
The following rule plugins are currently built into the code base:
21+
The following plugins provide XRLint's [inbuilt rules](rule-ref.md):
2222

23-
- `core`: Implementing the rules for
23+
- `core`: implementing the rules for
2424
[tidy data](https://tutorial.xarray.dev/intermediate/data_cleaning/05.1_intro.html)
2525
and the
2626
[CF-Conventions](https://cfconventions.org/cf-conventions/cf-conventions.html).
27-
- `xcube`: Implementing the rules for
27+
- `xcube`: implementing the rules for
2828
[xcube datasets](https://xcube.readthedocs.io/en/latest/cubespec.html).
2929
Note, this plugin is fully optional. You must manually configure
3030
it to apply its rules. It may be moved into a separate GitHub repo

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies:
1313
- black
1414
- flake8
1515
- mkdocs
16+
- mkdocs-autorefs
1617
- mkdocs-material
1718
- mkdocstrings
1819
- mkdocstrings-python

mkdocs.yml

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,59 @@ repo_name: bcdev/xrlint
55
copyright: Copyright © 2025 Brockmann Consult
66

77
nav:
8-
- Overview: index.md
9-
- Getting Started: start.md
10-
- Configuration: config.md
11-
- Rule Reference: rule-ref.md
12-
- CLI: cli.md
13-
- Python API: api.md
14-
- About: about.md
8+
- Overview: index.md
9+
- Getting Started: start.md
10+
- Configuration: config.md
11+
- Rule Reference: rule-ref.md
12+
- CLI: cli.md
13+
- Python API: api.md
14+
- About: about.md
1515

1616
theme:
17-
name: material
18-
# logo: assets/logo.png
19-
# favicon: assets/logo-small.png
20-
palette:
21-
# Palette toggle for light mode
22-
- scheme: default
23-
primary: blue grey
24-
toggle:
25-
icon: material/brightness-7
26-
name: Switch to dark mode
27-
# Palette toggle for dark mode
28-
- scheme: slate
29-
primary: blue grey
30-
toggle:
31-
icon: material/brightness-4
32-
name: Switch to light mode
17+
name: material
18+
# logo: assets/logo.png
19+
# favicon: assets/logo-small.png
20+
palette:
21+
# Palette toggle for light mode
22+
- scheme: default
23+
primary: blue grey
24+
toggle:
25+
icon: material/brightness-7
26+
name: Switch to dark mode
27+
# Palette toggle for dark mode
28+
- scheme: slate
29+
primary: blue grey
30+
toggle:
31+
icon: material/brightness-4
32+
name: Switch to light mode
3333

3434
markdown_extensions:
35-
- attr_list
36-
- admonition
37-
- pymdownx.details
38-
- pymdownx.superfences
39-
- pymdownx.emoji:
40-
emoji_index: !!python/name:material.extensions.emoji.twemoji
41-
emoji_generator: !!python/name:material.extensions.emoji.to_svg
35+
- attr_list
36+
- admonition
37+
- pymdownx.details
38+
- pymdownx.superfences
39+
- pymdownx.emoji:
40+
emoji_index: !!python/name:material.extensions.emoji.twemoji
41+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
4242

4343
extra:
44-
social:
45-
- icon: fontawesome/brands/github
46-
link: https://github.com/bcdev/xrlint
47-
- icon: fontawesome/brands/python
48-
link: https://pypi.org/project/xrlint/
44+
social:
45+
- icon: fontawesome/brands/github
46+
link: https://github.com/bcdev/xrlint
47+
- icon: fontawesome/brands/python
48+
link: https://pypi.org/project/xrlint/
4949

5050
plugins:
51-
- search
52-
- autorefs
53-
- mkdocstrings:
54-
handlers:
55-
python:
56-
options:
57-
show_root_toc_entry: false
58-
show_root_heading: false
59-
show_source: true
60-
heading_level: 3
61-
annotations_path: brief
62-
members_order: source
51+
- search
52+
- autorefs
53+
- mkdocstrings:
54+
handlers:
55+
python:
56+
options:
57+
docstring_style: google
58+
show_root_toc_entry: true
59+
show_root_heading: true
60+
show_source: true
61+
heading_level: 2
62+
annotations_path: brief
63+
members_order: source

notebooks/mkdataset.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,18 @@
88

99
def make_dataset() -> xr.Dataset:
1010
"""Create a dataset that passes xrlint core rules."""
11-
11+
1212
return xr.Dataset(
1313
attrs=dict(title="SST-Climatology Subset"),
1414
coords={
1515
"x": xr.DataArray(
16-
np.linspace(-180, 180, nx),
17-
dims="x",
18-
attrs={"units": "degrees"}
16+
np.linspace(-180, 180, nx), dims="x", attrs={"units": "degrees"}
1917
),
2018
"y": xr.DataArray(
21-
np.linspace(-90, 90, ny),
22-
dims="y",
23-
attrs={"units": "degrees"}
19+
np.linspace(-90, 90, ny), dims="y", attrs={"units": "degrees"}
2420
),
2521
"time": xr.DataArray(
26-
[2010 + y for y in range(nt)],
27-
dims="time",
28-
attrs={"units": "years"}
22+
[2010 + y for y in range(nt)], dims="time", attrs={"units": "years"}
2923
),
3024
"spatial_ref": xr.DataArray(
3125
0,
@@ -38,27 +32,25 @@ def make_dataset() -> xr.Dataset:
3832
},
3933
data_vars={
4034
"sst": xr.DataArray(
41-
np.random.random((nt, ny, nx)),
42-
dims=["time", "y", "x"],
43-
attrs={"units": "kelvin", "grid_mapping": "spatial_ref"}
35+
np.random.random((nt, ny, nx)),
36+
dims=["time", "y", "x"],
37+
attrs={"units": "kelvin", "grid_mapping": "spatial_ref"},
4438
),
4539
"sst_anomaly": xr.DataArray(
46-
np.random.random((nt, ny, nx)),
47-
dims=["time", "y", "x"],
48-
attrs={"units": "kelvin", "grid_mapping": "spatial_ref"}
49-
)
40+
np.random.random((nt, ny, nx)),
41+
dims=["time", "y", "x"],
42+
attrs={"units": "kelvin", "grid_mapping": "spatial_ref"},
43+
),
5044
},
5145
)
5246

5347

54-
def make_dataset_with_issues() -> xr.Dataset:
48+
def make_dataset_with_issues() -> xr.Dataset:
5549
"""Create a dataset that produces issues with xrlint core rules."""
5650
invalid_ds = make_dataset()
5751
invalid_ds.attrs = {}
5852
invalid_ds.sst.attrs["units"] = 1
5953
invalid_ds["sst_avg"] = xr.DataArray(
60-
np.random.random((nx, ny)),
61-
dims=["x", "y"],
62-
attrs={"units": "kelvin"}
54+
np.random.random((nx, ny)), dims=["x", "y"], attrs={"units": "kelvin"}
6355
)
6456
return invalid_ds

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ dev = [
7474
]
7575
doc = [
7676
"mkdocs",
77+
"mkdocs-autorefs",
7778
"mkdocs-material",
7879
"mkdocstrings",
7980
"mkdocstrings-python"

0 commit comments

Comments
 (0)