Skip to content

feat(docs): publish Client libraries help to python reference documen…#16575

Open
bshaffer wants to merge 6 commits intogoogleapis:mainfrom
bshaffer:client-libraries-help
Open

feat(docs): publish Client libraries help to python reference documen…#16575
bshaffer wants to merge 6 commits intogoogleapis:mainfrom
bshaffer:client-libraries-help

Conversation

@bshaffer
Copy link
Copy Markdown
Contributor

@bshaffer bshaffer commented Apr 7, 2026

b/450298584

Publishes documentation to https://cloud.google.com/python/docs/reference under "Client libraries help".

This currently only contains the README.rst contents from the root of this repo. We will expand this to add more once we've confirmed this is deploying as expected.

@bshaffer bshaffer requested review from a team as code owners April 7, 2026 23:23
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Naming the package help shadows the Python built-in help() function. This can lead to confusion and subtle bugs when users try to use the built-in help system after importing this package. It is strongly recommended to use a more specific name, such as google_cloud_help.

# See the License for the specific language governing permissions and
# limitations under the License.

import os
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The os module is imported but not used in this file. It can be safely removed to keep the code clean.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The repo_root parameter is accepted and converted to a Path object but is never used within the build_docfx function. If it's not intended for future use, it should be removed from the function signature and body.

'gfm',
format='rst'
)
(output_dir / target_filename).write_text(output)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When writing text to a file using write_text, it is recommended to specify the encoding explicitly (e.g., encoding="utf-8") to ensure consistent behavior across different platforms.

(output_dir / target_filename).write_text(output, encoding="utf-8")

Comment on lines +75 to +76
with open(toc_path, "w") as f:
yaml.dump(toc, f, default_flow_style=False)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. 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.

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]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The manual argument parsing is brittle. If an odd number of arguments is provided for the title/source pairs, the script will crash with an IndexError. Consider using argparse for more robust argument handling and validation.

# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The from future import absolute_import statement is a legacy from Python 2 compatibility and is no longer necessary in Python 3.10+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant