Skip to content

Commit 15b0ac7

Browse files
committed
master: finish editing documentation
1 parent 0ea249b commit 15b0ac7

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

importify/interface.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212
DELIM = "."
1313

1414

15-
def json_serializable(x):
15+
def json_serializable(x: Any) -> bool:
16+
""" Check if x is json serializable
17+
18+
Args:
19+
x: any value
20+
21+
Returns:
22+
Return true if x is json serializable. Else, return False
23+
"""
1624
try:
1725
json.dumps(x)
1826
return True
@@ -21,6 +29,11 @@ def json_serializable(x):
2129

2230

2331
class Serializable:
32+
""" Serializable
33+
34+
Attributes:
35+
parser: Serializable Parser
36+
"""
2437
def __init__(self):
2538
self.parser = SerializableParser(instance=self)
2639

@@ -53,6 +66,7 @@ def export_json(self, path: str, ignore_error=True) -> bool:
5366
5467
Args:
5568
path: path of json file to be saved.
69+
ignore_error: whether to ignore error.
5670
5771
Returns:
5872
succeed saving json file or not.
@@ -161,17 +175,37 @@ def get_attribute(self, key_path: List[str]) -> Tuple[Any, str]:
161175
return self, key_path[0]
162176

163177
@staticmethod
164-
def is_base(key):
178+
def is_base(key: str) -> bool:
179+
"""
180+
181+
Args:
182+
key: key
183+
184+
Returns:
185+
if key named argument is from Serializable parent code.
186+
"""
165187
BASE = ['parser']
166188
return key in BASE
167189

168190

169191
class SerializableParser:
192+
""" Serializable Parser
193+
194+
Attributes:
195+
instance: Serializable instance
196+
"""
170197
def __init__(self, instance):
198+
""" Constructor
199+
200+
Args:
201+
instance: Serializable instance
202+
"""
171203
self.instance = instance
172204

173205
def parse(self):
174206
"""Parse method.
207+
208+
Automatically generate attributes and initialize using argument parser.
175209
"""
176210
# Strip dicts for parser
177211
dicts = self.instance.strip()

0 commit comments

Comments
 (0)