From 0bab60fe1799dd916172c4625172c52f68d85a7b Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Thu, 24 Oct 2019 13:21:27 -0700 Subject: [PATCH 1/2] docs: remove v2 sample in README --- translate/README.rst | 39 +-------------------------------------- translate/docs/index.rst | 8 -------- translate/docs/usage.rst | 2 +- translate/docs/v2.rst | 1 + 4 files changed, 3 insertions(+), 47 deletions(-) diff --git a/translate/README.rst b/translate/README.rst index af398ee4e3a0..1ca13ab74749 100644 --- a/translate/README.rst +++ b/translate/README.rst @@ -81,41 +81,4 @@ Windows pip install virtualenv virtualenv \Scripts\activate - \Scripts\pip.exe install google-cloud-translate - - -Example Usage -~~~~~~~~~~~~~ - -.. code-block:: python - - >>> from google.cloud import translate - >>> client = translate.Client() - >>> client.get_languages() - [ - { - 'language': 'af', - 'name': 'Afrikaans', - }, - ... - ] - >>> client.detect_language(['Me llamo', 'I am']) - [ - { - 'confidence': 0.25830904, - 'input': 'Me llamo', - 'language': 'es', - }, { - 'confidence': 0.17112699, - 'input': 'I am', - 'language': 'en', - }, - ] - >>> from google.cloud import translate - >>> client = translate.Client() - >>> client.translate('koszula') - { - 'translatedText': 'shirt', - 'detectedSourceLanguage': 'pl', - 'input': 'koszula', - } + \Scripts\pip.exe install google-cloud-translate \ No newline at end of file diff --git a/translate/docs/index.rst b/translate/docs/index.rst index 604ac0485f06..b5d2405e2f47 100644 --- a/translate/docs/index.rst +++ b/translate/docs/index.rst @@ -1,13 +1,5 @@ .. include:: README.rst -v2 Usage Guide --------------------- -.. toctree:: - :maxdepth: 2 - - usage - - API Reference ------------- diff --git a/translate/docs/usage.rst b/translate/docs/usage.rst index 5fc2767c06e6..5bd42c889399 100644 --- a/translate/docs/usage.rst +++ b/translate/docs/usage.rst @@ -1,4 +1,4 @@ -Using the Translate Client +Translation v2 Usage Guide -------------------------- To create a client: diff --git a/translate/docs/v2.rst b/translate/docs/v2.rst index d8e7f23789bb..0e056c8ff63b 100644 --- a/translate/docs/v2.rst +++ b/translate/docs/v2.rst @@ -5,3 +5,4 @@ v2 :maxdepth: 2 client + usage From 63e9301c51712fc50986f7933a7689f23d5fe441 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Fri, 25 Oct 2019 09:34:34 -0700 Subject: [PATCH 2/2] docs: fix imports in usage.rst --- translate/docs/usage.rst | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/translate/docs/usage.rst b/translate/docs/usage.rst index 5bd42c889399..c6ee312c0cac 100644 --- a/translate/docs/usage.rst +++ b/translate/docs/usage.rst @@ -5,8 +5,8 @@ To create a client: .. doctest:: - >>> from google.cloud import translate - >>> client = translate.Client() + >>> from google.cloud import translate_v2 + >>> client = translate_v2.Client() By default, the client targets English when doing detections and translations, but a non-default value can be used as @@ -14,21 +14,21 @@ well: .. doctest:: - >>> from google.cloud import translate - >>> client = translate.Client(target_language='es') + >>> from google.cloud import translate_v2 + >>> client = translate_v2.Client(target_language='es') -The Google Cloud Translation API has three supported methods, and they +The Google Cloud Translation v2 API has three supported methods, and they map to three methods on a client: -:meth:`~google.cloud.translate.client.Client.get_languages`, -:meth:`~google.cloud.translate.client.Client.detect_language` and -:meth:`~google.cloud.translate.client.Client.translate`. +:meth:`~google.cloud.translate_v2.client.Client.get_languages`, +:meth:`~google.cloud.translate_v2.client.Client.detect_language` and +:meth:`~google.cloud.translate_v2.client.Client.translate`. To get a list of languages supported by the Google Cloud Translation API .. doctest:: - >>> from google.cloud import translate - >>> client = translate.Client() + >>> from google.cloud import translate_v2 + >>> client = translate_v2.Client() >>> client.get_languages() [ { @@ -42,8 +42,8 @@ To detect the language that some given text is written in: .. doctest:: - >>> from google.cloud import translate - >>> client = translate.Client() + >>> from google.cloud import translate_v2 + >>> client = translate_v2.Client() >>> client.detect_language(['Me llamo', 'I am']) [ { @@ -68,8 +68,8 @@ the source language: .. doctest:: - >>> from google.cloud import translate - >>> client = translate.Client() + >>> from google.cloud import translate_v2 + >>> client = translate_v2.Client() >>> client.translate('koszula') { 'translatedText': 'shirt', @@ -81,8 +81,8 @@ If the source language is known: .. doctest:: - >>> from google.cloud import translate - >>> client = translate.Client() + >>> from google.cloud import translate_v2 + >>> client = translate_v2.Client() >>> client.translate('camisa', source_language='es') { 'translatedText': 'shirt', @@ -93,8 +93,8 @@ or to use a non-default target language: .. doctest:: - >>> from google.cloud import translate - >>> client = translate.Client() + >>> from google.cloud import translate_v2 + >>> client = translate_v2.Client() >>> client.translate(['Me llamo Jeff', 'My name is Jeff'], ... target_language='de') [