Skip to content

Commit

Permalink
test get_doc_string.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeichikawasalesforce committed Nov 21, 2024
1 parent ec05b7e commit a0ca62b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 1 addition & 5 deletions tabpy/tabpy_tools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi
description = obj.__doc__.strip() or "" if isinstance(obj.__doc__, str) else ""

endpoint_object = CustomQueryObject(query=obj, description=description,)

docstring = "-- no docstring found in query function --"
if sys.platform != "win32":
docstring = inspect.getdoc(obj) or "-- no docstring found in query function --"

return {
"name": name,
Expand All @@ -395,7 +391,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi
"methods": endpoint_object.get_methods(),
"required_files": [],
"required_packages": [],
"docstring": docstring,
"docstring": endpoint_object.get_doc_string(),
"schema": copy.copy(schema),
"is_public": is_public,
}
Expand Down
14 changes: 10 additions & 4 deletions tabpy/tabpy_tools/custom_query_object.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import inspect
import logging
import platform
import sys
from .query_object import QueryObject as _QueryObject


Expand Down Expand Up @@ -71,10 +74,13 @@ def query(self, *args, **kwargs):

def get_doc_string(self):
"""Get doc string from customized query"""
if self.custom_query.__doc__ is not None:
return self.custom_query.__doc__
else:
return "-- no docstring found in query function --"
default_docstring = "-- no docstring found in query function --"
return default_docstring
# Docstring parsing not working on Windows.
# if platform.system() == "Windows":
# return default_docstring
# else:
# return inspect.getdoc(self.custom_query) or default_docstring

def get_methods(self):
return [self.get_query_method()]
Expand Down

0 comments on commit a0ca62b

Please sign in to comment.