@@ -145,8 +145,9 @@ def class_name(self, cls, parts=0):
145145 """
146146 module = cls .__module__
147147 if module == '__builtin__' :
148- return cls .__name__
149- fullname = '.' .join ([module , cls .__name__ ])
148+ fullname = cls .__name__
149+ else :
150+ fullname = "%s.%s" % (module , cls .__name__ )
150151 if parts == 0 :
151152 return fullname
152153 name_parts = fullname .split ('.' )
@@ -299,6 +300,9 @@ def inheritance_diagram_directive_run(class_names, options, state):
299300 node ['content' ] = " " .join (class_names )
300301 return [node ]
301302
303+ def get_graph_hash (node ):
304+ return md5 (node ['content' ] + str (node ['parts' ])).hexdigest ()[- 10 :]
305+
302306def html_output_graph (self , node ):
303307 """
304308 Output the graph for HTML. This will insert a PNG with clickable
@@ -307,11 +311,9 @@ def html_output_graph(self, node):
307311 graph = node ['graph' ]
308312 parts = node ['parts' ]
309313
310- # Determine where to write the PNG to. This follows
311- # the same procedure as mathpng.py
312- name = 'inheritance%s' % md5 (
313- node ['content' ] + str (node ['parts' ])).hexdigest ()[- 10 :]
314- png_path = '_static/%s.png' % name
314+ graph_hash = get_graph_hash (node )
315+ name = "inheritance%s" % graph_hash
316+ png_path = os .path .join ('_static' , name + ".png" )
315317
316318 path = '_static'
317319 source = self .document .attributes ['source' ]
@@ -346,23 +348,13 @@ def latex_output_graph(self, node):
346348 graph = node ['graph' ]
347349 parts = node ['parts' ]
348350
349- # Determine where to write the PNG to. This follows
350- # the same procedure as mathpng.py
351- name = 'inheritance%s' % md5 (
352- node ['content' ] + str (node ['parts' ])).hexdigest ()[- 10 :]
353- pdf_path = '_static/%s.pdf' % name
354-
355- path = '_static'
356- source = self .document .attributes ['source' ]
357- count = source .split ('/doc/' )[- 1 ].count ('/' )
358- for i in range (count ):
359- if os .path .exists (path ): break
360- path = '../' + path
361- path = '../' + path #specifically added for matplotlib
351+ graph_hash = get_graph_hash (node )
352+ name = "inheritance%s"
353+ pdf_path = os .path .join ('_static' , name + ".pdf" )
362354
363- graph .run_dot (['-Tpdf' , '-o%s' % pdf_path ], name , parts ,
364- graph_options = {'size' : '"6.0,6.0"' })
365- return '\\ includegraphics{../../_static/%s.pdf }' % name
355+ graph .run_dot (['-Tpdf' , '-o%s' % pdf_path ],
356+ name , parts , graph_options = {'size' : '"6.0,6.0"' })
357+ return '\\ includegraphics{../../%s }' % pdf_path
366358
367359def visit_inheritance_diagram (inner_func ):
368360 """
0 commit comments