MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / Doc

Class Doc

dnn/scripts/gen_param_defs.py:30–69  ·  view source on GitHub ↗

wrap an identifier to associate document note: if the doc starts with a linebreak, it would not be reforamtted.

Source from the content-addressed store, hash-verified

28 pass
29
30 class Doc:
31 """wrap an identifier to associate document
32
33 note: if the doc starts with a linebreak, it would not be reforamtted.
34 """
35
36 __slots__ = ["id", "doc"]
37
38 def __init__(self, id_, doc):
39 assert isinstance(id_, str) and isinstance(doc, str), (id_, doc)
40 self.id = id_
41 self.doc = doc
42
43 @property
44 def no_reformat(self):
45 """whether reformat is disallowed for this doc string"""
46 return self.doc.startswith("\n")
47
48 @property
49 def raw_lines(self):
50 """the doc lines when ``no_format`` is true"""
51 ret = self.doc.split("\n")
52 assert not ret[0]
53 return ret[1:]
54
55 @classmethod
56 def make(cls, v):
57 """make doc object from str or doc"""
58 if isinstance(v, cls):
59 return v
60 assert isinstance(v, str)
61 return cls(v, "")
62
63 def __str__(self):
64 return self.id
65
66 def __eq__(self, rhs):
67 if isinstance(rhs, str):
68 return self.id == rhs
69 return isinstance(rhs, Doc) and (self.id, self.doc) == (rhs.id, rhs.doc)
70
71 class Enum(Base):
72 """define an enum; the result would contain both an enum class def and its

Callers 2

opr_param_defs.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected