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

Inherit render properties #116

Merged
merged 3 commits into from
Oct 13, 2020
Merged

Conversation

BMaxV
Copy link
Contributor

@BMaxV BMaxV commented Oct 10, 2020

Hi,

this is for #114 .

There are two things probably still have to be done:

I don't know what good non default values would be for 'encoding' and 'engine' for the test function.

There is a check in https://github.com/xflr6/graphviz/blob/master/graphviz/dot.py#L100 that subgraphs can't be strict, so it does not make sense to inherit that one.

@codecov-io
Copy link

codecov-io commented Oct 10, 2020

Codecov Report

Merging #116 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #116   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          504       504           
=========================================
  Hits           504       504           
Impacted Files Coverage Δ
graphviz/dot.py 100.00% <ø> (ø)
graphviz/backend.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3651713...d3cfbfe. Read the comment docs.

graphviz/dot.py Outdated
@@ -67,6 +67,7 @@ def __init__(self, name=None, comment=None,
self.body = list(body) if body is not None else []

self.strict = strict
self.enconding = encoding
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is handled by the super()-call in line 61 above:

self.encoding = encoding

@xflr6
Copy link
Owner

xflr6 commented Oct 10, 2020

Thanks for working on this.

I don't know what good non default values would be for 'encoding' and 'engine' for the test function.

How about 'ascii', and 'neato'?

There is a check in https://github.com/xflr6/graphviz/blob/master/graphviz/dot.py#L100 that subgraphs can't be strict, so it does not make sense to inherit that one.

graphviz/graphviz/dot.py

Lines 98 to 100 in 0c503a3

if subgraph:
if self.strict:
raise ValueError('subgraphs cannot be strict')

+1. We should add a note to the .subgraph()-method that instances created with the context manager are always strict=None because the parent's value is used when rendering the parent graph (there is no way for the subgraph to override). This means if we render the subgraph in the context manager it is bool(strict) == False. If user's would really want to render the subgraph as strict while rendering the whole graph non-strict they could do like this.

(...)
with d.subgraph(name='child') as s:
    s.strict = True
    s.render('child.gv')
    s.strict = None  # any falsy value

I think we should add a functional test for the use case of doing render() on a subgraph within the context-manager, i.e. use tmpdir and assert on the rendered files. Not yet shure where to put it exactly.

Another thing would be to extend the the docstring and maybe also the documentation section and to write a short summary of the behavioural difference for the CHANGES.txt. Tell me if/when you prefer me to take over, then we can probably merge what you have.

@BMaxV
Copy link
Contributor Author

BMaxV commented Oct 13, 2020

I think this should be it. I didn't touch CHANGES.txt yet , that would still need to be done. It inherits the format now and that was the main thing I wanted, so I think you can take over now?

@xflr6
Copy link
Owner

xflr6 commented Oct 13, 2020

Thanks. Still need a functional test, implement strict=None, more informative documentation and a proper note in the docstring, let me take if from here then.

@xflr6 xflr6 merged commit 9bc6803 into xflr6:master Oct 13, 2020
@xflr6
Copy link
Owner

xflr6 commented Oct 13, 2020

See adaptations in 4a20d2e

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

Successfully merging this pull request may close these issues.

3 participants