o $a @sdZddlmZddlmZmZmZmZmZddl m Z ddl m Z ddl mZddlmZddlmZdd lmZdd lmZmZdd lmZmZeeZGd d d eZdedeeeffddZ dS)z sphinx.builders.text ~~~~~~~~~~~~~~~~~~~~ Plain-text Sphinx builder. :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. )path)AnyDictIteratorSetTuple) StringOutput)Node)Sphinx)Builder)__)logging) ensurediros_path)TextTranslator TextWriterc@seZdZUdZdZedZdZdZe Z dZ e e d<ddd Zdee fd d Zdd e d e de fddZdee ddfddZd e deddfddZdddZdS) TextBuildertextz!The text files are in %(outdir)s.z.txtTNcurrent_docnamereturncCs i|_dSN) secnumbersselfr6/usr/lib/python3/dist-packages/sphinx/builders/text.pyinit&s zTextBuilder.initc cs|jjD]D}||jjvr|Vqt|j||j}zt|}Wn ty-d}Ynwzt|j |}||kr?|VWqt yIYqwdS)Nr) env found_docsall_docsrjoinoutdir out_suffixgetmtime Exceptiondoc2pathOSError)rdocname targetname targetmtimesrcmtimerrrget_outdated_docs*s(    zTextBuilder.get_outdated_docsr'typcCsdS)Nr)rr'r,rrrget_target_uri<zTextBuilder.get_target_uridocnamescCst||_dSr)rwriter)rr0rrrprepare_writing?szTextBuilder.prepare_writingdoctreec Cs||_|jj|i|_tdd}|j||t |j t ||j }t t|z#t|ddd}||jjWdWdS1sGwYWdStyj}zttd||WYd}~dSd}~ww)Nzutf-8)encodingwzerror writing file %s: %s)rrtoc_secnumbersgetrrr1writerr r!rr"rdirnameopenoutputr&loggerwarningr )rr'r3 destination outfilenameferrrrr write_docBs & zTextBuilder.write_doccCsdSrrrrrrfinishOr/zTextBuilder.finish)rNr)__name__ __module__ __qualname__nameformatr epilogr"allow_parallelrdefault_translator_classrstr__annotations__rrr+r.rr2r rBrCrrrrrs    rapprcCsN|t|ddd|ddd|ddd|dd dd ddd S) Ntext_sectioncharsz*=-~"+`r text_newlinesunixtext_add_secnumbersTtext_secnumber_suffixz. builtin)versionparallel_read_safeparallel_write_safe) add_builderradd_config_value)rNrrrsetupSs rZN)!__doc__osrtypingrrrrr docutils.iordocutils.nodesr sphinx.applicationr sphinx.buildersr sphinx.localer sphinx.utilr sphinx.util.osutilrrsphinx.writers.textrr getLoggerrDr<rrLrZrrrrs        8