diff --git a/.gitignore b/.gitignore index 7a0218ce..d51e750c 100644 --- a/.gitignore +++ b/.gitignore @@ -24,8 +24,10 @@ pip-log.txt # Unit test / coverage reports .coverage +*.lock .tox nosetests.xml +.secret_key_store .testrepository .venv node_modules @@ -47,6 +49,7 @@ output/*/index.html # Sphinx doc/build +doc/source/contributor/modules # pbr generates these AUTHORS diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 00000000..5632a3a0 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,3 @@ +openstackdocstheme>=1.17.0 # Apache-2.0 +oslosphinx>=4.7.0 # Apache-2.0 +sphinx>=1.6.2 # BSD diff --git a/doc/source/conf.py b/doc/source/conf.py index cf939716..dc80be30 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,18 +12,34 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging import os import sys +from sphinx import apidoc + +import django sys.path.insert(0, os.path.abspath('../..')) +sys.path.insert(0, os.path.abspath('.')) + +logging.getLogger('openstack_dashboard.settings').setLevel(logging.ERROR) + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'openstack_dashboard.settings') + +django.setup() + # -- 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. extensions = [ + 'openstackdocstheme', + 'oslosphinx', 'sphinx.ext.autodoc', - #'sphinx.ext.intersphinx', - 'oslosphinx' + 'sphinx.ext.coverage', + # 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.viewcode', ] # autodoc generation is a bit aggressive and a nuisance when doing heavy @@ -57,6 +73,13 @@ pygments_style = 'sphinx' # html_theme_path = ["."] # html_theme = '_theme' # html_static_path = ['static'] +html_theme = 'openstackdocs' + +html_theme_options = { + 'display_toc': False +} + +html_static_path = [] # Output file base name for HTML help builder. htmlhelp_basename = '%sdoc' % project @@ -72,7 +95,34 @@ latex_documents = [ ] # Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None} +# intersphinx_mapping = {'http://docs.python.org/': None} # A list of ignored prefixes for module index sorting. modindex_common_prefix = ['octavia-dashboard.'] + + +# TODO(mordred) We should extract this into a sphinx plugin +def run_apidoc(_): + cur_dir = os.path.abspath(os.path.dirname(__file__)) + out_dir = os.path.join(cur_dir, 'contributor', 'modules') + module = os.path.join(cur_dir, '..', '..', 'octavia_dashboard') + # Keep the order of arguments same as the sphinx-apidoc help, otherwise it + # would cause unexpected errors: + # sphinx-apidoc [options] -o + # [exclude_pattern, ...] + apidoc.main([ + '--force', + '-o', + out_dir, + module, + 'octavia_dashboard/tests', + 'octavia_dashboard/enabled', + 'octavia_dashboard/locale', + 'octavia_dashboard/static', + 'octavia_dashboard/post_install.sh', + 'octavia_dashboard/karma.conf.js' + ]) + + +def setup(app): + app.connect('builder-inited', run_apidoc) diff --git a/doc/source/index.rst b/doc/source/index.rst index 66d8902b..a12d7322 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -14,11 +14,4 @@ Contents: readme installation contributing - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - + reference diff --git a/doc/source/reference.rst b/doc/source/reference.rst new file mode 100644 index 00000000..28e9fb4c --- /dev/null +++ b/doc/source/reference.rst @@ -0,0 +1,16 @@ +========= +Reference +========= + +Indices and search +------------------ + +.. toctree:: + :hidden: + + contributor/modules/modules + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/setup.cfg b/setup.cfg index 11a97495..8b196132 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,5 +31,17 @@ all_files = 1 upload-dir = doc/build/html [pbr] -autodoc_index_modules = True -warnerrors = True +autodoc_tree_index_modules = False +autodoc_tree_excludes = + setup.py + octavia_dashboard/tests + octavia_dashboard/enabled + octavia_dashboard/locale + octavia_dashboard/static + octavia_dashboard/post_install.sh + octavia_dashboard/karma.conf.js +autodoc_index_modules = False +autodoc_exclude_modules = + octavia_dashboard.tests.* + octavia_dashboard.enabled.* +api_doc_dir = contributor/modules diff --git a/test-requirements.txt b/test-requirements.txt index e6ee31a7..5fcc61e6 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,13 +8,10 @@ django-nose>=1.4.4 # BSD python-subunit>=1.0.0 # Apache-2.0/BSD nose-exclude>=0.3.0 # LGPL selenium>=2.50.1 # Apache-2.0 -sphinx>=1.6.2 # BSD -oslosphinx>=4.7.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0 testrepository>=0.0.18 # Apache-2.0/BSD testscenarios>=0.4 # Apache-2.0/BSD testtools>=2.2.0 # MIT reno>=2.5.0 # Apache-2.0 -openstackdocstheme>=1.17.0 # Apache-2.0 # This also needs xvfb library installed on your OS xvfbwrapper>=0.1.3 #license: MIT diff --git a/tox.ini b/tox.ini index fd644e1c..d09901d2 100644 --- a/tox.ini +++ b/tox.ini @@ -40,7 +40,15 @@ commands = nosetests octavia_dashboard/tests/integration_tests/tests {posargs} commands = python setup.py test --coverage --testr-args='{posargs}' [testenv:docs] -commands = python setup.py build_sphinx +whitelist_externals = rm +deps = + -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} + -r{toxinidir}/requirements.txt + -r{toxinidir}/doc/requirements.txt +commands = + rm -rf doc/build + sphinx-build -W -b html doc/source doc/build/html + [testenv:releasenotes] commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html