o +a @sdZddlZddlZddlZddlZddlZddlmZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZddlmZddlmZddlmZdd lmZdd lmZmZdd lmZdd lm Z dd l!m"Z"m#Z#ddl!m$Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,ddl-m.Z.m/Z/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8m9Z9ddl:m;Z;ddlZ>ddl?m@Z@ddlAmBZBddlCmDZDmEZEmFZFmGZGmHZHddlImJZJmKZKddlLmMZMddlNmOZOddlPmQZQdd lRmSZSmTZTmUZUdd!lVmWZWmXZXmYZYmZZZdd"l[m\Z\dd#l]m^Z^m_Z_eJrdd$l`maZad%Zbnd&Zbd'ZceEdeeZfegd(Zhd)e d*eifd+d,ZjGd-d.d.eiZkGd/d0d0eiZlGd1d2d2ZmGd3d4d4e)Znd5e'd6e,d*dfd7d8Zod5e'd6e,d*dfd9d:Zpd5e'd;eided*df d?d@Zqd5e'd;eided*df dAdBZrd5e'd;eided*df dCdDZsd5e'd*dfdEdFZtd5e'd6e,d*dfdGdHZud5e'd6e,d*dfdIdJZvd5e'd6e,d*dfdKdLZwd5e'd6e,d*dfdMdNZxGdOdPdPZyeyZzd5e'd6e,d*dfdQdRZ{ddl|Z!ddl}Z!d5e'd*e eie ffdSdTZ~dS)Uz sphinx.builders.html ~~~~~~~~~~~~~~~~~~~~ Several HTML builders. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. N)datetime)path) IOAnyDictIterableIteratorListSetTupleType)quote)nodes) publish_parts) OptionParser) DocTreeInput StringOutput)Node) relative_path)__display_version__ package_dir) version_info)Sphinx)Builder)ENUMConfig)DomainIndex IndexEntry) ImageAdapter) IndexEntries)TocTree) ConfigError ThemeError)PygmentsBridge)___)js_index)HTMLThemeFactory)isurlloggingmd5progress_messagestatus_iterator)is_html5_writer_available new_document) copy_asset) format_date) InventoryFile)DOTFILESMatcherpatmatch)copyfile ensurediros_path relative_uri)Tags)HTMLTranslator HTMLWriter)HTML5TranslatorTFz objects.invz[ ]+objreturncCsNt|tr tt|St|ttfrtdd|D}tt|  S)z Return a stable hash for a Python data structure. We can't just use the md5 of str(obj) since for example dictionary items are enumerated in unpredictable order due to hash randomization in newer Pythons. css|]}t|VqdSN)get_stable_hash).0orD?/usr/lib/python3/dist-packages/sphinx/builders/html/__init__.py Kz"get_stable_hash..) isinstancedictrAlistitemstuplesortedr+strencode hexdigest)r>rDrDrErABs rAc @sbeZdZUdZdZeeefed<dZeed<dZ e ed<dddedede de d df d d Z dS) StylesheetzA metadata of stylesheet. To keep compatibility with old themes, an instance of stylesheet behaves as its filename (str). N attributesfilenamepriorityrTargsr?cOs^t||}||_||_||_|jdd|jdd|r-|d|jd<|d|jd<|S)Nrel stylesheettypeztext/cssrtitle)rN__new__rSrTrR setdefault)clsrSrTrWrRselfrDrDrEr]Zs zStylesheet.__new__) __name__ __module__ __qualname____doc__rRrrN__annotations__rSrTintrr]rDrDrDrErQOs   rQc @sZeZdZUdZdZeeefed<dZeed<dZ e ed<d dede deddfdd Z dS) JavaScriptzA metadata of javascript file. To keep compatibility with old themes, an instance of javascript behaves as its filename (str). NrRrSrTrUr?cKs"t||}||_||_||_|Sr@)rNr]rSrTrR)r_rSrTrRr`rDrDrEr]ts zJavaScript.__new__)rU) rarbrcrdrRrrNrerSrTrfr]rDrDrDrErgis    rgc @speZdZdZededdfddZddgfdeded e e ddfd d Z d dde fd dZ deddfddZdS) BuildInfozbuildinfo file manipulator. HTMLBuilder and its family are storing their own envdata to ``.buildinfo``. This class is a manipulator for the file. fr?c Csz<|}|ddksJ|ddsJ|dds!Jt}|dd|_|dd|_|WStyQ}z t t d||d}~ww) Nrz# Sphinx build info version 1zconfig: ztags: r[zbuild info file is broken: %r) readlinesrstrip startswithrhsplitstrip config_hash tags_hash Exception ValueErrorr&)r_rilines build_infoexcrDrDrEloadszBuildInfo.loadNconfigtagsconfig_categoriescCsHd|_d|_|rdd||D}t||_|r"tt||_dSdS)NcSsi|]}|j|jqSrD)namevalue)rBcrDrDrE sz&BuildInfo.__init__..)rqrrfilterrArM)r`ryrzr{valuesrDrDrE__init__s zBuildInfo.__init__othercCs|j|jko |j|jkSr@)rqrr)r`rrDrDrE__eq__s  zBuildInfo.__eq__cCs|d|j|jfdS)Nz# Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. config: %s tags: %s )writerqrrr`rirDrDrEdumps  zBuildInfo.dump)rarbrcrd classmethodrrxrr:r rNrboolrrrDrDrDrErh}s& rhc s,eZdZUdZdZdZedZdZdZ dZ dZ e Z eed<dZdZgdZdZdZdZdZdZd ZdZd ZdZd Zeed <gZee ee!e"ee eee#fe$fed <d e%dd ffdd Z&dddZ'de(fddZ)defddZ*defddZ+de ee,ffddZ-dddZ.dddZ/ddd Z0d!ed"edd fd#d$Z1dd%d&Z2d!ed"edd fd'd(Z3e4de!e5j6fd)d*Z7e4defd+d,Z8de9efd-d.Z:deefd/d0Z;d1eedd fd5d6Z?d7ed8ed9ede,eeffd:d;Z@d7edZBd7eds  z>StandaloneHTMLBuilder._get_translations_js..localerrzshare/sphinx/locale) ry locale_dirsrrrrsysprefixisfile)r` candidatesjsfilerDrrE_get_translations_jss   z*StandaloneHTMLBuilder._get_translations_jscCs,|jjdur |jjS|jr|jddSdS)NthemerYz default.css)ry html_styler get_configrrDrDrE_get_style_filenames z)StandaloneHTMLBuilder._get_style_filenamecCs|jj|jjfSr@)ry html_themehtml_theme_optionsrrDrDrEget_theme_configz&StandaloneHTMLBuilder.get_theme_configcCsHt|j}|\}}|||_||_||j ||jdSr@) r(rrcreatercopy theme_optionscreate_template_bridge templatesr)r` theme_factory themename themeoptionsrDrDrEr s    z$StandaloneHTMLBuilder.init_templatescCs|jjdur |jj}n|jr|jddd}nd}td||_|jr+|jddd}nd}|durBtd||_|jjddd d dSd|_dS) Nrpygments_stylenonesphinxrpygments_dark_stylepygments_dark.cssz(prefers-color-scheme: dark)pygments_dark_css)mediaid) ryrrrr$ highlighterdark_highlighterr add_css_file)r`style dark_stylerDrDrErs     z&StandaloneHTMLBuilder.init_highlightercCsg|_|jddd|j|dd|jjjD] \}}|j|fi|q|ddD]\}}|dd|j|fi|q,dS)N pygments.cssrVrrrT )rrrrregistryrr^r`rSattrsrDrDrEr(s z$StandaloneHTMLBuilder.init_css_filesrSkwargscKs0d|vr td|}|jt|fi|dSN://_static) posixpathrrappendrQr`rSrrDrDrEr4s z"StandaloneHTMLBuilder.add_css_filecCsg|_|jddddd|jddd|jddd|jd dd|jjjD] \}}|j|fi|q&|d d D]\}}|d d |j|fi|q:|jjr]| r_|ddSdSdS)Nzdocumentation_options.jsdocumentation_optionsr|r)r data_url_rootrTz jquery.jsrVz underscore.jsz doctools.jsjs_filesrrTrtranslations.js) r add_js_filerrrrr^ryrrrrDrDrEr:s z#StandaloneHTMLBuilder.init_js_filescKs4|r d|vr td|}|jt|fi|dSr)rrrrrgrrDrDrErLs  z!StandaloneHTMLBuilder.add_js_filecCstr|jjrtStSr@) html5_readyry html4_writerr;r=rrDrDrEdefault_translator_classRs z.StandaloneHTMLBuilder.default_translator_classcCs\|dd}|dur |St|jjj}t|dkr|dSt|dkr,|d|dSdS)N math_rendererrr[rrjmathjax)rrJrrhtml_inline_math_rendererslenremove)r`r} renderersrDrDrEmath_renderer_nameYs    z(StandaloneHTMLBuilder.math_renderer_namec csz4tt|jd }t|}Wdn1swY|j|kr4td|j j EdHWdSWn"t yO}zt t d|WYd}~n d}~wtyWYnw|jra|j}nd}|j j D]b}||j jvrytd||Vqg||}zt|}Wn tyd}Ynwz/tt|j ||}||krtd|t|t||tt|j ||VWqgtyYqgwdS)N .buildinfoz)[build target] did not match: build_info z"Failed to read build info file: %rrz![build target] did not in env: %rz>[build target] targetname %r(%s), template(%s), docname %r(%s))openrroutdirrhrxrvloggerdebugenv found_docsrtwarningr&OSErrorrnewest_template_mtimeall_docsget_outfilenamegetmtimersmaxdoc2pathrutcfromtimestamp) r`fp buildinforwtemplate_mtimedocname targetname targetmtimesrcmtimerDrDrEget_outdated_docsmsb           z'StandaloneHTMLBuilder.get_outdated_docscCs|jj|jjSr@)ryhtml_extra_pathhtml_static_pathrrDrDrEget_asset_pathsrz%StandaloneHTMLBuilder.get_asset_pathsnodecCs@|durddiStd}||t|}td|tddi|dS) z$Utility: Render a lone doctree node.Nfragmentr|zdoctreeoutput_encodingunicode) reader_namewriter source_classsettings_overridessource)r/rr<rr)r`r docrrDrDrErender_partials z$StandaloneHTMLBuilder.render_partialdocnamescCs&d|_|jr*ddlm}|jjp|jj}|sd}||j||jj|jj |_| |t ||_ t |jj|j fdd|_t|jj|j_g|_|jj}|rt|jjD]4}|jj|}|jD](}d|j|jf}t|trs||vrsq_||\} } | r|j||| | fq_qT|jj} | durt| pt d|jjd|_!nd|_!|jj"pd } |jj#pd } t$| st%&| } t$| st%&| } |j'|_(g}|j)r|d t d d t d f|jD]\}}} } |j*r|||j+d |j*fqt|j,|_-t|j.|_/id|j0d|jj1dt23d |jj4d|jj5d|j!d|jj6d|jj7d|jj7d|jj8d|jj9d|jj:d|jj;d|jj<d|jj=d|jj>d|jj?d|j@|jA|j,|jj|j.tBtC|D||jg| | tEon|jjF d |_G|jHr|jGId d!|jHJ|jKLD|jGI|jjMdS)"Nr) IndexBuilderenT)defaults componentsread_config_filesz%s-%sz %b %d, %Y)rr|genindexz General IndexIindexembeddedprojectreleaseversion last_updated copyright master_docroot_docuse_opensearch docstitle shorttitleshow_copyright show_sphinx has_source show_sourcesourcelink_suffixr) rrrrsphinx_versionsphinx_version_tuplerrellinksbuilderparentslogofavicon html5_doctypecss |] \}}d||fVqdS)theme_NrD)rBkeyvalrDrDrErFs z8StandaloneHTMLBuilder.prepare_writing..)Nindexersearch sphinx.searchrryhtml_search_languagerrhtml_search_optionshtml_search_scorer load_indexerr< docwriterrsettingsget_default_values docsettingsrhtml_compact_lists compact_listsrhtml_domain_indicesrMdomainsindicesr}rHrJgeneraterhtml_last_updated_fmtr1r%r# html_logo html_faviconr)rbasenamecollect_relations relationsr shortname localnamer _script_filesr _css_filesrr return_codes_resubr!r"r$r&html_use_opensearch html_titlehtml_short_titlehtml_show_copyrighthtml_show_sphinxhtml_copy_sourcehtml_show_sourcelinkhtml_sourcelink_suffixrrrr/rrr globalcontextrupdate get_optionsrrK html_context)r`rrlangindices_config domain_namedomainindexcls indexnamecontentcollapselufmtr4r5r1rDrDrEprepare_writings                         z%StandaloneHTMLBuilder.prepare_writingrbodymetatagsc CsTd}}g}|jddd}|j|}|jj} |rP|drPz%|||d|| |ddd}||d|ddtdfWn t yOd}Ynw|r|drz%|||d|| |ddd}||d|dd td fWn t yd}Ynw|r|d rz||||d || |d ddWn t yYnw|j|d }|r|d s|r| | |jj |} | r|| dnd } |j |d t|d} |jjr|| } | |jjkr| |jj7} nd } |jj|}t|j||}||d}|||| ||||| ||jj|dk| d S)z1Collect items for the template context of a page.Nr1rjr\)linkr\Nnextr[Ppreviousrr|Fr ) r3prevrqr\metarmrnr1 sourcenametoc display_tocpage_source_suffix)r_rPgetrtitlesget_relative_urirrr%KeyErrorpopreverse longtitlesrrryr\r^metadatar! get_toc_fortoc_num_entries)r`rrmrnrtrqr3r1relatedr{ title_noder\ source_suffixrvruself_tocrwrDrDrEget_doc_contexts~  "  "      z%StandaloneHTMLBuilder.get_doc_contextr cCstdd}|j|_|jj|i|_|jj|i|_t | |d|_ t | |d|_ ||_ |j|||j|jjd}|jj}||||}|j|||ddS)Nutf-8encodingr _downloadsr ) event_arg)rrDrBrtoc_secnumbersrzrtoc_fignumbers fignumbersr9get_target_urirdlpathrrArassemble_partsparts clean_metar handle_page)r`rr  destinationrmrnctxrDrDrE write_docis   zStandaloneHTMLBuilder.write_doccCsTt|||j|_|||jj|}|r||dnd}| |||dS)Nr\r|) r9rrrpost_process_imagesrrrzr index_page)r`rr rr\rDrDrEwrite_doc_serializedzs  z*StandaloneHTMLBuilder.write_doc_serializedcCs||j|j|j|j|j|j|j|j|j|j|j|j|j|j|j|j | dSr@) finish_tasksadd_task gen_indicesgen_pages_from_extensionsgen_additional_pagescopy_image_filescopy_download_filescopy_static_filescopy_extra_fileswrite_buildinfo handle_finishrrDrDrEfinishs zStandaloneHTMLBuilder.finishzgenerating indicescCs|jr||dSr@)rwrite_genindexwrite_domain_indicesrrDrDrErs z!StandaloneHTMLBuilder.gen_indicescCs4|jdD]}|D] \}}}||||q qdS)Nhtml-collect-pages)eventsemitr)r`pagelistpagenamecontexttemplaterDrDrErs z/StandaloneHTMLBuilder.gen_pages_from_extensionszwriting additional pagescCs|jjD]\}}tj|ddd||i|q|jr,tjddd|did|jjrM|jrOtjdddt |j dd }|jd id |d dSdSdS) N Tnonlzsearch r;z search.htmlz opensearch rzopensearch.xml opensearch) outfilename) ryhtml_additional_pagesrKrinforr;rWrrr)r`rrfnrDrDrErsz*StandaloneHTMLBuilder.gen_additional_pagesc Cst|j|}g}|D]\}}|tdd|Dq |||jjd}tjddd|jjr\| d|d| d |d t ||D]\\}}}||||d }| d ||d qCdS| d|d dS)Ncss&|]\}\}}}dt|VqdS)r[N)r)rBr%subitemsrDrDrErFs z7StandaloneHTMLBuilder.write_genindex..)genindexentriesgenindexcounts split_indexz genindex Trrzgenindex-split.htmlz genindex-allz genindex.html)r8entriescountrz genindex-zgenindex-single.html) r r create_indexrsumryhtml_split_indexrrrzip) r`r indexcounts_krgenindexcontextr8rrrDrDrErs6    z$StandaloneHTMLBuilder.write_genindexcCsF|jD]\}}}}|j||d}tj|ddd|||dqdS)N) indextitlericollapse_indexrTrzdomainindex.html)rrRrrr)r`rhrgrirj indexcontextrDrDrErsz*StandaloneHTMLBuilder.write_domain_indicesc Cs|jrat|jjj}tt|j|j t |jt ddt |j|jj |dD]<}|j|}ztt|j|t|j|j |Wq&ty`}ztt dt|j||WYd}~q&d}~wwdSdS)Nzcopying images... brownstringify_funczcannot copy image file %r: %s)imagesrrrget_original_image_urir7rrrrr-r&r verbosityr6srcdirrsrr)r`rsrcdesterrrDrDrErs(  z&StandaloneHTMLBuilder.copy_image_filesc sdtdtffdd }jjrpttjdtjjtddt jjj j |dD]E}z!tjdjj|d }tt |t tj||Wq,tyo}zttd tj||WYd}~q,d}~wwdSdS) Nrir?cs tj|Sr@)rr)rirrDrE to_relpaths z=StandaloneHTMLBuilder.copy_download_files..to_relpathrzcopying downloadable files... rrr[z$cannot copy downloadable file %r: %s)rNrdlfilesr7rrrr-r&rrrdirnamer6rrrr)r`rrrrrDrrErs&  z)StandaloneHTMLBuilder.copy_download_filescCstt|jddd}||jWdn1swY|jrLtt|jddd}||jWddS1sEwYdSdS)z!create a style file for pygments.rrwNr)rrrrrrget_stylesheetrrrDrDrEcreate_pygments_style_files"z0StandaloneHTMLBuilder.create_pygments_style_filecCs:|jjdur|}|rt|t|jdddSdSdS)z(Copy a JavaScript file for translations.Nrr)ryrrr6rrrr`rrDrDrEcopy_translation_jss z)StandaloneHTMLBuilder.copy_translation_jsc Csv|jdur7t|jdr#|jD]}t|t|jdt|qdS|j}|r9t|t|jdddSdSdS)z#Copy a JavaScript file for stemmer.Nget_js_stemmer_rawcodesrz _stemmer.js) r:hasattrrr6rrrrNget_js_stemmer_rawcoderrDrDrEcopy_stemmer_jss   z%StandaloneHTMLBuilder.copy_stemmer_jsrc Csfdtdtddfdd}|jr/|jdddD]}tt|dt|jdt||j |d qdSdS) NrSerrorr?cSttd||dSNz1Failed to copy a file in html_static_file: %s: %rrrr&rSrrDrDrEonerror z>StandaloneHTMLBuilder.copy_theme_static_files..onerrorstaticr)excludedrrendererr) rNrsrget_theme_dirsr0rrrr3r)r`rrentryrDrDrEcopy_theme_static_filess  z-StandaloneHTMLBuilder.copy_theme_static_filesc Csddtdtddfdd}t|jjdg}|jjD]}tt|j |t|j d|||j |dqdS) NrSrr?cSrrrrrDrDrErrz=StandaloneHTMLBuilder.copy_html_static_files..onerrorz**/.*r)rrr) rNrsr4ryexclude_patternsrr0rrconfdirrr)r`rrrrrDrDrEcopy_html_static_filess   z,StandaloneHTMLBuilder.copy_html_static_filescCB|jjrt|jjstt|j|jjt|jddSdSdSNr)ryrLr)r0rrrrrrDrDrEcopy_html_logo)  z$StandaloneHTMLBuilder.copy_html_logocCrr)ryrMr)r0rrrrrrDrDrEcopy_html_favicon.rz'StandaloneHTMLBuilder.copy_html_faviconc CszTttdCtt|jd|j}|jdur#| |j | | | ||||||WdWdS1sMwYWdStyo}zttd|WYd}~dSd}~ww)Nzcopying static filesrzcannot copy static file %r)r,r&r7rrrr_rr:r`context_for_searchtoolrrrrrrrrrr)r`rrrDrDrEr3s$     &z'StandaloneHTMLBuilder.copy_static_filesc Csz6ttd%t|jj}|jjD]}t|j|}t ||j |qWdWdS1s/wYWdSt yQ}zt td|WYd}~dSd}~ww)zcopy html_extra_path files.zcopying extra filesNzcannot copy extra file %r)r,r&r4ryrrrrrr0rrrr)r`r extra_pathrrrDrDrErGs  &z&StandaloneHTMLBuilder.copy_extra_filesc Csz%tt|jdd}|j|WdWdS1swYWdSty@}ztt d|WYd}~dSd}~ww)Nrrz#Failed to write build info file: %r) rrrrrvrrrrr&)r`rrwrDrDrErRs&z%StandaloneHTMLBuilder.write_buildinfocCs|jr |jdSdSr@)rcleanuprrDrDrErYszStandaloneHTMLBuilder.cleanupcst|||jjr]|jr_|tjD]MtfdddDs!qtj tj r)qddvr0qd}tj dddd }||j vrNt |j|j ||d <n||d <||qd Sd Sd S) zlPick the best candidate for an image and link down-scaled images to their high res version. c3|]}|vVqdSr@rD)rBr8r rDrErFfrGz.)scalewidthheightzno-scaled-linkclassesurir|T)internalrefuriN)rrryhtml_scaled_image_linktraverserimageanyrHparent referencerrrr replace_selfr)r`r rrrDrrEr^s(      z)StandaloneHTMLBuilder.post_process_imagesc Cst|jjt|}zIt|j|j}|jr5t|dd}|j ||j Wdn1s/wYnt|d}|j ||j Wdn1sMwYWnt t fyg|rettdYnw|j |dS)Nrrrbzcsearch index couldn't be loaded, but not all documents will be built: the index will be incomplete.)setrrrrrsearchindex_filenameindexer_dumps_unicoderr:rxrrrtrrr&prune)r`rkeep searchindexfnftfbrDrDrEr@{s$ z"StandaloneHTMLBuilder.load_indexerrr\cCsn|jdur3|r5|jj|dd}|jj|i}d|vr(|j||dtddS|j||||dSdSdS)N)basenosearchr|)r:rrrrzfeedr/)r`rr r\rSrrDrDrErsz StandaloneHTMLBuilder.index_pagerjcKsNd|vrd|d<|ddkr|d|t|jj|||fi|dS)N includehiddenFmaxdepthr|r )rzr~rr!rget_toctree_for)r`rrjrrDrDrE_get_local_toctrees z(StandaloneHTMLBuilder._get_local_toctreecCst|jt||jSr@)rrrr8r)r`rrDrDrErsz%StandaloneHTMLBuilder.get_outfilenamerc Csdtdtfdd}d}d}d}|jjdkr9z|jjdd}|r*dd |d D}Wn!ty8gd }Ynw|jddd}|rMd d |d D}| dd }| D]"\} } t || ry|ru|| ru||rtt td||| qW| }| }qW|dur ||d<||d<dS)Npatternr?cstfdddDS)Nc3rr@rD)rBcharrrDrErFrGzKStandaloneHTMLBuilder.add_sidebars..has_wildcard..z*?[)rrrDrrE has_wildcardsz8StandaloneHTMLBuilder.add_sidebars..has_wildcard alabasterrsidebarscSg|]}|qSrDrprBr}rDrDrErz6StandaloneHTMLBuilder.add_sidebars..,)z about.htmlznavigation.htmlzrelations.htmlzsearchbox.htmlz donate.htmlcSrrDr r!rDrDrErr"rz8page %s matches two patterns in html_sidebars: %r and %r customsidebar)rNrrr}ryrzrorsrrrKr5rrr&) r`rrrrmatchedr$theme_default_sidebars html_sidebarsr patsidebarsrDrDrE add_sidebarssB       z"StandaloneHTMLBuilder.add_sidebarstypcCst||jSr@)r r)r`rr*rDrDrErsz$StandaloneHTMLBuilder.get_target_uri page.htmladdctx templatenamerrc sj}|d<|d<jj|d<}|ddd}jjr2tjjj |d<nd|d<d|fd t d t d t d t ffd d }||d<dt d t ffdd } | |d<fdd|d< || |jjdd<jjdd<|||jd|||} | r| }ztt|dddd|d<Wn tyYnwztt|dddd|d<Wn tyYnwz j||} Wn(tyttdYdSty} z ttd| f| d} ~ ww|s }t!t"#|z"t$|d|dd d! } | %| Wdn 1s&wYWnt&yH}zttd"||WYd}~nd}~wwj'rq|(d#rst"j)d$t*|d#}t!t"#|t+j,-|dSdSdS)%Nrcurrent_page_namer#r[rpageurlFotheruriresourcebaseurir?csB|rd|vr|S|s|}t||pd}|dkrjs|}|S)Nrr/)rr9allow_sharp_as_current_path)r1r2r3rrrDrEpathtos  z1StandaloneHTMLBuilder.handle_page..pathtor5r}cs>|jjvrdS|dkrjrdS|dkrddrdSdS)NTr;rrrF)rrr;r)r}rrDrEhasdocs z1StandaloneHTMLBuilder.handle_page..hasdocr6csjfi|Sr@)r)rrr`rDrEsz3StandaloneHTMLBuilder.handle_page..toctreehtml-page-contextrcS|jSr@rV)jsrDrDrEr8)r8rcSr;r@rV)cssrDrDrEr8r=za Unicode error occurred when rendering the page %s. Please make sure all config values that contain non-ASCII content are Unicode strings.z6An error happened in rendering the page %s. Reason: %rrxmlcharrefreplace)rerrorszerror writing file %s: %srv_sources).r_rryhtml_output_encodingrrsplit html_baseurlrrrrNrr)r`rSrrTrupdate_page_contextremit_firstresultrMrJAttributeErrorrrender UnicodeErrorrrr&rsr#rr7rrrrr copysourcerzrr8r6rr)r`rr,r-rrrdefault_baseurir5r6newtmploutputrwrir source_namerDr7rErs     $               z!StandaloneHTMLBuilder.handle_pagecCsdSr@rD)r`rr-rrrDrDrErE:sz)StandaloneHTMLBuilder.update_page_contextcCs&|jr |j|j|j|jdSr@)r:rrdump_search_indexdump_inventoryrrDrDrEr>sz#StandaloneHTMLBuilder.handle_finishzdumping object inventorycCstt|jt|j|dSr@)r2rrrrINVENTORY_FILENAMErrrDrDrErPCsz$StandaloneHTMLBuilder.dump_inventoryc Csttd|je|j|jjt|j |j }|j rAt |dddd}|j ||jWdn1s;wYnt |dd}|j ||jWdn1s[wYt|d|WddS1sswYdS)Nzdumping search index in %sz.tmprrrwb)r,r&r:labelr rrrrrr r rrrosreplace)r`rrrrDrDrErOGs"z'StandaloneHTMLBuilder.dump_search_index)r?N)Tr@)r+NN)frarbrcrdr}formatr&epilogrJallow_parallelrrr'rrrer rsupported_image_typessupported_remote_imagessupported_data_uri_imagesr add_permalinksr4rr;rdownload_supportrrNrr r r rrrrrrrhrrrrrrrrrrrpropertyr NodeVisitorrrrrr rrr rlrdocumentrrrr,rrrrrrrrrrrrrrrrrrrrr@rrrr)rrrErrPrO __classcell__rDrDrrErs   0     ."mP                4 a   rrryc Cpg}|jD]-}t|tr||ifqz |\}}|||fWqty2ttd|Yqw||_dS)z?This converts string styled html_css_files to tuple styled one.zinvalid css_file: %r, ignoredN)html_css_filesrHrNrrsrrr&)rryrcrrSrrDrDrEconvert_html_css_filesV    rdc Crb)z>This converts string styled html_js_files to tuple styled one.zinvalid js_file: %r, ignoredN) html_js_filesrHrNrrsrrr&)rryrfrrSrrDrDrEconvert_html_js_filesgrergrr-rr c,|ddtdtffdd }||d<dS)zySet up css_tag() template helper. .. note:: This set up function is added to keep compatibility with webhelper. r5r>r?c sfg}t|jD]}|j|}|dur|d|t|dfq|d|jdddd|S)N%s="%s"Tz href="%s"r2z r)rMrRrrescaperSr)r>rr8r~r5rDrEcss_tags z%setup_css_tag_helper..css_tagrmN)rzrQrN)rrr-rr rmrDrlrEsetup_css_tag_helperxs  rncrh)zxSet up js_tag() template helper. .. note:: This set up function is added to keep compatibility with webhelper. r5r<r?c sg}d}t|trNt|jD]/}|j|}|dur=|dkr |}q|dkr0|ddddq|d|t|dfq|jrM|d|jddn |d|dd|rdd d ||fSd |S) Nr|rmrzdata-url_root="%s"Trjrizsrc="%s"zrz) rHrgrMrRrrrkrSr)r<rrmr8r~rlrDrEjs_tags&  z#setup_js_tag_helper..js_tagroN)rzrgrN)rrr-rr rorDrlrEsetup_js_tag_helpers  rpcCsx|d}|d}|rt|s|d|dd|d<n||d<|d}|r6t|s6|d|dd|d<d S||d<d S) zSet up relative resource paths.r5r5z_static/Trj favicon_urlr4logo_urlN)rzr))rrr-rr r5r5r4rDrDrEsetup_resource_pathss      rscCsL|jjdkrdS|jj}|durttd||jjvr$ttd|dS)NrzEMany math_renderers are registered. But no math_renderer is selected.z"Unknown math_renderer %r is given.)r2rVrr"r&rr)rr}rDrDrEvalidate_math_renderers   rtcC|jddD]H}tt|j|}t|s'ttd||j |qt |j dt |dkrOt |j |g|j krOttd||j |qdS)zCheck html_extra_paths setting.Nz'html_extra_path entry %r does not existrz0html_extra_path entry %r is placed inside outdir) rrnormpathrrexistsrrr&r splitdriver commonpath)rryrrrDrDrEvalidate_html_extra_path  rzcCru)z Check html_static_paths setting.Nz(html_static_path entry %r does not existrz1html_static_path entry %r is placed inside outdir) rrrvrrrwrrr&rrxrry)rryr static_pathrDrDrEvalidate_html_static_pathr{r}cCN|jr!tt|j|js#t|js%ttd|jd|_dSdSdSdS)zCheck html_logo setting.zlogo file %r does not existN) rLrrrrr)rrr&rryrDrDrEvalidate_html_logo  rcCr~)zCheck html_favicon setting.zfavicon file %r does not existN) rMrrrrr)rrr&rrDrDrEvalidate_html_faviconrrc@seZdZddZdS)_stable_repr_objectcCsdS)NzrDrrDrDrE__repr__sz_stable_repr_object.__repr__N)rarbrcrrDrDrDrErs rcCs>|j}|tur dSttd|sd|_dSt||_dS)z0Migrate html_add_permalinks to html_permalinks*.Nzrhtml_add_permalinks has been deprecated since v3.5.0. Please use html_permalinks and html_permalinks_icon instead.F) html_add_permalinksUNSETrrr&html_permalinksrrkhtml_permalinks_icon)rryrrDrDrEmigrate_html_add_permalinkss rcCsP|t|ddd|dgd|did|ddddtg|d d dd|d ddtg|d ddtg|d ddtg|dgd|dgd|dgd|dgd|dddtg|did|did|dddtg|dtd|ddd|ddd|ddd|ddd|ddd|ddd|d d!d|d"d#d|d$ddtg|d%ddtg|d&dd|d'dd|d(id|d)d*d|d+dd|d,d-d|d.ddtg|d/id|d0d#d|d1dd|d2d#d|d3d4dtd5d4|d6dd7|d8dd|d9|d:|jd;t dt|d:t|d:t|d:t|d?|d@dAdddBS)CNrrrhtml_theme_pathrrXcSstd|j|jfS)Nz%s %s documentation)r%r r!rrDrDrEr8#r"zsetup..rYcSr;r@)rXrrDrDrEr8%r=rrLrMrcrfrrrKr'rrGTrrr¶html_use_indexrFr\r]r^z.txtrWr|rrrZr[rbrBrrEhtml_secnumber_suffixz. r=r>r?rrDhtml_codeblock_linenos_styleinlinetablehtml_math_rendererrrrr:z config-initedrrVzbuilder-initedzsphinx.ext.mathjaxzsphinx.builders.html.transformsbuiltin)r"parallel_read_safeparallel_write_safe) add_builderradd_config_valuerNrJrr add_eventconnectrdrgrrzr}rrrtrnrprssetup_extension)rrDrDrEsetups          r)rdrrTrrerrrtypingrrrrrr r r r urllib.parser docutilsr docutils.corerdocutils.frontendr docutils.iorrdocutils.nodesrdocutils.utilsrrrrrr/sphinx.applicationrsphinx.buildersr sphinx.configrrsphinx.domainsrrr!sphinx.environment.adapters.assetr(sphinx.environment.adapters.indexentriesr #sphinx.environment.adapters.toctreer! sphinx.errorsr"r#sphinx.highlightingr$ sphinx.localer%r&r<r'sphinx.themingr( sphinx.utilr)r*r+r,r-sphinx.util.docutilsr.r/sphinx.util.fileutilr0sphinx.util.i18nr1sphinx.util.inventoryr2sphinx.util.matchingr3r4r5sphinx.util.osutilr6r7r8r9sphinx.util.tagsr:sphinx.writers.htmlr;r<sphinx.writers.html5r=rrQ getLoggerrarcompilerUrNrArQrgrhrrdrgrnrprsrtrzr}rrrrrsphinx.builders.dirhtmlsphinx.builders.singlehtmlrrDrDrDrEs   ,                       .2  #