diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py index 521a5662e..3c8b3ac50 100644 --- a/sphinx/ext/graphviz.py +++ b/sphinx/ext/graphviz.py @@ -156,7 +156,7 @@ class Graphviz(SphinxDirective): node = graphviz() node['code'] = dotcode node['options'] = { - 'docpath': path.splitext(self.state.document.current_source)[0], + 'docname': path.splitext(self.state.document.current_source)[0], } if 'graphviz_dot' in self.options: @@ -196,7 +196,7 @@ class GraphvizSimple(SphinxDirective): node['code'] = '%s %s {\n%s\n}\n' % \ (self.name, self.arguments[0], '\n'.join(self.content)) node['options'] = { - 'docpath': path.splitext(self.state.document.current_source)[0], + 'docname': path.splitext(self.state.document.current_source)[0], } if 'graphviz_dot' in self.options: node['options']['graphviz_dot'] = self.options['graphviz_dot'] @@ -241,7 +241,8 @@ def render_dot(self, code, options, format, prefix='graphviz'): dot_args.extend(self.builder.config.graphviz_dot_args) dot_args.extend(['-T' + format, '-o' + outfn]) - cwd = path.dirname(options.get('docpath', self.builder.srcdir)) + docname = options.get('docname', 'index') + cwd = path.dirname(path.join(self.builder.srcdir, docname)) if format == 'png': dot_args.extend(['-Tcmapx', '-o%s.map' % outfn])