Skip to content
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

DOCS-2506: Add raises to write_markdown #3043

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/update_sdk_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,10 +1171,15 @@ def parse(type, names):
## and new empty dictionary this_method_raises_dict to house all errors raised
## keys for this method, to allow for multiple errors raised:
this_method_dict["raises"] = {}
this_method_raises_dict = {}

## Iterate through all <strong> tags in method tag:
for strong_tag in tag.find_all('strong'):

## Create new empty dictionary this_method_raises_dict to house all raises (errors)
## keys for this method, to allow for multiple errors raised. Also resets the
## previous error's data when looping through multiple errors:
this_method_raises_dict = {}

## Determine if this <strong> tag is preceded by a <dt> tag containing the text "Raises". Otherwise omit.
## METHODOLOGY: Find previous <dt> tag before matching <strong>param_name</strong> tag which contains this data.
## Determining by <strong> tags allows matching parameters regardless whether they are
Expand Down Expand Up @@ -1824,6 +1829,23 @@ def write_markdown(type, names, methods):
else:
output_file.write("- None.\n")

if 'raises' in methods['python'][type][resource][py_method_name]:
output_file.write('\n**Raises:**\n\n')

raises_object = methods['python'][type][resource][py_method_name]["raises"]
raises_types = methods['python'][type][resource][py_method_name]["raises"].keys()
for raises_type in raises_types:
output_file.write(f"- ({raises_type})")
if "raises_description" in raises_object[raises_type]:
raises_description= raises_object[raises_type]["raises_description"]
## Add a trailing period if it is missing:
if not raises_description.endswith('.'):
raises_description = raises_description + '.'

output_file.write(f": {raises_description}\n")
else:
output_file.write("\n")

## If the method has a code sample, print it here:
if 'code_sample' in methods['python'][type][resource][py_method_name]:

Expand Down
Loading
Loading