Mercurial > evolve
changeset 5654:034873ca0f88 stable
docs: refactor docs/conf.py a bit
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 06 Jul 2020 00:17:16 +0800 |
parents | 479f76c47295 |
children | 1aec5a3be808 |
files | docs/conf.py |
diffstat | 1 files changed, 23 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- 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):