Skip to content

Commit

Permalink
fix: type annotations, comments, __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
haidaraM committed Mar 18, 2024
1 parent 48498af commit d5afe58
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
3 changes: 2 additions & 1 deletion ansibleplaybookgrapher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def parse(
:param tags: Only add plays and tasks tagged with these values
:param skip_tags: Only add plays and tasks whose tags do not match these values
:param group_roles_by_name: Group roles by name instead of considering them as separate nodes with different IDs
:return:
:return: Tuple of the list of playbook nodes and the dictionary of the role usages: the key is the role and the
value is the set of plays that use the role.
"""
playbook_nodes = []
roles_usage: Dict[RoleNode, Set[PlayNode]] = {}
Expand Down
6 changes: 3 additions & 3 deletions ansibleplaybookgrapher/renderer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from abc import ABC, abstractmethod
from typing import Dict, Optional, Set
from typing import Dict, Optional, Set, List

from ansible.utils.display import Display

Expand Down Expand Up @@ -44,7 +44,7 @@
class Renderer(ABC):
def __init__(
self,
playbook_nodes: PlaybookNode,
playbook_nodes: List[PlaybookNode],
roles_usage: Dict[RoleNode, Set[PlayNode]],
):
self.playbook_nodes = playbook_nodes
Expand Down Expand Up @@ -73,7 +73,7 @@ def render(

class PlaybookBuilder(ABC):
"""
This the base class to inherit from by the renderer to build a single Playbook in the target format.
This is the base class to inherit from by the renderer to build a single Playbook in the target format.
It provides some methods that need to be implemented
"""

Expand Down
3 changes: 1 addition & 2 deletions ansibleplaybookgrapher/renderer/graphviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def __init__(
playbook_nodes: List[PlaybookNode],
roles_usage: Dict["RoleNode", Set[PlayNode]],
):
self.playbook_nodes = playbook_nodes
self.roles_usage = roles_usage
super().__init__(playbook_nodes, roles_usage)

def render(
self,
Expand Down
10 changes: 4 additions & 6 deletions ansibleplaybookgrapher/renderer/mermaid.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from pathlib import Path
from typing import Dict, Set, List

Expand All @@ -23,9 +24,7 @@
display = Display()

# Default directive when rendering the graph.
# More info at
# https://mermaid.js.org/config/directives.html
#
# More info at https://mermaid.js.org/config/directives.html
DEFAULT_DIRECTIVE = '%%{ init: { "flowchart": { "curve": "bumpX" } } }%%'
DEFAULT_ORIENTATION = "LR" # Left to right

Expand All @@ -36,8 +35,7 @@ def __init__(
playbook_nodes: List[PlaybookNode],
roles_usage: Dict["RoleNode", Set[PlayNode]],
):
self.playbook_nodes = playbook_nodes
self.roles_usage = roles_usage
super().__init__(playbook_nodes, roles_usage)

def render(
self,
Expand Down Expand Up @@ -106,7 +104,7 @@ def render(
"The --view option is not supported yet by the mermaid renderer"
)

return final_output_path_file
return str(final_output_path_file)


class MermaidFlowChartPlaybookBuilder(PlaybookBuilder):
Expand Down

0 comments on commit d5afe58

Please sign in to comment.