Skip to content

Commit 0ffbfd5

Browse files
shoyerXarray-Beam authors
authored andcommitted
Add docs for xbeam.Dataset
PiperOrigin-RevId: 813378676
1 parent 9881072 commit 0ffbfd5

7 files changed

Lines changed: 454 additions & 122 deletions

File tree

docs/api.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,28 @@
7878
split_chunks
7979
split_variables
8080
in_memory_rechunk
81-
```
81+
```
82+
83+
## High-level interface
84+
85+
```{warning}
86+
The high-level interface is experimental and offers no backwards compatibility
87+
guarantees.
88+
```
89+
90+
```{eval-rst}
91+
.. autosummary::
92+
:toctree: _autosummary
93+
94+
Dataset
95+
Dataset.from_xarray
96+
Dataset.from_zarr
97+
Dataset.to_zarr
98+
Dataset.collect_with_direct_runner
99+
Dataset.map_blocks
100+
Dataset.rechunk
101+
Dataset.split_variables
102+
Dataset.consolidate_variables
103+
Dataset.head
104+
Dataset.pipe
105+
```

docs/conf.py

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
# import sys
1515
# sys.path.insert(0, os.path.abspath('.'))
1616

17-
# Print Python environment info for easier debugging on ReadTheDocs
18-
17+
import inspect
18+
import operator
19+
import os
1920
import sys
2021
import subprocess
22+
2123
import xarray_beam # verify this works
2224

25+
# Print Python environment info for easier debugging on ReadTheDocs
2326
print("python exec:", sys.executable)
2427
print("sys.path:", sys.path)
2528
print("pip environment:")
@@ -42,6 +45,7 @@
4245
extensions = [
4346
'sphinx.ext.autodoc',
4447
'sphinx.ext.autosummary',
48+
'sphinx.ext.linkcode',
4549
'sphinx.ext.napoleon',
4650
'myst_nb',
4751
]
@@ -63,7 +67,14 @@
6367
# The theme to use for HTML and HTML Help pages. See the documentation for
6468
# a list of builtin themes.
6569
#
66-
html_theme = 'sphinx_rtd_theme'
70+
html_theme = 'furo' # https://pradyunsg.me/furo/quickstart/
71+
72+
html_theme_options = {
73+
'source_repository': 'https://github.com/google/xarray-beam/',
74+
'source_branch': 'main',
75+
'source_directory': 'docs/',
76+
'sidebar_hide_name': False,
77+
}
6778

6879
# Add any paths that contain custom static files (such as style sheets) here,
6980
# relative to this directory. They are copied after the builtin static files,
@@ -81,3 +92,34 @@
8192

8293
# https://stackoverflow.com/a/66295922/809705
8394
autodoc_typehints = "description"
95+
96+
97+
# Customize code links via sphinx.ext.linkcode
98+
# Borrowed from JAX: https://github.com/google/jax/pull/20961
99+
100+
101+
def linkcode_resolve(domain, info):
102+
if domain != 'py':
103+
return None
104+
if not info['module']:
105+
return None
106+
if not info['fullname']:
107+
return None
108+
try:
109+
mod = sys.modules.get(info['module'])
110+
obj = operator.attrgetter(info['fullname'])(mod)
111+
if isinstance(obj, property):
112+
obj = obj.fget
113+
while hasattr(obj, '__wrapped__'): # decorated functions
114+
obj = obj.__wrapped__
115+
filename = inspect.getsourcefile(obj)
116+
source, linenum = inspect.getsourcelines(obj)
117+
print(f'found source code for: {info}')
118+
except Exception as e:
119+
print(f'did not find source code for: {info}: {e}')
120+
return None
121+
filename = os.path.relpath(
122+
filename, start=os.path.dirname(xarray_beam.__file__)
123+
)
124+
lines = f'#L{linenum}-L{linenum + len(source)}' if linenum else ''
125+
return f'https://github.com/google/xarray-beam/blob/main/xarray_beam/{filename}{lines}'

0 commit comments

Comments
 (0)