Skip to content

Commit d81a4e3

Browse files
author
The TensorFlow Datasets Authors
committed
Improve doc scripts.
PiperOrigin-RevId: 798156419
1 parent e6ab773 commit d81a4e3

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

tensorflow_datasets/scripts/documentation/build_community_catalog.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def to_namespace_overview(self) -> str:
168168
)
169169

170170
def to_details_markdown(self) -> str:
171-
""" "Markdown to be shown on the details page for the namespace."""
171+
"""Markdown to be shown on the details page for the namespace."""
172172
extra_links = self.format_extra_links(prefix='* ', infix='\n')
173173
details = self.templates.dataset_details_template.format(
174174
name=self.name,
@@ -194,9 +194,6 @@ def dataset_info_per_config(
194194

195195
def documentation(self, keep_short: bool = False) -> str:
196196
"""Returns detailed documentation for all configs of this dataset."""
197-
# TODO(weide): if e.g. the description contains markdown chars, then it
198-
# messes up the page. Try escaping backticks or using code blocks.
199-
# TODO(weide): how to format citation?
200197
header_template = '## {config_name}'
201198
template = textwrap.dedent("""
202199
Use the following command to load this dataset in TFDS:
@@ -207,9 +204,7 @@ def documentation(self, keep_short: bool = False) -> str:
207204
208205
* **Description**:
209206
210-
```
211207
{description}
212-
```
213208
214209
* **License**: {license}
215210
* **Version**: {version}
@@ -364,6 +359,7 @@ def _parse_dataset_info_proto(
364359
)
365360
)
366361

362+
version = None
367363
if isinstance(config['version'], dict):
368364
version = config['version']['version_str']
369365
elif isinstance(config['version'], str):

tensorflow_datasets/scripts/documentation/dataset_markdown_builder.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ def _list_versions(self, builder: tfds.core.DatasetBuilder):
222222
all_versions = set(tfds.core.Version(v) for v in all_versions)
223223
for v in sorted(all_versions): # List all available versions
224224
if v == builder.version: # Highlight the default version
225-
version_name = '**`{}`** (default)'.format(str(v))
225+
version_name = f'**`{v}`** (default)'
226226
else:
227-
version_name = '`{}`'.format(str(v))
227+
version_name = f'`{v}`'
228228
if (
229229
v in curr_versions # Filter versions only present in RELEASE_NOTES
230230
and self._nightly_doc_util
@@ -322,14 +322,14 @@ def _build_autocached_info(self, builder: tfds.core.DatasetBuilder):
322322
autocached_info_parts = []
323323
if always_cached:
324324
split_names_str = ', '.join(always_cached)
325-
autocached_info_parts.append('Yes ({})'.format(split_names_str))
325+
autocached_info_parts.append(f'Yes ({split_names_str})')
326326
if never_cached:
327327
split_names_str = ', '.join(never_cached)
328-
autocached_info_parts.append('No ({})'.format(split_names_str))
328+
autocached_info_parts.append(f'No ({split_names_str})')
329329
if unshuffle_cached:
330330
split_names_str = ', '.join(unshuffle_cached)
331331
autocached_info_parts.append(
332-
'Only when `shuffle_files=False` ({})'.format(split_names_str)
332+
f'Only when `shuffle_files=False` ({split_names_str})'
333333
)
334334
autocached_info = ', '.join(autocached_info_parts)
335335
return autocached_info
@@ -346,7 +346,7 @@ class SplitInfoSection(Section):
346346

347347
def _get_num_examples(self, split_info):
348348
if split_info.num_examples:
349-
return '{:,}'.format(split_info.num_examples)
349+
return f'{split_info.num_examples:,}'
350350
return 'Not computed'
351351

352352
def get_key(self, builder: tfds.core.DatasetBuilder):

0 commit comments

Comments
 (0)