docs: Use sphinxcontrib.apidoc for building API docs

Gets us away from the old pbr functionality.

Some cleanup of tox.ini is included along the way.

Change-Id: Ia228f8ee49f31f88fa2a66f2aad3a3921c41a785
This commit is contained in:
Stephen Finucane 2019-04-02 14:39:50 +01:00
parent b9c51e295b
commit 05ddd9fc9e
5 changed files with 40 additions and 89 deletions

View File

@ -6,9 +6,4 @@ sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
doc8>=0.6.0 # Apache-2.0 doc8>=0.6.0 # Apache-2.0
reno>=2.5.0 # Apache-2.0 reno>=2.5.0 # Apache-2.0
sphinxcontrib-apidoc>=0.2.0 # BSD
# These modules are needed when generating document
fixtures>=3.0.0 # Apache-2.0/BSD
testresources>=2.0.0 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
oslotest>=3.2.0 # Apache-2.0

View File

@ -11,17 +11,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration ---------------------------------------------------- # -- General configuration ----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [ extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.autodoc',
#'sphinx.ext.intersphinx', 'sphinxcontrib.apidoc',
'oslo_config.sphinxext', 'oslo_config.sphinxext',
'openstackdocstheme', 'openstackdocstheme',
'stevedore.sphinxext' 'stevedore.sphinxext'
@ -31,23 +27,6 @@ repository_name = 'openstack/oslo.db'
bug_project = 'oslo.db' bug_project = 'oslo.db'
bug_tag = '' bug_tag = ''
# Must set this variable to include year, month, day, hours, and minutes.
html_last_updated_fmt = '%Y-%m-%d %H:%M'
# 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
# A list of glob-style patterns that should be excluded when looking for source
# files.
exclude_patterns = [
'api/setup.rst', # workaround for https://launchpad.net/bugs/1260495
'api/tests.*', # avoid of docs generation from tests
]
# The suffix of source filenames.
source_suffix = '.rst'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = 'index'
@ -68,26 +47,18 @@ pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
modindex_common_prefix = ['oslo_db.'] modindex_common_prefix = ['oslo_db.']
# -- Options for HTML output --------------------------------------------------
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with # The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'. # Sphinx are currently 'default' and 'sphinxdoc'.
# html_theme_path = ["."]
html_theme = 'openstackdocs' html_theme = 'openstackdocs'
# html_static_path = ['static']
# Output file base name for HTML help builder.
htmlhelp_basename = '%sdoc' % project
# Grouping the document tree into LaTeX files. List of tuples # -- sphinxcontrib.apidoc configuration --------------------------------------
# (source start file, target name, title, author, documentclass
# [howto/manual]). apidoc_module_dir = '../../oslo_db'
latex_documents = [ apidoc_output_dir = 'reference/api'
('index', apidoc_excluded_paths = [
'%s.tex' % project, 'tests',
u'%s Documentation' % project,
u'OpenStack Foundation', 'manual'),
] ]
# Example configuration for intersphinx: refer to the Python standard library.
#intersphinx_mapping = {'http://docs.python.org/': None}

View File

@ -15,4 +15,4 @@ API
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
api/autoindex api/modules

View File

