Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bdacdc4

Browse files
committed
release 008
1 parent 833683a commit bdacdc4

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

‎HISTORY.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,13 @@ Release data: Jul 5, 2023
8585
* Update all class extractor format (using dict instead of list)
8686
* Fix missing identifier, parameter in C, C#, Java parser
8787
* Implement CLI
88+
89+
Version 0.0.8
90+
=============
91+
Release data: Aug 17, 2023
92+
93+
* Update format codetext_cli
94+
* Update PythonParser: Handle class definitions with empty argument list class ABC()
95+
* Add Javascript undeclared functions
96+
* Add PHP interface
97+
* Add Ruby actions with block parameters

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "codetext"
7-
version = "0.0.7"
7+
version = "0.0.8"
88
authors = [
99
{ name="Dung Manh Nguyen", email="dungnm.workspace@gmail.com" },
1010
]

‎src/codetext/codetext_cli.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def parse_file(file_path: str, language: str = None, verbose: bool = False) -> L
5656
method_list = parser.get_function_list(_cls)
5757
for method in method_list:
5858
method_info = parser.get_function_metadata(method)
59+
method_info['code'] = get_node_text(method)
5960
cls_method.append(method_info)
6061

6162
cls_info["method"] = cls_method
@@ -88,7 +89,8 @@ def print_result(res: Dict, file_name: str = "no_name_file"):
8889

8990
# ========= Print class & method =========
9091
cls_headers = ["#", "Class", "Arguments"]
91-
cls_method_headers = ["#", "Method name", "Paramters", "Type", "Return type"]
92+
cls_method_headers = ["#", "Method name", "Paramters",
93+
"Type", "Return type", "Throws"]
9294
cls_info = []
9395
method_info = {}
9496
for cls_idx, _cls in enumerate(res["class"]):
@@ -116,6 +118,11 @@ def print_result(res: Dict, file_name: str = "no_name_file"):
116118
if i <= 1 and method["return_type"] != "<not_specific>"
117119
else ""
118120
)
121+
sublist[5] = (
122+
method["throws"]
123+
if i <= 1 and "throws" in method.keys()
124+
else ""
125+
)
119126
_method_info.append(sublist)
120127

121128
method_info[file_name] = [_cls["identifier"], _method_info]

‎src/codetext/parser/java_parser.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ def get_function_metadata(function_node, blob: str = None) -> Dict[str, str]:
125125
metadata['identifier'] = get_node_text(child)
126126
elif child.type in return_kinds:
127127
metadata['return_type'] = get_node_text(child)
128+
elif child.type == 'throws':
129+
for subchild in child.children:
130+
if 'identifier' in subchild.type:
131+
metadata['throws'] = get_node_text(subchild)
128132
elif child.type == 'formal_parameters':
129133
param_list = get_node_by_kind(child, ['formal_parameter']) # speed_parameter
130134
for param in param_list:

‎src/codetext/utils/utils.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ def parse_code(raw_code: str, language: str='Auto', tree_sitter_path: str=None)
102102
parser.set_language(language)
103103

104104
if isinstance(raw_code, str):
105-
tree = parser.parse(bytes(raw_code, 'utf8'))
106-
return tree
105+
raw_code = bytes(raw_code, 'utf8')
106+
elif isinstance(raw_code, bytes):
107+
pass
107108
else:
108109
raise ValueError(f"Expect `str`, got {type(raw_code)}")
110+
tree = parser.parse(raw_code)
111+
return tree

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /