Skip to content

Commit f5de840

Browse files
krfrickeAmeerHajAli
authored andcommitted
[docs] Fix Deprecated annotation indentation (#31532)
Our Documentation build job currently returns errors like this: /ray/python/ray/air/checkpoint.py:docstring of ray.air.checkpoint.Checkpoint.from_object_ref:9: WARNING: Content block expected for the "warning" directive; none found. The reason for this is the Deprecated annotation that adds a warning block to the __doc__ property to be rendered in our documentation. The code is faulty: A misplaced newline character in the DEPRECATED message block removes the proper indentation: Returns: If called by a driver, this returns the job ID. If called in a task, return the job ID of the associated driver. .. warning:: DEPRECATED: This API is deprecated and may be removed in future Ray releases. Use get_job_id() instead Additionally, newline characters in the deprecation message are also not indented correctly: Returns: If called by a driver, this returns the job ID. If called in a task, return the job ID of the associated driver. .. warning:: DEPRECATED: This API is deprecated and may be removed in future Ray releases. Use get_job_id() instead This PR fixes both problems: Returns: If called by a driver, this returns the job ID. If called in a task, return the job ID of the associated driver. .. warning:: DEPRECATED: This API is deprecated and may be removed in future Ray releases. Use get_job_id() instead Signed-off-by: Kai Fricke <[email protected]>
1 parent 3e16345 commit f5de840

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python/ray/util/annotations.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def Deprecated(*args, **kwargs):
124124
return Deprecated()(args[0])
125125

126126
doc_message = (
127-
"\n DEPRECATED: This API is deprecated and may be removed "
127+
"**DEPRECATED**: This API is deprecated and may be removed "
128128
"in future Ray releases."
129129
)
130130
warning_message = (
@@ -179,10 +179,14 @@ def _append_doc(obj, *, message: str, directive: Optional[str] = None) -> str:
179179

180180
indent = _get_indent(obj.__doc__)
181181
obj.__doc__ += "\n\n"
182+
182183
if directive is not None:
183-
obj.__doc__ += f"{' ' * indent}.. {directive}::\n"
184+
obj.__doc__ += f"{' ' * indent}.. {directive}::\n\n"
185+
186+
message = message.replace("\n", "\n" + " " * (indent + 4))
184187
obj.__doc__ += f"{' ' * (indent + 4)}{message}"
185188
else:
189+
message = message.replace("\n", "\n" + " " * (indent + 4))
186190
obj.__doc__ += f"{' ' * indent}{message}"
187191
obj.__doc__ += f"\n{' ' * indent}"
188192

0 commit comments

Comments
 (0)