@ -21,10 +21,10 @@ classifier =
[extras] [extras]
# So e.g. nova can test-depend on oslo.db[mysql] # So e.g. nova can test-depend on oslo.db[mysql]
mysql = mysql =
PyMySQL>=0.7.6 # MIT License PyMySQL>=0.7.6 # MIT License
# or oslo.db[postgresql] # or oslo.db[postgresql]
postgresql = postgresql =
psycopg2>=2.7.0 # LGPL/ZPL psycopg2>=2.7.0 # LGPL/ZPL
[files] [files]
packages = packages =
@ -42,15 +42,6 @@ oslo.db.migration =
[bdist_wheel] [bdist_wheel]
universal = 1 universal = 1
[build_sphinx]
source-dir = doc/source
build-dir = doc/build
all_files = 1
warning-is-error = 1
[upload_sphinx]
upload-dir = doc/build/html
[compile_catalog] [compile_catalog]
directory = oslo_db/locale directory = oslo_db/locale
domain = oslo_db domain = oslo_db
@ -64,9 +55,3 @@ input_file = oslo_db/locale/oslo_db.pot
keywords = _ gettext ngettext l_ lazy_gettext keywords = _ gettext ngettext l_ lazy_gettext
mapping_file = babel.cfg mapping_file = babel.cfg
output_file = oslo_db/locale/oslo_db.pot output_file = oslo_db/locale/oslo_db.pot
[pbr]
autodoc_index_modules = True
api_doc_dir = reference/api
autodoc_exclude_modules =
oslo_db.tests.*

54
tox.ini
View File

@ -1,34 +1,29 @@
[tox] [tox]
minversion = 2.0 minversion = 2.0
envlist = py35,py27,pep8 envlist = py27,py35,pep8
[testenv] [testenv]
install_command = pip install {opts} {packages} whitelist_externals =
whitelist_externals = bash env
env passenv =
OS_TEST_DBAPI_ADMIN_CONNECTION
setenv = setenv =
VIRTUAL_ENV={envdir} BASECOMMAND=stestr run
BASECOMMAND=stestr run {postgresql,all}: PIFPAF_POSTGRESQL=pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run postgresql --
BRANCH_NAME=master {mysql,all}: PIFPAF_MYSQL=pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run mysql --
CLIENT_NAME=oslo.db {mysql,postgresql,all}: BASECOMMAND={toxinidir}/tools/run-pifpaf-tests.sh
{postgresql,all}: PIFPAF_POSTGRESQL=pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run postgresql --
{mysql,all}: PIFPAF_MYSQL=pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run mysql --
{mysql,postgresql,all}: BASECOMMAND={toxinidir}/tools/run-pifpaf-tests.sh
deps = deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt} -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt
commands = commands =
{env:PIFPAF_MYSQL:} {env:PIFPAF_POSTGRESQL:} {env:BASECOMMAND:} {posargs} {env:PIFPAF_MYSQL:} {env:PIFPAF_POSTGRESQL:} {env:BASECOMMAND:} {posargs}
passenv = OS_TEST_DBAPI_ADMIN_CONNECTION
[testenv:py27] [testenv:py27]
basepython = python2.7 basepython = python2.7
commands = commands =
env TEST_EVENTLET=0 stestr run {posargs} env TEST_EVENTLET=0 stestr run {posargs}
env TEST_EVENTLET=1 stestr run {posargs} env TEST_EVENTLET=1 stestr run {posargs}
[testenv:pep8] [testenv:pep8]
basepython = python3 basepython = python3
@ -44,19 +39,24 @@ commands = {posargs}
[testenv:cover] [testenv:cover]
basepython = python3 basepython = python3
setenv = setenv =
PYTHON=coverage run --source oslo_db --parallel-mode PYTHON=coverage run --source oslo_db --parallel-mode
commands = commands =
stestr run {posargs} stestr run {posargs}
coverage combine coverage combine
coverage html -d cover coverage html -d cover
coverage xml -o cover/coverage.xml coverage xml -o cover/coverage.xml
[testenv:docs] [testenv:docs]
basepython = python3 basepython = python3
deps = -r{toxinidir}/doc/requirements.txt whitelist_externals =
rm
deps =
{[testenv]deps}
-r{toxinidir}/doc/requirements.txt
commands = commands =
doc8 -e .rst CONTRIBUTING.rst HACKING.rst README.rst doc/source rm -rf doc/build doc/source/reference/api
sphinx-build -b html doc/source doc/build/html doc8 -e .rst CONTRIBUTING.rst HACKING.rst README.rst doc/source
sphinx-build -W -b html doc/source doc/build/html
[testenv:releasenotes] [testenv:releasenotes]
basepython = python3 basepython = python3