feat(docs): publish Client libraries help to python reference documen…#16575
Open
bshaffer wants to merge 6 commits intogoogleapis:mainfrom
Open
feat(docs): publish Client libraries help to python reference documen…#16575bshaffer wants to merge 6 commits intogoogleapis:mainfrom
bshaffer wants to merge 6 commits intogoogleapis:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds a new help package for documentation, including a DocFX helper script and Nox configuration. Key feedback includes concerns about shadowing the built-in help() function, unused imports and parameters in docfx_helper.py, and the need for explicit encoding during file operations. Improvements were also suggested for argument parsing and the removal of legacy Python 2 imports.
| python_requires=">=3.10", | ||
| include_package_data=True, | ||
| zip_safe=False, | ||
| packages=["help"], |
Contributor
There was a problem hiding this comment.
packages/help/docfx_helper.py
Outdated
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import os |
Contributor
packages/help/docfx_helper.py
Outdated
Comment on lines
+22
to
+24
| def build_docfx(current_dir, repo_root, docs_map): | ||
| current_dir = pathlib.Path(current_dir) | ||
| repo_root = pathlib.Path(repo_root) |
Contributor
| 'gfm', | ||
| format='rst' | ||
| ) | ||
| (output_dir / target_filename).write_text(output) |
Contributor
packages/help/docfx_helper.py
Outdated
Comment on lines
+75
to
+76
| with open(toc_path, "w") as f: | ||
| yaml.dump(toc, f, default_flow_style=False) |
Contributor
There was a problem hiding this comment.
To ensure the generated toc.yaml is stable and predictable, programmatically sort the dictionary before dumping it. Also, specify the encoding when opening the file for writing to avoid platform-dependent defaults.
Suggested change
| with open(toc_path, "w") as f: | |
| yaml.dump(toc, f, default_flow_style=False) | |
| with open(toc_path, "w", encoding="utf-8") as f: | |
| yaml.dump(dict(sorted(toc.items())), f, default_flow_style=False) |
References
- To ensure dictionary keys remain sorted without manual effort, programmatically sort the dictionary before returning it (e.g., using dict(sorted(metadata.items()))) instead of relying on manual ordering in the code.
packages/help/docfx_helper.py
Outdated
Comment on lines
+83
to
+87
| curr = sys.argv[1] | ||
| root = sys.argv[2] | ||
| d_map = {} | ||
| for i in range(3, len(sys.argv), 2): | ||
| d_map[sys.argv[i]] = sys.argv[i+1] |
Contributor
packages/help/noxfile.py
Outdated
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from __future__ import absolute_import |
Contributor
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
b/450298584
Publishes documentation to https://cloud.google.com/python/docs/reference under "Client libraries help".
This currently only contains the
README.rstcontents from the root of this repo. We will expand this to add more once we've confirmed this is deploying as expected.