Skip to content

Commit

Permalink
fix(python_samples): README link fix, enforce samples=True (#732)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
runargs authored Aug 20, 2020
1 parent 9602086 commit 2e85c10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions synthtool/gcp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 3 additions & 4 deletions synthtool/gcp/templates/python_samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="{{ metadata['repo']['product_documentation'] }}">cloud.google.com</a>.
{% for sample in range(metadata['repo']['samples']|length) %}
Expand Down Expand Up @@ -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 <a href="https://github.com/{{ metadata['repo']['repo'] }}">browse the source</a> 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 <a href="https://github.com/{{ metadata['repo']['repo'] }}">{{ metadata['repo']['repo'] }}</a>.
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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sample_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_samples_footer():
assert "Google Cloud Client Library for Python" in result
assert "Python style guide" in result
assert (
'<a href="https://github.com/googleapis/python-storage">googleapis/python-storage</a>'
'<a href="https://github.com/googleapis/python-storage">browse the source</a>'
in result
)

Expand Down

0 comments on commit 2e85c10

Please sign in to comment.