# HG changeset patch # User Anton Shestakov # Date 1593965836 -28800 # Node ID 034873ca0f88fdd5f06b58f6e4d964d64a535306 # Parent 479f76c47295be405a0153aeb1db70e13563164f docs: refactor docs/conf.py a bit diff -r 479f76c47295 -r 034873ca0f88 docs/conf.py --- a/docs/conf.py Thu Nov 12 13:37:35 2020 +0800 +++ b/docs/conf.py Mon Jul 06 00:17:16 2020 +0800 @@ -2,12 +2,21 @@ # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. from mercurial import demandimport demandimport.disable() + +from os.path import ( + abspath, + dirname, + join, +) + from docutils import nodes from docutils.parsers.rst import Directive -from mercurial import ui -from mercurial import extensions as hgext -from mercurial import commands -import os + +from mercurial import ( + commands, + extensions as hgext, + ui as uimod, +) extensions = ["sphinx.ext.graphviz"] @@ -139,20 +148,17 @@ has_content = True def run(self): - u = ui.ui() - if not hasattr(u, 'disablepager'): + ui = uimod.ui() + if not hasattr(ui, 'disablepager'): return [] - u.disablepager() - u.setconfig( - 'extensions', 'evolve', - os.path.join( - os.path.abspath(os.path.dirname(__file__)), - os.pardir, 'hgext3rd', 'evolve')) - hgext.loadall(u) - u.pushbuffer() - commands.help_(u, self.content[0].encode('utf-8')) - return [ - nodes.literal_block(text=u.popbuffer().decode('utf-8'))] + ui.disablepager() + rootdir = abspath(dirname(dirname(__file__))) + evolvepath = join(rootdir, 'hgext3rd', 'evolve') + ui.setconfig('extensions', 'evolve', evolvepath) + hgext.loadall(ui) + ui.pushbuffer() + commands.help_(ui, self.content[0].encode('utf-8')) + return [nodes.literal_block(text=ui.popbuffer().decode('utf-8'))] def setup(app):