forked from enlightenment/efl
Pyolian gendoc: the last hidden bits of documentation ref tokens
Now links works also inside documentation text \o/
This commit is contained in:
parent
40676af383
commit
ac2f3896df
|
@ -78,7 +78,15 @@ ${'\n\n' if i else ''}$#!
|
||||||
<!--(if token.type == Eolian_Doc_Token_Type.TEXT)-->
|
<!--(if token.type == Eolian_Doc_Token_Type.TEXT)-->
|
||||||
%%${token.text}$%%#!
|
%%${token.text}$%%#!
|
||||||
<!--(elif token.type == Eolian_Doc_Token_Type.REF)-->
|
<!--(elif token.type == Eolian_Doc_Token_Type.REF)-->
|
||||||
**REF ${token.text}$ ${token.ref}$ ??**#!
|
<!--(if token.ref_type == Eolian_Object_Type.FUNCTION)-->
|
||||||
|
${CLS_LINK(cls=token.ref_obj)}$.${FUNC_LINK(func=token.ref_attr)}$#!
|
||||||
|
<!--(elif token.ref_type == Eolian_Object_Type.TYPEDECL)-->
|
||||||
|
${TYPEDECL_LINK(typedecl=token.ref_obj)}$#!
|
||||||
|
<!--(elif token.ref_type == Eolian_Object_Type.CLASS)-->
|
||||||
|
${CLS_LINK(cls=token.ref_obj)}$#!
|
||||||
|
<!--(else)-->
|
||||||
|
**TODO REF ${token.ref_type}$**$#!
|
||||||
|
<!--(end)-->
|
||||||
<!--(elif token.type == Eolian_Doc_Token_Type.MARKUP_MONOSPACE)-->
|
<!--(elif token.type == Eolian_Doc_Token_Type.MARKUP_MONOSPACE)-->
|
||||||
''${token.text}$''#!
|
''${token.text}$''#!
|
||||||
<!--(elif token.type == Eolian_Doc_Token_Type.MARK_NOTE)-->
|
<!--(elif token.type == Eolian_Doc_Token_Type.MARK_NOTE)-->
|
||||||
|
|
|
@ -37,6 +37,25 @@ _already_halted = False
|
||||||
|
|
||||||
|
|
||||||
# Eolian Enums ##############################################################
|
# Eolian Enums ##############################################################
|
||||||
|
class Eolian_Object_Type(IntEnum):
|
||||||
|
UNKNOWN = 0
|
||||||
|
CLASS = 1
|
||||||
|
TYPEDECL = 2
|
||||||
|
STRUCT_FIELD = 3
|
||||||
|
ENUM_FIELD = 4
|
||||||
|
TYPE = 5
|
||||||
|
CONSTANT = 6
|
||||||
|
EXPRESSION = 7
|
||||||
|
FUNCTION = 8
|
||||||
|
FUNCTION_PARAMETER = 9
|
||||||
|
EVENT = 10
|
||||||
|
PART = 11
|
||||||
|
IMPLEMENT = 12
|
||||||
|
CONSTRUCTOR = 13
|
||||||
|
DOCUMENTATION = 14
|
||||||
|
ERROR = 15
|
||||||
|
|
||||||
|
|
||||||
class Eolian_Function_Type(IntEnum):
|
class Eolian_Function_Type(IntEnum):
|
||||||
UNRESOLVED = 0
|
UNRESOLVED = 0
|
||||||
PROPERTY = 1
|
PROPERTY = 1
|
||||||
|
@ -782,7 +801,7 @@ class Constructor(Object):
|
||||||
|
|
||||||
class Event(Object):
|
class Event(Object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<eolian.Event '{0.name}', c_name='{0.c_name}'>".format(self)
|
return "<eolian.Event '{0.name}', c_macro='{0.c_macro}'>".format(self)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def c_macro(self):
|
def c_macro(self):
|
||||||
|
@ -1262,7 +1281,7 @@ class _Eolian_Doc_Token_Struct(ctypes.Structure):
|
||||||
("text_end", c_char_p)]
|
("text_end", c_char_p)]
|
||||||
|
|
||||||
|
|
||||||
class Documentation(Object): # OK (1 TODO Unit*)
|
class Documentation(Object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
t = self.summary if len(self.summary) < 40 else self.summary[:40] + '...'
|
t = self.summary if len(self.summary) < 40 else self.summary[:40] + '...'
|
||||||
return "<eolian.Documentation summary='{}'>".format(t)
|
return "<eolian.Documentation summary='{}'>".format(t)
|
||||||
|
@ -1293,8 +1312,7 @@ class Documentation(Object): # OK (1 TODO Unit*)
|
||||||
""" return a list of paragraphs, each one is a list of tokens """
|
""" return a list of paragraphs, each one is a list of tokens """
|
||||||
return self._tokenize(self.description)
|
return self._tokenize(self.description)
|
||||||
|
|
||||||
@classmethod
|
def _tokenize(self, full_text):
|
||||||
def _tokenize(cls, full_text):
|
|
||||||
paragraphs = []
|
paragraphs = []
|
||||||
if not full_text:
|
if not full_text:
|
||||||
return paragraphs
|
return paragraphs
|
||||||
|
@ -1309,8 +1327,10 @@ class Documentation(Object): # OK (1 TODO Unit*)
|
||||||
while next_chunk:
|
while next_chunk:
|
||||||
typ = lib.eolian_doc_token_type_get(byref(tok))
|
typ = lib.eolian_doc_token_type_get(byref(tok))
|
||||||
txt = lib.eolian_doc_token_text_get(byref(tok))
|
txt = lib.eolian_doc_token_text_get(byref(tok))
|
||||||
# ref = # TODO ... Stupido parametro '*unit' :(
|
ref_obj = c_void_p(0)
|
||||||
tokens.append(Documentation_Token(typ, txt))
|
ref_attr = c_void_p(0)
|
||||||
|
ref_type = lib.eolian_doc_token_ref_resolve(byref(tok), self.unit.state, byref(ref_obj), byref(ref_attr))
|
||||||
|
tokens.append(Documentation_Token(typ, txt, ref_type, ref_obj, ref_attr))
|
||||||
lib.free(c_void_p(txt))
|
lib.free(c_void_p(txt))
|
||||||
next_chunk = lib.eolian_documentation_tokenize(c_char_p(next_chunk), byref(tok))
|
next_chunk = lib.eolian_documentation_tokenize(c_char_p(next_chunk), byref(tok))
|
||||||
paragraphs.append(tokens)
|
paragraphs.append(tokens)
|
||||||
|
@ -1319,10 +1339,12 @@ class Documentation(Object): # OK (1 TODO Unit*)
|
||||||
|
|
||||||
|
|
||||||
class Documentation_Token(object):
|
class Documentation_Token(object):
|
||||||
def __init__(self, c_token_type, c_text):
|
def __init__(self, c_token_type, c_text, c_ref_type, c_ref_obj, c_ref_attr):
|
||||||
self._type = Eolian_Doc_Token_Type(c_token_type)
|
self._type = Eolian_Doc_Token_Type(c_token_type)
|
||||||
self._text = _str_to_py(c_text)
|
self._text = _str_to_py(c_text)
|
||||||
self._ref = None # TODO
|
self._ref_type = Eolian_Object_Type(c_ref_type)
|
||||||
|
self._ref_obj = Object(c_ref_obj) if c_ref_obj else None
|
||||||
|
self._ref_attr = Object(c_ref_attr) if c_ref_attr else None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
t = self.text if len(self.text) < 40 else self.text[:40] + '...'
|
t = self.text if len(self.text) < 40 else self.text[:40] + '...'
|
||||||
|
@ -1338,8 +1360,16 @@ class Documentation_Token(object):
|
||||||
return self._text
|
return self._text
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ref(self):
|
def ref_type(self):
|
||||||
return self._ref
|
return self._ref_type
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ref_obj(self):
|
||||||
|
return self._ref_obj
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ref_attr(self):
|
||||||
|
return self._ref_attr
|
||||||
|
|
||||||
|
|
||||||
class Error(Object):
|
class Error(Object):
|
||||||
|
@ -1382,42 +1412,23 @@ def _str_to_py(s):
|
||||||
|
|
||||||
# internal Object type -> Class mapping #####################################
|
# internal Object type -> Class mapping #####################################
|
||||||
|
|
||||||
class _Eolian_Object_Type(IntEnum):
|
|
||||||
UNKNOWN = 0
|
|
||||||
CLASS = 1
|
|
||||||
TYPEDECL = 2
|
|
||||||
STRUCT_FIELD = 3
|
|
||||||
ENUM_FIELD = 4
|
|
||||||
TYPE = 5
|
|
||||||
CONSTANT = 6
|
|
||||||
EXPRESSION = 7
|
|
||||||
FUNCTION = 8
|
|
||||||
FUNCTION_PARAMETER = 9
|
|
||||||
EVENT = 10
|
|
||||||
PART = 11
|
|
||||||
IMPLEMENT = 12
|
|
||||||
CONSTRUCTOR = 13
|
|
||||||
DOCUMENTATION = 14
|
|
||||||
ERROR = 15
|
|
||||||
|
|
||||||
|
|
||||||
_eolian_type_class_mapping = {
|
_eolian_type_class_mapping = {
|
||||||
_Eolian_Object_Type.UNKNOWN: Object,
|
Eolian_Object_Type.UNKNOWN: Object,
|
||||||
_Eolian_Object_Type.CLASS: Class,
|
Eolian_Object_Type.CLASS: Class,
|
||||||
_Eolian_Object_Type.TYPEDECL: Typedecl,
|
Eolian_Object_Type.TYPEDECL: Typedecl,
|
||||||
_Eolian_Object_Type.STRUCT_FIELD: Struct_Type_Field,
|
Eolian_Object_Type.STRUCT_FIELD: Struct_Type_Field,
|
||||||
_Eolian_Object_Type.ENUM_FIELD: Enum_Type_Field,
|
Eolian_Object_Type.ENUM_FIELD: Enum_Type_Field,
|
||||||
_Eolian_Object_Type.TYPE: Type,
|
Eolian_Object_Type.TYPE: Type,
|
||||||
_Eolian_Object_Type.CONSTANT: Constant,
|
Eolian_Object_Type.CONSTANT: Constant,
|
||||||
_Eolian_Object_Type.EXPRESSION: Expression,
|
Eolian_Object_Type.EXPRESSION: Expression,
|
||||||
_Eolian_Object_Type.FUNCTION: Function,
|
Eolian_Object_Type.FUNCTION: Function,
|
||||||
_Eolian_Object_Type.FUNCTION_PARAMETER: Function_Parameter,
|
Eolian_Object_Type.FUNCTION_PARAMETER: Function_Parameter,
|
||||||
_Eolian_Object_Type.EVENT: Event,
|
Eolian_Object_Type.EVENT: Event,
|
||||||
_Eolian_Object_Type.PART: Part,
|
Eolian_Object_Type.PART: Part,
|
||||||
_Eolian_Object_Type.IMPLEMENT: Implement,
|
Eolian_Object_Type.IMPLEMENT: Implement,
|
||||||
_Eolian_Object_Type.CONSTRUCTOR: Constructor,
|
Eolian_Object_Type.CONSTRUCTOR: Constructor,
|
||||||
_Eolian_Object_Type.DOCUMENTATION: Documentation,
|
Eolian_Object_Type.DOCUMENTATION: Documentation,
|
||||||
_Eolian_Object_Type.ERROR: Error,
|
Eolian_Object_Type.ERROR: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -690,8 +690,8 @@ lib.eolian_doc_token_text_get.argtypes = (c_void_p,)
|
||||||
lib.eolian_doc_token_text_get.restype = c_void_p # char* TO BE FREED
|
lib.eolian_doc_token_text_get.restype = c_void_p # char* TO BE FREED
|
||||||
|
|
||||||
# EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2);
|
# EAPI Eolian_Object_Type eolian_doc_token_ref_resolve(const Eolian_Doc_Token *tok, const Eolian_State *state, const Eolian_Object **data, const Eolian_Object **data2);
|
||||||
# lib.eolian_doc_token_ref_resolve.argtypes = (c_void_p, c_void_p, ???, ???)
|
lib.eolian_doc_token_ref_resolve.argtypes = (c_void_p, c_void_p, c_void_p, c_void_p)
|
||||||
# lib.eolian_doc_token_ref_resolve.restype = c_int
|
lib.eolian_doc_token_ref_resolve.restype = c_int
|
||||||
|
|
||||||
|
|
||||||
# Eolian_Error ##############################################################
|
# Eolian_Error ##############################################################
|
||||||
|
|
|
@ -134,6 +134,7 @@ class Template(pyratemp.Template):
|
||||||
'Documentation_Token': eolian.Documentation_Token,
|
'Documentation_Token': eolian.Documentation_Token,
|
||||||
'Error': eolian.Error,
|
'Error': eolian.Error,
|
||||||
# Eolian Enums
|
# Eolian Enums
|
||||||
|
'Eolian_Object_Type': eolian.Eolian_Object_Type,
|
||||||
'Eolian_Function_Type': eolian.Eolian_Function_Type,
|
'Eolian_Function_Type': eolian.Eolian_Function_Type,
|
||||||
'Eolian_Parameter_Direction': eolian.Eolian_Parameter_Direction,
|
'Eolian_Parameter_Direction': eolian.Eolian_Parameter_Direction,
|
||||||
'Eolian_Class_Type': eolian.Eolian_Class_Type,
|
'Eolian_Class_Type': eolian.Eolian_Class_Type,
|
||||||
|
|
Loading…
Reference in New Issue