Prevent doc generation failure on OVO decorators
Currently Sphinx will fail to generate the documentation if we are using
decorators from any OVO in cinder.objects, because the OVOs are only
added to the cinder.objects namespace when the CLI programs are run.
So we need to run `register_all` method during documentation generation
to avoid failures like:
AttributeError: 'module' object has no attribute 'Volume'
This patch modifies autogenerated doc/source/conf.py file and since now
it is no longer completely autogenerated it is added to PEP8 checks,
which required some minor changes.
Change-Id: Ifeeef61a778f9e3f3daceba8ed05cd2036219499
This commit is contained in:
@@ -1,3 +1,15 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
# cinder documentation build configuration file, created by
|
# cinder documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Sat May 1 15:17:47 2010.
|
# sphinx-quickstart on Sat May 1 15:17:47 2010.
|
||||||
#
|
#
|
||||||
@@ -15,6 +27,16 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
from cinder import objects
|
||||||
|
|
||||||
|
|
||||||
|
# NOTE(geguileo): Sphinx will fail to generate the documentation if we are
|
||||||
|
# using decorators from any OVO in cinder.objects, because the OVOs are only
|
||||||
|
# added to the cinder.objects namespace when the CLI programs are run. So we
|
||||||
|
# need to run it here as well to avoid failures like:
|
||||||
|
# AttributeError: 'module' object has no attribute 'Volume'
|
||||||
|
objects.register_all()
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# 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
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
@@ -38,7 +60,8 @@ extensions = ['sphinx.ext.autodoc',
|
|||||||
'ext.cinder_driverlist',
|
'ext.cinder_driverlist',
|
||||||
]
|
]
|
||||||
|
|
||||||
config_generator_config_file = '../../cinder/config/cinder-config-generator.conf'
|
config_generator_config_file = (
|
||||||
|
'../../cinder/config/cinder-config-generator.conf')
|
||||||
sample_config_basename = '_static/cinder'
|
sample_config_basename = '_static/cinder'
|
||||||
|
|
||||||
# autodoc generation is a bit aggressive and a nuisance
|
# autodoc generation is a bit aggressive and a nuisance
|
||||||
|
|||||||
2
tox.ini
2
tox.ini
@@ -127,7 +127,7 @@ commands = bandit -r cinder -n5 -x tests -ll
|
|||||||
# E251 unexpected spaces around keyword / parameter equals
|
# E251 unexpected spaces around keyword / parameter equals
|
||||||
# reason: no improvement in readability
|
# reason: no improvement in readability
|
||||||
ignore = E251
|
ignore = E251
|
||||||
exclude = .git,.venv,.tox,dist,tools,doc,*egg,build
|
exclude = .git,.venv,.tox,dist,tools,doc/ext,*egg,build
|
||||||
max-complexity=30
|
max-complexity=30
|
||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
|
|||||||
Reference in New Issue
Block a user