Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for neato engine no-op command-line flag #131

Closed
clayms opened this issue Mar 16, 2021 · 6 comments
Closed

Add support for neato engine no-op command-line flag #131

clayms opened this issue Mar 16, 2021 · 6 comments

Comments

@clayms
Copy link

clayms commented Mar 16, 2021

Is it possible to use the neato engine no-op command-line flag (-n CLI flag) to add to an existing graph without altering the current node locations?

See "-n[num]" in https://graphviz.gitlab.io/doc/info/command.html

Neato Layout Manual.

@xflr6
Copy link
Owner

xflr6 commented Mar 16, 2021

Thanks. Marking this as enhancement.

Would you like to give it a try?

Probably similar to the formatter argument:

graphviz/graphviz/files.py

Lines 202 to 205 in a542d04

def render(self, filename=None, directory=None, view=False, cleanup=False,
format=None, renderer=None, formatter=None,
quiet=False, quiet_view=False):
"""Save the source to file and render with the Graphviz engine.

graphviz/graphviz/files.py

Lines 143 to 144 in a542d04

def pipe(self, format=None, renderer=None, formatter=None, quiet=False):
"""Return the source piped through the Graphviz layout command.

@xflr6 xflr6 changed the title neato engine no-op command-line flag Add support for neato engine no-op command-line flag Nov 14, 2021
@xflr6
Copy link
Owner

xflr6 commented Nov 14, 2021

@neogeno
Copy link

neogeno commented Jan 30, 2022

+1 - can someone give me some advice to add a PR myself so that I can pass -n2 to the neato engine?

@xflr6
Copy link
Owner

xflr6 commented Feb 3, 2022

The code moved around a bit since then (better structure).

We need a new argument similar to the formatter argument:

def command(engine: str, format_: str, *,
renderer: typing.Optional[str] = None,
formatter: typing.Optional[str] = None
) -> typing.List[typing.Union[os.PathLike, str]]:
"""Return ``subprocess.Popen`` argument list for rendering.

def render(engine: str,
format: typing.Optional[str] = None,
filepath: typing.Union[os.PathLike, str, None] = None,
renderer: typing.Optional[str] = None,
formatter: typing.Optional[str] = None,
quiet: bool = False, *,
outfile: typing.Union[os.PathLike, str, None] = None,
raise_if_result_exists: bool = False,
overwrite_filepath: bool = False) -> str:
r"""Render file with ``engine`` into ``format`` and return result filename.

Also the overload annoations above.

def pipe(engine: str, format: str, data: bytes,
renderer: typing.Optional[str] = None,
formatter: typing.Optional[str] = None,
quiet: bool = False) -> bytes:
"""Return ``data`` (``bytes``) piped through ``engine`` into ``format`` as ``bytes``.

Also the other pipe functions above.

def render(self,
filename: typing.Union[os.PathLike, str, None] = None,
directory: typing.Union[os.PathLike, str, None] = None,
view: bool = False,
cleanup: bool = False,
format: typing.Optional[str] = None,
renderer: typing.Optional[str] = None,
formatter: typing.Optional[str] = None,
quiet: bool = False,
quiet_view: bool = False, *,
outfile: typing.Union[os.PathLike, str, None] = None,
engine: typing.Optional[str] = None,
raise_if_result_exists: bool = False,
overwrite_source: bool = False) -> str:
r"""Save the source to file and render with the Graphviz engine.

def pipe(self,
format: typing.Optional[str] = None,
renderer: typing.Optional[str] = None,
formatter: typing.Optional[str] = None,
quiet: bool = False, *,
engine: typing.Optional[str] = None,
encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]:
"""Return the source piped through the Graphviz layout command.

Also overload and the private implementations above.

Not sure about the naming, maybe neato_no_op, or neato_no_op_num (type: Union[bool, int], maybe Optional[int] or Union[bool, int, None])?

Needs test coverage naturally.

@xflr6
Copy link
Owner

xflr6 commented Apr 10, 2022

Work in progress in 4ac5a25.

@xflr6
Copy link
Owner

xflr6 commented Apr 16, 2022

Added in version 0.20, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants