MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / parse

Method parse

tools/codestyle/docstring_checker.py:55–90  ·  view source on GitHub ↗

parse gets sections from doc Such as Args, Returns, Raises, Examples s Args: doc (string): is the astroid node doc string. Returns: True if doc is parsed successfully.

(self, doc)

Source from the content-addressed store, hash-verified

53 return level
54
55 def parse(self, doc):
56 """parse gets sections from doc
57 Such as Args, Returns, Raises, Examples s
58 Args:
59 doc (string): is the astroid node doc string.
60 Returns:
61 True if doc is parsed successfully.
62 """
63 self.clear()
64
65 lines = doc.splitlines()
66 state = ("others", -1)
67 for l in lines:
68 c = l.strip()
69 if len(c) <= 0:
70 continue
71
72 level = self.get_level(l)
73 if c.startswith("Args:"):
74 state = ("Args", level)
75 elif c.startswith("Returns:"):
76 state = ("Returns", level)
77 elif c.startswith("Raises:"):
78 state = ("Raises", level)
79 elif c.startswith("Examples:"):
80 state = ("Examples", level)
81 else:
82 if level > state[1]:
83 self.d[state[0]].append(c)
84 continue
85
86 state = ("others", -1)
87 self.d[state[0]].append(c)
88
89 self._arg_with_type()
90 return True
91
92 def get_returns(self):
93 return self.d['Returns']

Callers 1

visit_functiondefMethod · 0.95

Calls 4

clearMethod · 0.95
get_levelMethod · 0.95
_arg_with_typeMethod · 0.95
appendMethod · 0.80

Tested by

no test coverage detected