generated from jCloud/repository-template
Add feature to parse Python docstrings
This commit is contained in:
@@ -12,10 +12,19 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from enum import Enum
|
||||
import docstring_parser
|
||||
|
||||
__all__ = [
|
||||
'PythonDocstringStyle',
|
||||
'PythonDocstring'
|
||||
]
|
||||
|
||||
class PythonDocstringStyle(Enum):
|
||||
SPHINX = 'sphinx'
|
||||
NUMPY = 'numpy'
|
||||
GOOGLE = 'google'
|
||||
|
||||
class PythonDocstring:
|
||||
'''
|
||||
Represents a Python docstring.
|
||||
@@ -33,4 +42,14 @@ class PythonDocstring:
|
||||
def __eq__(self, value) -> bool:
|
||||
if not isinstance(value, type(self)):
|
||||
return False
|
||||
return self.docstring == value.docstring
|
||||
return self.docstring == value.docstring
|
||||
|
||||
def parse(self) -> docstring_parser.Docstring:
|
||||
'''
|
||||
Parses the docstring.
|
||||
|
||||
:return: The parsed docstring.
|
||||
:rtype: docstring_parser.Docstring
|
||||
'''
|
||||
|
||||
return docstring_parser.parse(self.docstring)
|
||||
Reference in New Issue
Block a user