Skip to content

Commit

Permalink
Disable a group if all of its chiildren are all with "new" or unspeci…
Browse files Browse the repository at this point in the history
…fied status.
  • Loading branch information
niyue committed Feb 26, 2022
1 parent fb5fd43 commit af2af3f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# 0.2.1 - 2022-02-27
* disable a group if all its skills are new or not specified
# 0.2.0 - 2022-02-27
* add more themes
# 0.1.0 - 2022-02-26
* initial version, generating skill map from toml file to mermaid
31 changes: 22 additions & 9 deletions skillmap/skillmap_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,37 @@ def _required_node_edges(qualified_node_id, required_node_ids):
return "\n".join(node_requires)


def get_group_skills_list(qualified_group_id, group_skills):
group_skills = [
skill_node(_qualified_skill_id(qualified_group_id, skill_id), skill_value)
for skill_id, skill_value in group_skills.items()
]
return "\n".join(group_skills)


def get_group_status(group_skills):
for _, skill_value in group_skills.items():
skill_status = skill_value.get("status", "")
if skill_status not in ("new", ""):
return "normal"
return "new"


def group_subgraph(group_id, group_value):
qualified_group_id = _qualify(group_id)
group_name = group_value.get("name", "")
group_icon = get_icon(group_value)
group_skills_list = ""
if "skills" in group_value:
group_skills = [
skill_node(_qualified_skill_id(qualified_group_id, skill_id), skill_value)
for skill_id, skill_value in group_value["skills"].items()
]
group_skills_list = "\n".join(group_skills)
group_skills_list = get_group_skills_list(
qualified_group_id, group_value.get("skills", {})
)
group_status = get_group_status(group_value.get("skills", {}))

group_requires_list = _required_node_edges(
qualified_group_id, group_value.get("requires", [])
)

group_id_and_name = f"subgraph {qualified_group_id}[{group_icon} {group_name}]"
group_style = f"class {qualified_group_id} skillGroup;"
group_style = f"class {qualified_group_id} {group_status}SkillGroup;"
group_subgraph_end = "end"
sections = [
SECTION_SEPARATOR,
Expand Down Expand Up @@ -110,7 +123,7 @@ def skill_map_graph(skill_map):
map_group_subgraphs = group_subgraphs(skill_map.get("groups", {}))

skill_map_node = f"{map_name}({map_icon} <br/>{map_name})"
skill_map_node_style = f"class {map_name} skillGroup;"
skill_map_node_style = f"class {map_name} normalSkillGroup;"
sections = [
"flowchart TD",
skill_map_node,
Expand Down
6 changes: 3 additions & 3 deletions tests/skillmap_visitor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_visit_group_without_skill():
"subgraph groups.g1[fa:fa-anchor web ui]",
"", # skill list is skipped
"end",
"class groups.g1 skillGroup;",
"class groups.g1 newSkillGroup;",
""
]
assert group_graph.split("\n") == sections
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_visit_group():
"class groups.g1.skills.s2 newSkill;",
"",
"end",
"class groups.g1 skillGroup;",
"class groups.g1 newSkillGroup;",
""
]
assert group_graph.split("\n") == sections
Expand All @@ -100,7 +100,7 @@ def test_visit_group_with_requires():
"subgraph groups.g1[fa:fa-anchor web ui]",
"", # skill list is skipped
"end",
"class groups.g1 skillGroup;",
"class groups.g1 newSkillGroup;",
"groups.g2.skills.s1-->groups.g1",
]
assert group_graph.split("\n") == sections
2 changes: 1 addition & 1 deletion tests/urlshortener.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ requires = ["groups.backend.skills.restapi"]
requires = ["groups.webui.skills.react"]
[groups.webui.skills.react]
name = "react"
icon = "html5"
icon = "list"
status = "beingLearned"

[groups.backend]
Expand Down

0 comments on commit af2af3f

Please sign in to comment.