ó 1Tc@sŠdZddlZddlZddlZddlZyddlmZWn!ek rmddlmZnXddlm Z ddl m Z ddl m Z mZmZddlmZddlmZdd lmZejd ejƒZd efd „ƒYZd efd„ƒYZde je jfd„ƒYZdefd„ƒYZ d„Z!d„Z"d„Z#d„Z$d„Z%d„Z&dS(s[ sphinx.ext.inheritance_diagram ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Defines a docutils directive for inserting inheritance diagrams. Provide the directive with one or more classes or modules (separated by whitespace). For modules, all of the classes in that module will be used. Example:: Given the following classes: class A: pass class B(A): pass class C(A): pass class D(B, C): pass class E(B): pass .. inheritance-diagram: D E Produces a graph like the following: A / \ B C / \ / E D The graph is inserted as a PNG+image map into HTML and a PDF in LaTeX. :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. iÿÿÿÿN(tmd5(tnodes(t directives(trender_dot_htmltrender_dot_latextrender_dot_texinfo(tModuleAnalyzer(t force_decode(t Directives^([\w.]*\.)? # module names (\w+) \s* $ # class/final module name tInheritanceExceptioncBseZRS((t__name__t __module__(((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyR ?stInheritanceGraphcBsËeZdZeedd„Zd„Zd„Zd„Zdd„Zd„Z idd 6d d 6Z id d 6dd6dd6dd6dd6Z idd6dd6Z d„Z d„Zidiiid„ZRS(s¾ Given a list of classes, determines the set of classes that they inherit from all the way to the root "object", and then is able to generate a graphviz dot graph from them. icCsR||_|j||ƒ}|j||||ƒ|_|jsNtdƒ‚ndS(s£*class_names* is a list of child classes to show bases from. If *show_builtins* is True, then Python builtins will be shown in the graph. s(No classes found for inheritance diagramN(t class_namest_import_classest _class_infot class_infoR (tselfR t currmodulet show_builtinst private_basestpartstclasses((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyt__init__Is    c Cs¯ytj|ƒjƒ\}}Wn'ttfk rHtd|ƒ‚nX|pRd|}|rn|jdƒpqd}yt|ƒtj |}Wnt k r |sÇ|r´|}qÇtd|ƒ‚ny$t|ƒt tj ||ƒ}Wq!t tfk rtd|d|ƒ‚q!XnXt j |ƒr7|gSt j|ƒr›g}xH|jjƒD]7}t j |ƒr\|j|jkr\|j|ƒq\q\W|Std|ƒ‚dS(s0Import a class using its fully-qualified *name*.s<Invalid class or module %r specified for inheritance diagramtt.s;Could not import class %r specified for inheritance diagramsECould not import class or module %r specified for inheritance diagrams=%r specified for inheritance diagram is not a class or moduleN(t class_sig_retmatchtgroupstAttributeErrort ValueErrorR trstript __import__tsystmodulest ImportErrortgetattrtinspecttisclasstismodulet__dict__tvaluesR R tappend( RtnameRtpathtbasetfullnamettodocRtcls((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyt_import_class_or_moduleXsD     !cCs4g}x'|D]}|j|j||ƒƒq W|S(sImport a list of classes.(textendR1(RR RRR+((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyR…s cs^i‰ttƒjƒ‰‡‡‡‡‡‡‡fd†‰x|D]}ˆ|ƒq@WˆjƒS(sÅReturn name and bases for all classes that are ancestors of *classes*. *parts* gives the number of dotted name parts that is removed from the displayed node names. cs‘ˆ r|ˆkrdSˆ r4|jjdƒr4dSˆj|ˆƒ}ˆj|dƒ}d}y|jrÞtj|jƒj}|jj ƒj dƒd}t |t ƒs¼t ||ƒ}n|rÞd|jddƒ}qÞnWntk rònXg}||||fˆ| "%s" [%s]; s} R(tdefault_graph_attrstcopytdefault_node_attrstdefault_edge_attrstupdatetconfigtinheritance_graph_attrstinheritance_node_attrstinheritance_edge_attrsR*R_tsortedRR^RL(RR+turlstenvt graph_attrst node_attrst edge_attrstg_attrstn_attrste_attrstresR.tbasesRCtthis_node_attrst base_name((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyt generate_dotès6    "       N(R R R8tFalseRR1RRR6RORaRcRdR^R_R7Rw(((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyR Cs0 -  0       tinheritance_diagramcBseZdZRS(sN A docutils node to use as a placeholder for the inheritance diagram. (R R R8(((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyRystInheritanceDiagramcBsIeZdZeZdZdZeZie j d6e j d6Z d„Z RS(sJ Run when the inheritance_diagram directive is first encountered. iiRs private-basesc CsLtƒ}|jj|_|jjjj}|jdjƒ}|jdƒjdƒ}|j j ddƒ|d Output the graph for LaTeX. This will insert a PDF. Rs inheritance%sRlRms "6.0,6.0"RRR£N(RžRwR¥RlRRR¦(RRRR§R+R©((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pytlatex_visit_inheritance_diagramis   cCsk|d}t|ƒ}d|}|j|d|jjdidd6ƒ}t|||gdƒtj‚dS( s@ Output the graph for Texinfo. This will insert a PNG. Rs inheritance%sRlRms "6.0,6.0"RRR£N(RžRwR¥RlRRR¦(RRRR§R+R©((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyt!texinfo_visit_inheritance_diagramxs   cCs tj‚dS(N(RR¦(RR((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pytskip‡sc Cs¬|jdƒ|jtdtdfdtdfdtdfdtdfdtdfƒ|jdt ƒ|j dit ƒf|j d it ƒf|j d it ƒfdS( Nssphinx.ext.graphviztlatexthtmlttexttmanttexinfosinheritance-diagramRgRhRi( tsetup_extensiontadd_nodeRyR«R7RªR­R¬t add_directiveRztadd_config_valueRx(tapp((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pytsetup‹s      ('R8treR!R%RKthashlibRR#tdocutilsRtdocutils.parsers.rstRtsphinx.ext.graphvizRRRt sphinx.pycodeRt sphinx.utilRtsphinx.util.compatRtcompiletVERBOSERR@R tobjectR tGeneraltElementRyRzRžRªR«R¬R­R¸(((sH/usr/local/lib/python2.7/site-packages/sphinx/ext/inheritance_diagram.pyt%s4     Ó/