Get the docs for a given python object. Args: py_object: A python object to retrieve the docs for (class, function/method, or module). Returns: The docstring, or the empty string if no docstring was found.
(py_object)
| 125 | |
| 126 | |
| 127 | def _get_raw_docstring(py_object): |
| 128 | """Get the docs for a given python object. |
| 129 | |
| 130 | Args: |
| 131 | py_object: A python object to retrieve the docs for (class, function/method, |
| 132 | or module). |
| 133 | |
| 134 | Returns: |
| 135 | The docstring, or the empty string if no docstring was found. |
| 136 | """ |
| 137 | # For object instances, tf_inspect.getdoc does give us the docstring of their |
| 138 | # type, which is not what we want. Only return the docstring if it is useful. |
| 139 | if (tf_inspect.isclass(py_object) or tf_inspect.ismethod(py_object) or |
| 140 | tf_inspect.isfunction(py_object) or tf_inspect.ismodule(py_object) or |
| 141 | isinstance(py_object, property)): |
| 142 | return tf_inspect.getdoc(py_object) or '' |
| 143 | else: |
| 144 | return '' |
| 145 | |
| 146 | |
| 147 | # A regular expression for capturing a @{symbol} reference. |
no outgoing calls
no test coverage detected