From 2e85c10b5153defd9d654c34b57e7e9263361959 Mon Sep 17 00:00:00 2001 From: Alexa B Date: Thu, 20 Aug 2020 17:14:03 -0400 Subject: [PATCH] fix(python_samples): README link fix, enforce samples=True (#732) Updated sources link to direct to specified product's repo, enforced `kwargs["metadata"]["samples"] = True` every time `py_samples()` is run, as it's a given if the function is called and shouldn't have to be specified from the user side. Oh also the wording was slightly redundant. TLDR, Just some wording fixes and a one line edit --- synthtool/gcp/common.py | 3 +++ synthtool/gcp/templates/python_samples/README.md | 7 +++---- tests/test_sample_templates.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/synthtool/gcp/common.py b/synthtool/gcp/common.py index 255c10320..9702a0d21 100644 --- a/synthtool/gcp/common.py +++ b/synthtool/gcp/common.py @@ -90,6 +90,9 @@ def py_samples(self, **kwargs) -> List[Path]: ] ) + # ensure samples will generate + kwargs["metadata"]["samples"] = True + # determine if in client lib and set custom root sample dir if specified, else None in_client_library = Path("samples").exists() sample_project_dir = kwargs["metadata"]["repo"].get("sample_project_dir") diff --git a/synthtool/gcp/templates/python_samples/README.md b/synthtool/gcp/templates/python_samples/README.md index 469c9938f..faae7460c 100644 --- a/synthtool/gcp/templates/python_samples/README.md +++ b/synthtool/gcp/templates/python_samples/README.md @@ -3,7 +3,7 @@ ## Python Samples for {{ metadata['repo']['name_pretty'] }} -This directory contains samples for {{ metadata['repo']['name_pretty'] }}, which may be used as a refererence for how to use {{ metadata['repo']['name_pretty'] }}. {% if metadata['repo']['custom_content'] is defined %} +This directory contains samples for {{ metadata['repo']['name_pretty'] }}, which may be used as a refererence for how to use this product. {% if metadata['repo']['custom_content'] is defined %} {{ metadata['repo']['custom_content']}}{% endif %}{% if metadata['repo']['samples']|length %} Samples, quickstarts, and other documentation are available at cloud.google.com. {% for sample in range(metadata['repo']['samples']|length) %} @@ -37,15 +37,14 @@ To run this sample: {% if metadata['repo']|length %}{% if metadata['repo']['client_library'] %} These samples use the [Google Cloud Client Library for Python][client_library_python].{% endif %} You can read the documentation for more details on API usage and use GitHub -to [browse the source][source] and [report issues][issues].{% endif %} +to browse the source and [report issues][issues].{% endif %} ### Contributing -For [contributing guidelines][contrib_guide], the [Python style guide][py_style], and more information on prerequisite steps to contribute, view the source code at {{ metadata['repo']['repo'] }}. +View the [contributing guidelines][contrib_guide], the [Python style guide][py_style] for more information. [authentication]: https://cloud.google.com/docs/authentication/getting-started [enable_billing]:https://cloud.google.com/apis/docs/getting-started#enabling_billing [client_library_python]: https://googlecloudplatform.github.io/google-cloud-python/ -[source]: https://github.com/GoogleCloudPlatform/google-cloud-python [issues]: https://github.com/GoogleCloudPlatform/google-cloud-python/issues [contrib_guide]: https://github.com/googleapis/google-cloud-python/blob/master/CONTRIBUTING.rst [py_style]: http://google.github.io/styleguide/pyguide.html diff --git a/tests/test_sample_templates.py b/tests/test_sample_templates.py index e39a2ba88..e34238003 100644 --- a/tests/test_sample_templates.py +++ b/tests/test_sample_templates.py @@ -63,7 +63,7 @@ def test_samples_footer(): assert "Google Cloud Client Library for Python" in result assert "Python style guide" in result assert ( - 'googleapis/python-storage' + 'browse the source' in result )