o $a$ @sdZddlZddlmZddlmZmZmZmZmZm Z ddl m Z ddl m Z ddlmZddlmZdd lmZmZdd lmZdd lmZdd lmZdd lmZddlmZddlm Z m!Z!ddl"m#Z#m$Z$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/m0Z0m1Z1ddl2m3Z3m4Z4e#5e6Z7ej8eddZ9GdddeZ:dedeee;e;e;e;e;e;e;ffddZs  zTexinfoBuilder.get_target_urifrom_tocCs |||Sr')r3)r+r4r5r1r,r,r-get_relative_uriDs zTexinfoBuilder.get_relative_uricCsdd|jjD}|sttddSg|_|D]2}|d}||jjvr.ttd|q|j || t drA|dd}|j ||dfqdS) NcSsg|]}t|qSr,)list).0xr,r,r- Isz5TexinfoBuilder.init_document_data..zGno "texinfo_documents" config value found; no documents will be writtenrz?"texinfo_documents" config value references unknown document %sindex) configtexinfo_documentsloggerwarningrtitlesenvall_docsr)appendendswithr)r+preliminary_document_dataentryr0r,r,r-init_document_dataHs"    z!TexinfoBuilder.init_document_dataignoredc Gs||jD]}|dd\}}}}|d7}d}}} t|dkr,|dd\}}} d} t|dkr8|d} tt|j|dd} ttd ||j j pQg} |j || | d } Wdn1sdwYttd U| | t |}t|jj|fd d }||_||_|ddd|_|j j|_|pd|_| pd|_|pd|_||_|| _|| | ||ddWdn1swYqdS)Nz.texiFzutf-8)destination_pathencodingz processing %s) appendiceswritingT)defaults componentsread_config_filesr<z.info)rIr)lenr rjoinoutdirrrr>texinfo_appendicesassemble_doctreepost_process_imagesr!r rCsettingsget_default_valuesauthortitletexinfo_filenametexinfo_elementstexinfo_dir_entrytexinfo_dir_categorytexinfo_dir_descriptionr0writecopy_image_files)r+rJrHr0 targetnamer_r^direntry descriptioncategory toctree_only destinationrQdoctree docwriterr\r,r,r-re[sT            zTexinfoBuilder.write indexfilerkrQc Cst|g||_tjt|ddd|j|}||d<|rBtd}t }|t dd7}||7}| t j D]}||7}q9|}t||j||t|g}||d<|D]} |j| } | | d<|| qStdttd|j|||| t jD]E} | d } | d } t| | g} |jD]*\}}| |r| ttd td | t||| td d nq | | q|S) N Tnonlr0zzrLzresolving references... refdocname refsectnamez (in ))setr(r@inforrC get_doctreerr sectionr_traverser toctreerrErresolve_references pending_xrefemphasisrB startswithTextr replace_self)r+rorkrQtreenew_treenew_sectnode largetreer0appendix pendingnodesectnamenewnodessubdirr_r,r,r-rZsN        zTexinfoBuilder.assemble_doctreecCs |dSr')copy_support_filesr*r,r,r-finishs zTexinfoBuilder.finishrgc Cs|jrat|jjj}t|jtddt|j|jj|dD]F}|j|}zt |j |d}t |t t |j|t ||Wqty`}zttdt |j||WYd}~qd}~wwdSdS)Nzcopying images... brown)stringify_funcz-figureszcannot copy image file %r: %s)imagesrapprCget_original_image_urirrrV verbosityrrWrXrrsrcdir Exceptionr@rA)r+rgrsrcdestimagedirerrr,r,r-rfs*   zTexinfoBuilder.copy_image_filesc Csz-ttdtjdddttjtd|j WdWdS1s&wYWdSt yH}zt td|WYd}~dSd}~ww)Nzcopying Texinfo support filesz Makefile TrqMakefilezerror writing file Makefile: %s) rrr@rwrosrrW template_dirrXOSErrorrA)r+rr,r,r-rs&z!TexinfoBuilder.copy_support_files)r&Nr')__name__ __module__ __qualname____doc__nameformatrepilogrsupported_image_typesr default_translator_classr.rstrrr/r3r6rIrreboolr documentrZrrfrr,r,r,r-r$'s&     % *r$r>r&cCs$t|j}|j||j|j|ddfgS)z, Better default texinfo_documents settings. zOne line description of project Miscellaneous)rprojectroot_docr^)r>filenamer,r,r-default_texinfo_documentss rrcCsn|t|dtd|dgd|did|dddtg|ddd|dd dd ddd S) Nr?rYratexinfo_domain_indicesTtexinfo_show_urlsfootnotetexinfo_no_detailmenuFbuiltin)versionparallel_read_safeparallel_write_safe) add_builderr$add_config_valuerr7)rr,r,r-setups r)>rrrtypingrrrrrrdocutilsr docutils.frontendr docutils.ior docutils.nodesr sphinxr rsphinx.applicationrsphinx.buildersr sphinx.configr!sphinx.environment.adapters.assetr sphinx.errorsr sphinx.localerr sphinx.utilrrrsphinx.util.consolersphinx.util.docutilsrsphinx.util.fileutilrsphinx.util.nodesrsphinx.util.osutilrrrsphinx.writers.texinfor r! getLoggerrr@rWrr$rrrr,r,r,r-s8                (