o $a? @sdZddlmZmZmZddlmZddlmZddl Z ddl m Z ddl m Z ddlmZdd lmZGd d d ejZGd d d e Zde dejdeddfddZde deeeffddZdS)a sphinx.ext.ifconfig ~~~~~~~~~~~~~~~~~~~ Provides the ``ifconfig`` directive that allows to write documentation that is included depending on configuration variables. Usage:: .. ifconfig:: releaselevel in ('alpha', 'beta', 'rc') This stuff is only included in the built docs for unstable versions. The argument for ``ifconfig`` is a plain Python expression, evaluated in the namespace of the project configuration (that is, all variables from ``conf.py`` are available.) :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. )AnyDictList)nodes)NodeN)Sphinx)SphinxDirective)nested_parse_with_titles) OptionSpecc@s eZdZdS)ifconfigN)__name__ __module__ __qualname__rr5/usr/lib/python3/dist-packages/sphinx/ext/ifconfig.pyr "sr c@s<eZdZUdZdZdZdZiZee d<de e fddZ dS) IfConfigTr option_specreturncCs>t}|jj|_|||jd|d<t|j|j||gS)Nrexpr)r statedocumentset_source_info argumentsr content)selfnoderrrrun.s   z IfConfig.runN) r r r has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacerr __annotations__rrrrrrrr&s  rappdoctreedocnamerc Csdd|jD}||jj|jj|d<|tD]J}z t|d|}Wn0t yW}z$ddl m }d ||j |}|jjd||d } || WYd}~qd}~ww|s`|gq||jqdS) NcSsi|]}|j|jqSr)namevalue).0confvalrrr 8sz*process_ifconfig_nodes..builderrr)format_exception_onlyz.Exception occurred in ifconfig expression: %s) base_node)configupdate__dict__copyr+r&traverser eval Exception tracebackr,join __class__reportererror replace_selfchildren) r#r$r%nsrreserrr,msgnewnoderrrprocess_ifconfig_nodes7s*   rBcCs.|t|dt|dttjddS)Nr zdoctree-resolvedT)versionparallel_read_safe)add_noder add_directiverconnectrBsphinx__display_version__)r#rrrsetupMs    rJ)__doc__typingrrrdocutilsrdocutils.nodesrrHsphinx.applicationrsphinx.util.docutilsrsphinx.util.nodesr sphinx.util.typingr Elementr rrstrrBrJrrrrs