-
Notifications
You must be signed in to change notification settings - Fork 100
chore(python): autogenerate docs/index.rst #1114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
c0af3ab
chore(python): autogenerate docs/index.rst
parthea bdee7a8
set default path to owl-bot-staging
parthea 4bc1061
Merge branch 'master' into add-docs-index-rst-to-template
parthea fb23307
optimize code using glob
parthea 89e2bc4
move the default_version to the front of the list
parthea 9a6f82f
Drop redundant default_version argument
parthea 52541cc
remove unused imports
parthea 3fe0d5b
read default_version from .repo-metadata.json
parthea 83bd511
exclude docs/index.rst if default_version is not specified
parthea da5be6c
check for versions kwarg
parthea cf8a2bc
only generate docs/index.rst if default_version is specified
parthea 55e74f8
lint
parthea 77d8cf0
Merge branch 'master' into add-docs-index-rst-to-template
parthea 483c6d0
fix build
parthea 52de68a
fix build
parthea ecf2d07
Merge branch 'master' into add-docs-index-rst-to-template
parthea 5910c24
Merge branch 'master' into add-docs-index-rst-to-template
parthea d068abb
Merge branch 'master' into add-docs-index-rst-to-template
parthea 8af8e95
consolidate the duplicated detect_versions function
parthea d66ea79
remove unused import
parthea b8c20e0
remove unused imports
parthea 4a9688f
Merge branch 'master' into add-docs-index-rst-to-template
parthea fc607c0
update comments
parthea b992238
remove unused import
parthea c79fc51
run black
parthea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| .. include:: README.rst | ||
|
|
||
| .. include:: multiprocessing.rst | ||
| {% if versions|length > 1 %} | ||
| This package includes clients for multiple versions of {{ metadata['repo']['name_pretty'] }}. | ||
| By default, you will get version ``{{ versions | first }}``. | ||
| {% endif %} | ||
| {% for version in versions %} | ||
|
parthea marked this conversation as resolved.
|
||
| API Reference | ||
| ------------- | ||
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| {{ version }}/services | ||
| {{ version }}/types | ||
| {% endfor %} | ||
| {%- if migration_guide_version %} | ||
| Migration Guide | ||
| --------------- | ||
|
|
||
| See the guide below for instructions on migrating to the {{ migration_guide_version }} release of this library. | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| UPGRADING | ||
| {% endif %} | ||
| Changelog | ||
| --------- | ||
|
|
||
| For a list of all ``{{ metadata['repo']['distribution_name'] }}`` releases: | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| changelog | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import json | ||
| import re | ||
| import sys | ||
| from pathlib import Path | ||
|
|
@@ -93,6 +94,50 @@ def _get_sample_readme_metadata(sample_dir: Path) -> dict: | |
| return sample_metadata | ||
|
|
||
|
|
||
| def detect_versions(path: str = "./google/cloud") -> List[str]: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How hard would it be for us to pull this into a common file, if the logic is identical?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Please could you take another look? |
||
| """ | ||
| Detects the versions a library has, based on distinct folders | ||
| within path. This is based on the fact that our GAPIC libraries are | ||
| structured as follows: | ||
|
|
||
| google/cloud/*_v1 | ||
| google/cloud/*_v1beta | ||
| google/cloud/*_v1alpha | ||
|
|
||
| With folder names mapping directly to versions. | ||
|
|
||
| Returns: a list of the subdirectories; for the example above: | ||
| ['*_v1', '*_v1alpha', '*_v1beta'] | ||
| The subdirectory with the same suffix as the default_version | ||
| specified in .repo-metadata.json will be first in the list. The | ||
| remaining elements will be sorted alphabetically. | ||
| """ | ||
|
|
||
| versions = [] | ||
|
|
||
| # Get the default_version from .repo-metadata.json | ||
| default_version = json.load(open(".repo-metadata.json", "rt")).get( | ||
| "default_version" | ||
| ) | ||
|
|
||
| # Sort the sub directories alphabetically | ||
| sub_dirs = sorted([p.name for p in Path(path).glob("**/*_v[1-9]*")]) | ||
|
|
||
| if default_version and sub_dirs: | ||
| # The subdirectory with the same suffix as the default_version | ||
| # specified in .repo-metadata.json will be the default client. | ||
| default_client = next( | ||
| iter([d for d in sub_dirs if d.endswith(default_version)]), None | ||
| ) | ||
| if default_client: | ||
| # The default_client will be first in the list. | ||
| # The remaining elements will be sorted alphabetically. | ||
| versions = [default_client] + [ | ||
| d for d in sub_dirs if not d.endswith(default_version) | ||
| ] | ||
| return versions | ||
|
|
||
|
|
||
| def py_samples(*, root: PathOrStr = None, skip_readmes: bool = False) -> None: | ||
| """ | ||
| Find all samples projects and render templates. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.