From af4a172193cc1fe3e34aea07cebc88c4c858635c Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Tue, 29 Oct 2019 16:48:51 -0700 Subject: [PATCH] docs(translation): fix v2 imports, remove v2 sample in README (#9536) --- packages/google-cloud-translate/README.rst | 39 +------------------ .../google-cloud-translate/docs/index.rst | 8 ---- .../google-cloud-translate/docs/usage.rst | 38 +++++++++--------- packages/google-cloud-translate/docs/v2.rst | 1 + 4 files changed, 21 insertions(+), 65 deletions(-) diff --git a/packages/google-cloud-translate/README.rst b/packages/google-cloud-translate/README.rst index af398ee4e3a0..1ca13ab74749 100644 --- a/packages/google-cloud-translate/README.rst +++ b/packages/google-cloud-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/packages/google-cloud-translate/docs/index.rst b/packages/google-cloud-translate/docs/index.rst index 604ac0485f06..b5d2405e2f47 100644 --- a/packages/google-cloud-translate/docs/index.rst +++ b/packages/google-cloud-translate/docs/index.rst @@ -1,13 +1,5 @@ .. include:: README.rst -v2 Usage Guide --------------------- -.. toctree:: - :maxdepth: 2 - - usage - - API Reference ------------- diff --git a/packages/google-cloud-translate/docs/usage.rst b/packages/google-cloud-translate/docs/usage.rst index 5fc2767c06e6..c6ee312c0cac 100644 --- a/packages/google-cloud-translate/docs/usage.rst +++ b/packages/google-cloud-translate/docs/usage.rst @@ -1,12 +1,12 @@ -Using the Translate Client +Translation v2 Usage Guide -------------------------- 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') [ diff --git a/packages/google-cloud-translate/docs/v2.rst b/packages/google-cloud-translate/docs/v2.rst index d8e7f23789bb..0e056c8ff63b 100644 --- a/packages/google-cloud-translate/docs/v2.rst +++ b/packages/google-cloud-translate/docs/v2.rst @@ -5,3 +5,4 @@ v2 :maxdepth: 2 client + usage