Skip to content

Commit a2f37ba

Browse files
committed
Improve docstring for documentation API
1 parent 19e7886 commit a2f37ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+657
-591
lines changed

MANIFEST.in

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ prune .github
22
prune data
33
prune docs
44
prune tutorials
5-
prune ci
5+
prune ci
66
prune disdrodb/tests
7-
8-

ci/environment.yml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- donfig
1010
- requests
1111
- trollsift
12-
- h5py
1312
- netcdf4
1413
- pyarrow
1514
- pandas

ci/environment_latest.yml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- donfig
1010
- requests
1111
- trollsift
12-
- h5py
1312
- netcdf4
1413
- pyarrow
1514
- pandas

disdrodb/_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
def _get_disdrodb_default_configs():
29-
"""Retrieve the default DISDRODB settings from the .config_disdrodb.yml file."""
29+
"""Retrieve the default DISDRODB settings from the ``.config_disdrodb.yml`` file."""
3030
try:
3131
config_dict = read_disdrodb_configs()
3232
config_dict = {key: value for key, value in config_dict.items() if value is not None}

disdrodb/api/checks.py

+22-17
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def check_url(url: str) -> bool:
6767
Returns
6868
-------
6969
bool
70-
True if url well formatted, False if not well formatted.
70+
``True`` if url well formatted, ``False`` if not well formatted.
7171
"""
7272
regex = r"^(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$" # noqa: E501
7373

@@ -87,14 +87,14 @@ def check_path_is_a_directory(dir_path, path_name=""):
8787

8888

8989
def check_directories_inside(dir_path):
90-
"""Check there are directories inside the specified dir_path."""
90+
"""Check there are directories inside the specified ``dir_path``."""
9191
dir_paths = os.listdir(dir_path)
9292
if len(dir_paths) == 0:
9393
raise ValueError(f"There are not directories within {dir_path}")
9494

9595

9696
def check_base_dir(base_dir: str):
97-
"""Raise an error if the path does not end with "DISDRODB"."""
97+
"""Raise an error if the path does not end with ``DISDRODB``."""
9898
base_dir = str(base_dir) # convert Pathlib to string
9999
if not base_dir.endswith("DISDRODB"):
100100
raise ValueError(f"The path {base_dir} does not end with DISDRODB. Please check the path.")
@@ -114,7 +114,7 @@ def check_sensor_name(sensor_name: str, product: str = "L0A") -> None:
114114
Raises
115115
------
116116
TypeError
117-
Error if `sensor_name` is not a string.
117+
Error if ``sensor_name`` is not a string.
118118
ValueError
119119
Error if the input sensor name has not been found in the list of available sensors.
120120
"""
@@ -177,7 +177,7 @@ def check_station_dir(product, data_source, campaign_name, station_name, base_di
177177

178178

179179
def has_available_station_files(product, data_source, campaign_name, station_name, base_dir=None):
180-
"""Return True if data are available for the given product and station."""
180+
"""Return ``True`` if data are available for the given product and station."""
181181
station_dir = check_station_dir(
182182
product=product,
183183
base_dir=base_dir,
@@ -295,7 +295,7 @@ def check_issue_file(data_source, campaign_name, station_name, base_dir=None):
295295

296296

297297
def check_is_within_raw_directory(path):
298-
"""Check the path is within the DISDRODB 'Raw' directory."""
298+
"""Check the path is within the DISDRODB ``Raw`` directory."""
299299
components = infer_disdrodb_tree_path_components(path)
300300
if components[1] != "Raw":
301301
msg = f"{path} is not within the 'Raw' directory."
@@ -304,7 +304,7 @@ def check_is_within_raw_directory(path):
304304

305305

306306
def check_is_within_processed_directory(path):
307-
"""Check the path is within the DISDRODB 'Processed' directory."""
307+
"""Check the path is within the DISDRODB ``Processed`` directory."""
308308
components = infer_disdrodb_tree_path_components(path)
309309
if components[1] != "Processed":
310310
msg = f"{path} is not within the 'Processed' directory."
@@ -315,9 +315,9 @@ def check_is_within_processed_directory(path):
315315
def check_valid_campaign_dir(campaign_dir):
316316
"""Check the validity of a campaign directory path.
317317
318-
Used to check validity of 'raw_dir' and 'processed_dir'.
318+
Used to check validity of ``raw_dir`` and ``processed_dir``.
319319
320-
The path must represents this path */DISDRODB/<Raw or Processed>/<DATA_SOURCE>/<CAMPAIGN_NAME>
320+
The path must be ``*/DISDRODB/<Raw/Processed>/<DATA_SOURCE>/<CAMPAIGN_NAME>``
321321
"""
322322
last_component = os.path.basename(campaign_dir)
323323
tree_components = infer_disdrodb_tree_path_components(campaign_dir)
@@ -347,11 +347,16 @@ def check_raw_dir(raw_dir: str, station_name: str) -> None:
347347
"""Check validity of raw_dir content.
348348
349349
Steps:
350-
1. Check that 'raw_dir' is a valid directory path
351-
2. Check that 'raw_dir' follows the expect directory structure
352-
3. Check that each station_name directory contains data
353-
4. Check that for each station_name the mandatory metadata.yml is specified.
354-
5. Check that for each station_name the mandatory issue.yml is specified.
350+
351+
1. Check that ``raw_dir`` is a valid directory path
352+
353+
2. Check that ``raw_dir`` follows the expect directory structure
354+
355+
3. Check that each ``station_name`` directory contains data
356+
357+
4. Check that for each station_name the mandatory ``metadata.yml`` is specified.
358+
359+
5. Check that for each station_name the mandatory ``issue.yml`` is specified.
355360
356361
Parameters
357362
----------
@@ -361,7 +366,7 @@ def check_raw_dir(raw_dir: str, station_name: str) -> None:
361366
Station name.
362367
verbose : bool, optional
363368
Whether to verbose the processing.
364-
The default is False.
369+
The default is ``False``.
365370
366371
"""
367372
# Ensure valid path format
@@ -415,12 +420,12 @@ def check_raw_dir(raw_dir: str, station_name: str) -> None:
415420

416421

417422
def check_processed_dir(processed_dir):
418-
"""Check input, format and validity of the 'processed_dir' directory path.
423+
"""Check input, format and validity of the ``processed_dir`` directory path.
419424
420425
Parameters
421426
----------
422427
processed_dir : str
423-
Path to the campaign directory in the 'DISDRODB/Processed directory tree
428+
Path to the campaign directory in the ``DISDRODB/Processed`` directory tree
424429
425430
Returns
426431
-------

disdrodb/api/create_directories.py

+18-15
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
#### DISDRODB Products directories
6161
def _check_data_source_consistency(raw_dir: str, processed_dir: str) -> str:
62-
"""Check that 'raw_dir' and 'processed_dir' have same data_source.
62+
"""Check that ``raw_dir`` and ``processed_dir`` have same ``data_source``.
6363
6464
Parameters
6565
----------
@@ -71,12 +71,12 @@ def _check_data_source_consistency(raw_dir: str, processed_dir: str) -> str:
7171
Returns
7272
-------
7373
str
74-
data_source in capital letter.
74+
``data_source`` in capital letter.
7575
7676
Raises
7777
------
7878
ValueError
79-
Error if the data_source of the two directory paths does not match.
79+
Error if the ``data_source`` of the two directory paths does not match.
8080
"""
8181
raw_data_source = infer_data_source_from_path(raw_dir)
8282
processed_data_source = infer_data_source_from_path(processed_dir)
@@ -88,7 +88,7 @@ def _check_data_source_consistency(raw_dir: str, processed_dir: str) -> str:
8888

8989

9090
def _check_campaign_name_consistency(raw_dir: str, processed_dir: str) -> str:
91-
"""Check that 'raw_dir' and 'processed_dir' have same campaign_name.
91+
"""Check that ``raw_dir`` and ``processed_dir`` have same campaign_name.
9292
9393
Parameters
9494
----------
@@ -100,12 +100,12 @@ def _check_campaign_name_consistency(raw_dir: str, processed_dir: str) -> str:
100100
Returns
101101
-------
102102
str
103-
Campaign name in capital letter.
103+
``campaign_name`` in capital letter.
104104
105105
Raises
106106
------
107107
ValueError
108-
Error if the campaign_name of the two directory paths does not match.
108+
Error if the ``campaign_name`` of the two directory paths does not match.
109109
"""
110110
raw_campaign_name = infer_campaign_name_from_path(raw_dir)
111111
processed_campaign_name = infer_campaign_name_from_path(processed_dir)
@@ -119,7 +119,7 @@ def _check_campaign_name_consistency(raw_dir: str, processed_dir: str) -> str:
119119
def _copy_station_metadata(
120120
data_source: str, campaign_name: str, station_name: str, base_dir: str = None, check_validity: bool = False
121121
) -> None:
122-
"""Copy the station YAML file from the raw_dir/metadata into processed_dir/metadata
122+
"""Copy the station YAML file from the ``raw_dir/metadata`` into ``processed_dir/metadata``.
123123
124124
Parameters
125125
----------
@@ -163,12 +163,12 @@ def _check_pre_existing_station_data(
163163
):
164164
"""Check for pre-existing station data.
165165
166-
- If force=True, remove all data inside the station directory.
167-
- If force=False, raise error.
168-
169-
NOTE: force=False behaviour could be changed to enable updating of missing files.
170-
This would require also adding code to check whether a downstream file already exist.
166+
- If ``force=True``, remove all data inside the station directory.
167+
- If ``force=False``, raise error.
171168
"""
169+
# NOTE: ``force=False`` behaviour could be changed to enable updating of missing files.
170+
# This would require also adding code to check whether a downstream file already exist.
171+
172172
# Check if there are available data
173173
available_data = has_available_station_files(
174174
product=product,
@@ -211,8 +211,11 @@ def create_l0_directory_structure(
211211
):
212212
"""Create directory structure for the first L0 DISDRODB product.
213213
214-
If the input data are raw text files --> product = "L0A" (run_l0a)
215-
If the input data are raw netCDF files --> product = "L0B" (run_l0b_nc)
214+
If the input data are raw text files, use ``product = "L0A"``
215+
If the input data are raw netCDF files, use ``product = "L0B"``
216+
217+
``product = "L0A"`` will call ``run_l0a``.
218+
``product = "L0B"`` will call ``run_l0b_nc``.
216219
"""
217220
# Check inputs
218221
raw_dir = check_raw_dir(raw_dir=raw_dir, station_name=station_name)
@@ -315,7 +318,7 @@ def _create_station_directories(
315318
product="RAW",
316319
base_dir=None,
317320
):
318-
"""Create the /metadata, /issue and /data/<station_name> directories of a station."""
321+
"""Create the ``/metadata``, ``/issue`` and ``/data/<station_name>`` directories of a station."""
319322
# Create directory structure
320323
_ = create_station_directory(
321324
base_dir=base_dir,

0 commit comments

Comments
 (0)