forked from ScoDoc/ScoDoc
gen_api_map: compression espace vertical
This commit is contained in:
parent
06727f1b9b
commit
de47277e7c
@ -10,7 +10,7 @@ class COLORS:
|
||||
|
||||
|
||||
class Token:
|
||||
def __init__(self, name, method="GET", query=None, leaf=False, func_name=""):
|
||||
def __init__(self, name, method="GET", query=None, leaf=False):
|
||||
self.children: list["Token"] = []
|
||||
self.name: str = name
|
||||
self.method: str = method
|
||||
@ -41,10 +41,13 @@ class Token:
|
||||
children_height = sum(child.get_height(y_step) for child in self.children)
|
||||
|
||||
# Calculer la hauteur des éléments de la query
|
||||
query_height = len(self.query) * y_step
|
||||
query_height = len(self.query) * (y_step * 1.33)
|
||||
|
||||
# La hauteur totale est la somme de la hauteur des enfants et des éléments de la query
|
||||
return children_height + query_height + y_step
|
||||
height = children_height + query_height
|
||||
if height == 0:
|
||||
height = y_step
|
||||
return height
|
||||
|
||||
def to_svg_group(
|
||||
self,
|
||||
@ -62,8 +65,6 @@ class Token:
|
||||
color = COLORS.GREEN
|
||||
elif self.method == "POST":
|
||||
color = COLORS.PINK
|
||||
# if self.force_leaf and not self.is_leaf():
|
||||
# color = COLORS.ORANGE
|
||||
|
||||
element = _create_svg_element(self.name, color)
|
||||
element.set("transform", f"translate({x_offset}, {y_offset})")
|
||||
@ -155,7 +156,7 @@ class Token:
|
||||
)
|
||||
sub_group.append(ampersand_group)
|
||||
|
||||
query_y_offset += y_step
|
||||
query_y_offset += y_step * 1.33
|
||||
|
||||
query_sub_element.append(sub_group)
|
||||
group.append(query_sub_element)
|
||||
@ -478,7 +479,8 @@ def parse_query_doc(doc):
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = Token("api")
|
||||
child1 = Token("assiduites", leaf=True, func_name="assiduites_get")
|
||||
child1 = Token("assiduites", leaf=True)
|
||||
child1.func_name = "assiduites_get"
|
||||
child2 = Token("count")
|
||||
child22 = Token("all")
|
||||
child23 = Token(
|
||||
@ -490,7 +492,8 @@ if __name__ == "__main__":
|
||||
"formsemestre_id": "<int:formsemestre_id>",
|
||||
},
|
||||
)
|
||||
child3 = Token("justificatifs", "POST", func_name="justificatifs_post")
|
||||
child3 = Token("justificatifs", "POST")
|
||||
child3.func_name = "justificatifs_post"
|
||||
|
||||
root.add_child(child1)
|
||||
child1.add_child(child2)
|
||||
|
Loading…
Reference in New Issue
Block a user