From f80f8dfecb280673e9661447a9555bac0959e827 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Wed, 22 Aug 2012 11:57:42 +0800 Subject: [PATCH] Fix PEP8 issues. Fix some pep8 issues in doc/ext/cinder_todo.py and doc/source/conf.py and make the code looks pretty. Change-Id: Ie164bc7328507e20b0ab5993ba97eaadbd74bf63 --- doc/ext/cinder_todo.py | 15 +++++------ doc/source/conf.py | 56 +++++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/doc/ext/cinder_todo.py b/doc/ext/cinder_todo.py index 2bd652071..74331749d 100644 --- a/doc/ext/cinder_todo.py +++ b/doc/ext/cinder_todo.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- -# This is a hack of the builtin todo extension, to make the todo_list more user friendly +# This is a hack of the builtin todo extension, to make the todo_list +# more user friendly from sphinx.ext.todo import * import re + def _(s): return s @@ -20,12 +22,11 @@ def process_todo_nodes(app, doctree, fromdocname): if not hasattr(env, 'todo_all_todos'): env.todo_all_todos = [] - # remove the item that was added in the constructor, since I'm tired of # reading through docutils for the proper way to construct an empty list lists = [] for i in xrange(5): - lists.append(nodes.bullet_list("", nodes.Text('',''))) + lists.append(nodes.bullet_list("", nodes.Text('', ''))) lists[i].remove(lists[i][0]) lists[i]['classes'].append('todo_list') @@ -60,7 +61,8 @@ def process_todo_nodes(app, doctree, fromdocname): todo_entry = todo_info['todo'] - env.resolve_references(todo_entry, todo_info['docname'], app.builder) + env.resolve_references(todo_entry, todo_info['docname'], + app.builder) item = nodes.list_item('', para) todo_entry[1]['classes'].append('details') @@ -79,11 +81,11 @@ def process_todo_nodes(app, doctree, fromdocname): item.append(comment) - lists[priority-1].insert(0, item) - + lists[priority - 1].insert(0, item) node.replace_self(lists) + def setup(app): app.add_config_value('todo_include_todos', False, False) @@ -98,4 +100,3 @@ def setup(app): app.connect('doctree-read', process_todos) app.connect('doctree-resolved', process_todo_nodes) app.connect('env-purge-doc', purge_todos) - diff --git a/doc/source/conf.py b/doc/source/conf.py index 6d55ed5e5..7436039e1 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -3,7 +3,8 @@ # cinder documentation build configuration file, created by # sphinx-quickstart on Sat May 1 15:17:47 2010. # -# This file is execfile()d with the current directory set to its containing dir. +# This file is execfile()d with the current directory set +# to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. @@ -11,7 +12,8 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import sys +import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -20,28 +22,37 @@ sys.path.insert(0, os.path.abspath('../../')) sys.path.insert(0, os.path.abspath('../')) sys.path.insert(0, os.path.abspath('./')) -# -- General configuration ----------------------------------------------------- +# -- General configuration ---------------------------------------------------- -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# Add any Sphinx extension module names here, as strings. +# They can be extensions coming with Sphinx (named 'sphinx.ext.*') +# or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'ext.cinder_todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig','sphinx.ext.graphviz'] +extensions = ['sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'ext.cinder_todo', + 'sphinx.ext.coverage', + 'sphinx.ext.pngmath', + 'sphinx.ext.ifconfig', + 'sphinx.ext.graphviz'] -# autodoc generation is a bit aggressive and a nuisance when doing heavy text edit cycles. -# execute "export SPHINX_DEBUG=1" in your terminal to disable +# autodoc generation is a bit aggressive and a nuisance +# when doing heavy text edit cycles. Execute "export SPHINX_DEBUG=1" +# in your terminal to disable if not os.getenv('SPHINX_DEBUG'): extensions += ['ext.cinder_autodoc'] todo_include_todos = True # Add any paths that contain templates here, relative to this directory. -# Changing the path so that the Hudson build output contains GA code and the source -# docs do not contain the code so local, offline sphinx builds are "clean." +# Changing the path so that the Hudson build output contains GA code +# and the source docs do not contain the code so local, offline sphinx builds +# are "clean." templates_path = [] if os.getenv('HUDSON_PUBLISH_DOCS'): - templates_path = ['_ga', '_templates'] + templates_path = ['_ga', '_templates'] else: - templates_path = ['_templates'] + templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' @@ -82,13 +93,14 @@ unused_docs = [ 'api_ext/rst_extension_template', 'vmwareapi_readme', 'installer', - ] +] # List of directories, relative to source directory, that shouldn't be searched # for source files. exclude_trees = [] -# The reST default role (used for this markup: `text`) to use for all documents. +# The reST default role (used for this markup: `text`) to use +# for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. @@ -108,7 +120,7 @@ pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. modindex_common_prefix = ['cinder.'] -# -- Options for man page output ----------------------------------------------- +# -- Options for man page output ---------------------------------------------- # Grouping the document tree for man pages. # List of tuples 'sourcefile', 'target', u'title', u'Authors name', 'manual' @@ -116,9 +128,9 @@ modindex_common_prefix = ['cinder.'] man_pages = [ ('man/cinder-manage', 'cinder-manage', u'Cloud controller fabric', [u'OpenStack'], 1) - ] +] -# -- Options for HTML output --------------------------------------------------- +# -- Options for HTML output -------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. @@ -195,7 +207,7 @@ html_last_updated_fmt = os.popen(git_cmd).read() htmlhelp_basename = 'cinderdoc' -# -- Options for LaTeX output -------------------------------------------------- +# -- Options for LaTeX output ------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' @@ -204,10 +216,11 @@ htmlhelp_basename = 'cinderdoc' #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). +# (source start file, target name, title, author, documentclass +# [howto/manual]). latex_documents = [ - ('index', 'Cinder.tex', u'Cinder Documentation', - u'Anso Labs, LLC', 'manual'), + ('index', 'Cinder.tex', u'Cinder Documentation', + u'Anso Labs, LLC', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -231,4 +244,3 @@ latex_documents = [ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'python': ('http://docs.python.org/', None), 'swift': ('http://swift.openstack.org', None)} - -- 2.45.2