Skip to content

Commit a0ca62b

Browse files
test get_doc_string.
1 parent ec05b7e commit a0ca62b

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

tabpy/tabpy_tools/client.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,6 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi
380380
description = obj.__doc__.strip() or "" if isinstance(obj.__doc__, str) else ""
381381

382382
endpoint_object = CustomQueryObject(query=obj, description=description,)
383-
384-
docstring = "-- no docstring found in query function --"
385-
if sys.platform != "win32":
386-
docstring = inspect.getdoc(obj) or "-- no docstring found in query function --"
387383

388384
return {
389385
"name": name,
@@ -395,7 +391,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_publi
395391
"methods": endpoint_object.get_methods(),
396392
"required_files": [],
397393
"required_packages": [],
398-
"docstring": docstring,
394+
"docstring": endpoint_object.get_doc_string(),
399395
"schema": copy.copy(schema),
400396
"is_public": is_public,
401397
}

tabpy/tabpy_tools/custom_query_object.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import inspect
12
import logging
3+
import platform
4+
import sys
25
from .query_object import QueryObject as _QueryObject
36

47

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

7275
def get_doc_string(self):
7376
"""Get doc string from customized query"""
74-
if self.custom_query.__doc__ is not None:
75-
return self.custom_query.__doc__
76-
else:
77-
return "-- no docstring found in query function --"
77+
default_docstring = "-- no docstring found in query function --"
78+
return default_docstring
79+
# Docstring parsing not working on Windows.
80+
# if platform.system() == "Windows":
81+
# return default_docstring
82+
# else:
83+
# return inspect.getdoc(self.custom_query) or default_docstring
7884

7985
def get_methods(self):
8086
return [self.get_query_method()]

0 commit comments

Comments
 (0)