Skip to content

Commit

Permalink
chore(docs): add async note to docs (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche authored Aug 12, 2024
1 parent 678a06c commit a91fcb5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ remaining exclusively in the existing synchronous client.
Feedback and bug reports are welcome at [email protected],
or through the Github `issue tracker`_.


.. note::

It is generally not recommended to use the async client in an otherwise synchronous codebase. To make use of asyncio's
performance benefits, the codebase should be designed to be async from the ground up.


.. _issue tracker: https://github.com/googleapis/python-bigtable/issues


Quick Start
-----------

Expand Down
6 changes: 6 additions & 0 deletions docs/async_data_client/async_data_client.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Bigtable Data Client Async
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note::

It is generally not recommended to use the async client in an otherwise synchronous codebase. To make use of asyncio's
performance benefits, the codebase should be designed to be async from the ground up.


.. autoclass:: google.cloud.bigtable.data._async.client.BigtableDataClientAsync
:members:
:show-inheritance:
5 changes: 5 additions & 0 deletions docs/async_data_client/async_data_table.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Table Async
~~~~~~~~~~~

.. note::

It is generally not recommended to use the async client in an otherwise synchronous codebase. To make use of asyncio's
performance benefits, the codebase should be designed to be async from the ground up.

.. autoclass:: google.cloud.bigtable.data._async.client.TableAsync
:members:
:show-inheritance:
24 changes: 20 additions & 4 deletions docs/scripts/patch_devsite_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,31 @@ def __init__(self, dir_name, index_file_name):
index_file_path = os.path.join(dir_name, index_file_name)
# find set of files referenced by the index file
with open(index_file_path, "r") as f:
self.title = f.readline().strip()
self.title = None
in_toc = False
self.items = []
for line in f:
# ignore empty lines
if not line.strip():
continue
# add files explictly included in the toc
if line.startswith(".. include::"):
file_base = os.path.splitext(line.split("::")[1].strip())[0]
self.items.append(
self.extract_toc_entry(
file_base, file_title=file_base.capitalize()
)
)
continue
if line.startswith(".. toctree::"):
in_toc = True
continue
# ignore directives
if ":" in line:
continue
# set tile as first line with no directive
if self.title is None:
self.title = line.strip()
if not in_toc:
continue
# bail when toc indented block is done
Expand All @@ -109,14 +121,16 @@ def __init__(self, dir_name, index_file_name):
# extract entries
self.items.append(self.extract_toc_entry(line.strip()))

def extract_toc_entry(self, file_name):
def extract_toc_entry(self, file_name, file_title=None):
"""
Given the name of a file, extract the title and href for the toc entry,
and return as a dictionary
"""
# load the file to get the title
with open(f"{self.dir_name}/{file_name}.rst", "r") as f2:
file_title = f2.readline().strip()
if file_title is None:
# use first line as title if not provided
file_title = f2.readline().strip()
return {"name": file_title, "href": f"{file_name}.md"}

def to_dict(self):
Expand All @@ -143,7 +157,9 @@ def validate_toc(toc_file_path, expected_section_list, added_sections):
current_toc = yaml.safe_load(open(toc_file_path, "r"))
# make sure the set of sections matches what we expect
found_sections = [d["name"] for d in current_toc[0]["items"]]
assert found_sections == expected_section_list
assert (
found_sections == expected_section_list
), f"Expected {expected_section_list}, found {found_sections}"
# make sure each customs ection is in the toc
for section in added_sections:
assert section.title in found_sections
Expand Down

0 comments on commit a91fcb5

Please sign in to comment.