From bb8dcb5ceea378368084567354f70fffcd5d5f42 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 12 Jan 2017 02:43:18 +0900 Subject: [PATCH 1/6] Fix code styles --- sphinx/builders/websupport.py | 2 +- sphinx/environment/managers/toctree.py | 2 +- sphinx/writers/latex.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sphinx/builders/websupport.py b/sphinx/builders/websupport.py index 1154b3419..2ed37a697 100644 --- a/sphinx/builders/websupport.py +++ b/sphinx/builders/websupport.py @@ -141,7 +141,7 @@ class WebSupportBuilder(PickleHTMLBuilder): # "show source" link if ctx.get('sourcename'): source_name = path.join(self.staticdir, - '_sources', os_path(ctx['sourcename'])) + '_sources', os_path(ctx['sourcename'])) ensuredir(path.dirname(source_name)) copyfile(self.env.doc2path(pagename), source_name) diff --git a/sphinx/environment/managers/toctree.py b/sphinx/environment/managers/toctree.py index 67fbfa7b6..2c8ae5300 100644 --- a/sphinx/environment/managers/toctree.py +++ b/sphinx/environment/managers/toctree.py @@ -417,7 +417,7 @@ class Toctree(EnvironmentManager): subnode.parent.remove(subnode) else: # recurse on visible children - self._toctree_prune(subnode, depth+1, maxdepth, collapse) + self._toctree_prune(subnode, depth+1, maxdepth, collapse) def assign_section_numbers(self): """Assign a section number to each heading under a numbered toctree.""" diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 70a9c6f68..7f1c8dc42 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1700,14 +1700,14 @@ class LaTeXTranslator(nodes.NodeVisitor): elif type == 'pair': p1, p2 = [self.encode(x) for x in split_into(2, 'pair', string)] self.body.append(r'\index{%s!%s%s}\index{%s!%s%s}' % - (p1, p2, m, p2, p1, m)) + (p1, p2, m, p2, p1, m)) elif type == 'triple': p1, p2, p3 = [self.encode(x) for x in split_into(3, 'triple', string)] self.body.append( r'\index{%s!%s %s%s}\index{%s!%s, %s%s}' r'\index{%s!%s %s%s}' % - (p1, p2, p3, m, p2, p3, p1, m, p3, p1, p2, m)) + (p1, p2, p3, m, p2, p3, p1, m, p3, p1, p2, m)) elif type == 'see': p1, p2 = [self.encode(x) for x in split_into(2, 'see', string)] self.body.append(r'\index{%s|see{%s}}' % (p1, p2)) From 60d4846e0fa4ec0e76ed6c963d13f74015939875 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 12 Jan 2017 10:07:05 +0900 Subject: [PATCH 2/6] Fix flake8 violations --- setup.cfg | 2 +- sphinx/application.py | 6 +++--- sphinx/builders/changes.py | 2 +- sphinx/builders/html.py | 6 +++--- sphinx/builders/htmlhelp.py | 10 +++++----- sphinx/builders/latex.py | 6 +++--- sphinx/builders/qthelp.py | 16 ++++++++-------- sphinx/builders/texinfo.py | 4 ++-- sphinx/directives/code.py | 6 +++--- sphinx/directives/other.py | 4 ++-- sphinx/domains/c.py | 6 +++--- sphinx/domains/cpp.py | 4 ++-- sphinx/domains/javascript.py | 2 +- sphinx/domains/python.py | 2 +- sphinx/domains/std.py | 4 ++-- sphinx/environment/__init__.py | 2 +- sphinx/environment/managers/toctree.py | 8 ++++---- sphinx/ext/autosummary/__init__.py | 12 ++++++------ sphinx/ext/doctest.py | 4 ++-- sphinx/ext/imgmath.py | 2 +- sphinx/ext/intersphinx.py | 12 ++++++------ sphinx/ext/pngmath.py | 2 +- sphinx/ext/todo.py | 2 +- sphinx/make_mode.py | 2 +- sphinx/pycode/__init__.py | 2 +- sphinx/pycode/nodes.py | 4 ++-- sphinx/quickstart.py | 8 ++++---- sphinx/roles.py | 4 ++-- sphinx/transforms/i18n.py | 4 ++-- sphinx/util/__init__.py | 12 ++++++------ sphinx/util/console.py | 4 ++-- sphinx/util/nodes.py | 8 ++++---- sphinx/util/osutil.py | 2 +- sphinx/util/parallel.py | 4 ++-- sphinx/util/stemmer.py | 16 ++++++++-------- sphinx/websupport/search/__init__.py | 2 +- sphinx/writers/html.py | 4 ++-- sphinx/writers/latex.py | 2 +- sphinx/writers/manpage.py | 2 +- sphinx/writers/texinfo.py | 12 ++++++------ sphinx/writers/text.py | 12 ++++++------ 41 files changed, 114 insertions(+), 114 deletions(-) diff --git a/setup.cfg b/setup.cfg index 73ac1e746..a833a1323 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,5 +25,5 @@ universal = 1 [flake8] max-line-length = 95 -ignore = E113,E116,E221,E226,E241,E251,E901 +ignore = E113,E116,E221,E241,E251,E901 exclude = .git,.tox,tests/*,build/*,sphinx/search/*,sphinx/pycode/pgen2/*,doc/ext/example*.py diff --git a/sphinx/application.py b/sphinx/application.py index f3bc381bc..f060843b4 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -484,7 +484,7 @@ class Sphinx(object): summary = bold(summary) for item in iterable: l += 1 - s = '%s[%3d%%] %s' % (summary, 100*l/length, + s = '%s[%3d%%] %s' % (summary, 100 * l / length, colorfunc(stringify_func(item))) if self.verbosity: s += '\n' @@ -660,9 +660,9 @@ class Sphinx(object): else: # ignore invalid keys for compatibility continue - setattr(translator, 'visit_'+node.__name__, visit) + setattr(translator, 'visit_' + node.__name__, visit) if depart: - setattr(translator, 'depart_'+node.__name__, depart) + setattr(translator, 'depart_' + node.__name__, depart) def add_enumerable_node(self, node, figtype, title_getter=None, **kwds): self.enumerable_nodes[node] = (figtype, title_getter) diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py index a756742c9..eadbad09a 100644 --- a/sphinx/builders/changes.py +++ b/sphinx/builders/changes.py @@ -130,7 +130,7 @@ class ChangesBuilder(Builder): targetfn = path.join(self.outdir, 'rst', os_path(docname)) + '.html' ensuredir(path.dirname(targetfn)) with codecs.open(targetfn, 'w', 'utf-8') as f: - text = ''.join(hl(i+1, line) for (i, line) in enumerate(lines)) + text = ''.join(hl(i + 1, line) for (i, line) in enumerate(lines)) ctx = { 'filename': self.env.doc2path(docname, None), 'text': text diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 9160080c8..b9ab44676 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -498,7 +498,7 @@ class StandaloneHTMLBuilder(Builder): # additional pages from conf.py for pagename, template in self.config.html_additional_pages.items(): - self.info(' '+pagename, nonl=1) + self.info(' ' + pagename, nonl=1) self.handle_page(pagename, {}, template) # the search page @@ -953,7 +953,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder): hashindex = refuri.find('#') if hashindex < 0: continue - hashindex = refuri.find('#', hashindex+1) + hashindex = refuri.find('#', hashindex + 1) if hashindex >= 0: refnode['refuri'] = fname + refuri[hashindex:] @@ -1059,7 +1059,7 @@ class SingleFileHTMLBuilder(StandaloneHTMLBuilder): # additional pages from conf.py for pagename, template in self.config.html_additional_pages.items(): - self.info(' '+pagename, nonl=1) + self.info(' ' + pagename, nonl=1) self.handle_page(pagename, {}, template) if self.config.html_use_opensearch: diff --git a/sphinx/builders/htmlhelp.py b/sphinx/builders/htmlhelp.py index 79268ab74..11c614b5a 100644 --- a/sphinx/builders/htmlhelp.py +++ b/sphinx/builders/htmlhelp.py @@ -208,12 +208,12 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder): def build_hhx(self, outdir, outname): self.info('dumping stopword list...') - with self.open_file(outdir, outname+'.stp') as f: + with self.open_file(outdir, outname + '.stp') as f: for word in sorted(stopwords): print(word, file=f) self.info('writing project file...') - with self.open_file(outdir, outname+'.hhp') as f: + with self.open_file(outdir, outname + '.hhp') as f: f.write(project_template % { 'outname': outname, 'title': self.config.html_title, @@ -234,7 +234,7 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder): file=f) self.info('writing TOC file...') - with self.open_file(outdir, outname+'.hhc') as f: + with self.open_file(outdir, outname + '.hhc') as f: f.write(contents_header) # special books f.write('
  • ' + object_sitemap % (self.config.html_short_title, @@ -259,7 +259,7 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder): if ullevel != 0: f.write('
      \n') for subnode in node: - write_toc(subnode, ullevel+1) + write_toc(subnode, ullevel + 1) if ullevel != 0: f.write('
    \n') elif isinstance(node, addnodes.compact_paragraph): @@ -275,7 +275,7 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder): self.info('writing index file...') index = self.env.create_index(self) - with self.open_file(outdir, outname+'.hhk') as f: + with self.open_file(outdir, outname + '.hhk') as f: f.write('