Skip to content

Commit

Permalink
Fixed options according to official documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Jan 12, 2020
1 parent 5566eae commit 785c242
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ This is a patched version of [`sphinx.ext.graphviz`](https://github.com/sphinx-d
--------------------

## Added features
## Added features and changes

* TBD
* `2.3.1.post1`
* Updated directive options according to documentation (see: [sphinx-doc/sphinx#6991](https://github.com/sphinx-doc/sphinx/issues/6991#issuecomment-573446371))

## Cross-References

Expand Down
13 changes: 8 additions & 5 deletions btd/sphinx/graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ def run(self) -> List[Node]:
node['options'] = {'docname': self.env.docname}

if 'graphviz_dot' in self.options:
node['options']['graphviz_dot'] = self.options['graphviz_dot']
node['options']['layout'] = self.options['graphviz_dot']
if 'layout' in self.options:
node['options']['graphviz_dot'] = self.options['layout']
node['options']['layout'] = self.options['layout']
if 'alt' in self.options:
node['alt'] = self.options['alt']
if 'align' in self.options:
Expand All @@ -180,7 +180,8 @@ class GraphvizSimple(SphinxDirective):
'alt': directives.unchanged,
'align': align_spec,
'caption': directives.unchanged,
'graphviz_dot': directives.unchanged,
'layout': directives.unchanged,
'graphviz_dot': directives.unchanged, # an old alias of `layout` option
'name': directives.unchanged,
}

Expand All @@ -190,7 +191,9 @@ def run(self) -> List[Node]:
(self.name, self.arguments[0], '\n'.join(self.content))
node['options'] = {'docname': self.env.docname}
if 'graphviz_dot' in self.options:
node['options']['graphviz_dot'] = self.options['graphviz_dot']
node['options']['layout'] = self.options['graphviz_dot']
if 'layout' in self.options:
node['options']['layout'] = self.options['layout']
if 'alt' in self.options:
node['alt'] = self.options['alt']
if 'align' in self.options:
Expand All @@ -208,7 +211,7 @@ def run(self) -> List[Node]:
def render_dot(self: SphinxTranslator, code: str, options: Dict,
format: str, prefix: str = 'graphviz') -> Tuple[str, str]:
"""Render graphviz code into a PNG or PDF output file."""
graphviz_dot = options.get('graphviz_dot', self.builder.config.graphviz_dot)
graphviz_dot = options.get('layout', self.builder.config.graphviz_dot)
hashkey = (code + str(options) + str(graphviz_dot) +
str(self.builder.config.graphviz_dot_args)).encode()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

projectName = "sphinx.graphviz"
projectNameWithPrefix = "btd." + projectName
version = "2.3.1.post1.dev1"
version = "2.3.1.post1"

github_url = "https://github.com/buildthedocs/" + projectName
rtd_url = "https://" + projectNameWithPrefix.replace(".", "-") + ".readthedocs.io/en/latest/"
Expand Down

0 comments on commit 785c242

Please sign in to comment.