| 1 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 |
# you may not use this file except in compliance with the License. |
| 3 |
# You may obtain a copy of the License at |
| 4 |
# |
| 5 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 |
# |
| 7 |
# Unless required by applicable law or agreed to in writing, software |
| 8 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 9 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 10 |
# implied. |
| 11 |
# See the License for the specific language governing permissions and |
| 12 |
# limitations under the License. |
| 13 |
|
| 14 |
import os |
| 15 |
import sys |
| 16 |
|
| 17 |
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 18 |
ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", "..")) |
| 19 |
|
| 20 |
sys.path.insert(0, ROOT) |
| 21 |
sys.path.insert(0, BASE_DIR) |
| 22 |
|
| 23 |
|
| 24 |
def gen_ref(ver, title, names): |
| 25 |
refdir = os.path.join(BASE_DIR, "ref") |
| 26 |
pkg = "aodhclient" |
| 27 |
if ver: |
| 28 |
pkg = f"{pkg}.{ver}" |
| 29 |
refdir = os.path.join(refdir, ver) |
| 30 |
if not os.path.exists(refdir): |
| 31 |
os.makedirs(refdir) |
| 32 |
idxpath = os.path.join(refdir, "index.rst") |
| 33 |
with open(idxpath, "w") as idx: |
| 34 |
idx.write(("%(title)s\n" |
| 35 |
"%(signs)s\n" |
| 36 |
"\n" |
| 37 |
".. toctree::\n" |
| 38 |
" :maxdepth: 1\n" |
| 39 |
"\n") % {"title": title, "signs": "=" * len(title)}) |
| 40 |
for name in names: |
| 41 |
idx.write(" %s\n" % name) |
| 42 |
rstpath = os.path.join(refdir, "%s.rst" % name) |
| 43 |
with open(rstpath, "w") as rst: |
| 44 |
rst.write(("%(title)s\n" |
| 45 |
"%(signs)s\n" |
| 46 |
"\n" |
| 47 |
".. automodule:: %(pkg)s.%(name)s\n" |
| 48 |
" :members:\n" |
| 49 |
" :undoc-members:\n" |
| 50 |
" :show-inheritance:\n" |
| 51 |
" :noindex:\n") |
| 52 |
% {"title": " ".join([n.capitalize() |
| 53 |
for n in name.split("_")]), |
| 54 |
"signs": "=" * len(name), |
| 55 |
"pkg": pkg, "name": name}) |
| 56 |
|
| 57 |
|
| 58 |
gen_ref("v2", "Version 2 API", ["client"]) |
| 59 |
|
| 60 |
# -- General configuration ---------------------------------------------------- |
| 61 |
|
| 62 |
# Add any Sphinx extension module names here, as strings. They can be |
| 63 |
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. |
| 64 |
extensions = [ |
| 65 |
'sphinx.ext.autodoc', |
| 66 |
'openstackdocstheme', |
| 67 |
# 'sphinx.ext.intersphinx', |
| 68 |
] |
| 69 |
|
| 70 |
# autodoc generation is a bit aggressive and a nuisance when doing heavy |
| 71 |
# text edit cycles. |
| 72 |
# execute "export SPHINX_DEBUG=1" in your terminal to disable |
| 73 |
|
| 74 |
# The suffix of source filenames. |
| 75 |
source_suffix = '.rst' |
| 76 |
|
| 77 |
# The master toctree document. |
| 78 |
master_doc = 'index' |
| 79 |
|
| 80 |
# openstackdocstheme options |
| 81 |
openstackdocs_repo_name = 'openstack/python-aodhclient' |
| 82 |
openstackdocs_bug_project = 'python-aodhclient' |
| 83 |
openstackdocs_bug_tag = '' |
| 84 |
copyright = '2015, OpenStack Foundation' |
| 85 |
|
| 86 |
# If true, '()' will be appended to :func: etc. cross-reference text. |
| 87 |
add_function_parentheses = True |
| 88 |
|
| 89 |
# If true, the current module name will be prepended to all description |
| 90 |
# unit titles (such as .. function::). |
| 91 |
add_module_names = True |
| 92 |
|
| 93 |
# The name of the Pygments (syntax highlighting) style to use. |
| 94 |
pygments_style = 'native' |
| 95 |
|
| 96 |
# -- Options for HTML output -------------------------------------------------- |
| 97 |
|
| 98 |
# The theme to use for HTML and HTML Help pages. Major themes that come with |
| 99 |
# Sphinx are currently 'default' and 'sphinxdoc'. |
| 100 |
# html_theme_path = ["."] |
| 101 |
# html_theme = '_theme' |
| 102 |
# html_static_path = ['static'] |
| 103 |
html_theme = 'openstackdocs' |
| 104 |
|
| 105 |
# Add any paths that contain custom themes here, relative to this directory. |
| 106 |
# html_theme_path = ['_theme'] |
| 107 |
|
| 108 |
# Output file base name for HTML help builder. |
| 109 |
htmlhelp_basename = 'aodhclientdoc' |
| 110 |
|
| 111 |
# Grouping the document tree into LaTeX files. List of tuples |
| 112 |
# (source start file, target name, title, author, documentclass |
| 113 |
# [howto/manual]). |
| 114 |
latex_documents = [ |
| 115 |
('index', |
| 116 |
'aodhclient.tex', |
| 117 |
'aodhclient Documentation', |
| 118 |
'OpenStack Foundation', 'manual'), |
| 119 |
] |
| 120 |
|
| 121 |
# Example configuration for intersphinx: refer to the Python standard library. |
| 122 |
# intersphinx_mapping = {'http://docs.python.org/': None} |