| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
import os |
| 14 |
import sys |
| 15 |
|
| 16 |
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 17 |
ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", "..", "..")) |
| 18 |
|
| 19 |
sys.path.insert(0, ROOT) |
| 20 |
sys.path.insert(0, BASE_DIR) |
| 21 |
|
| 22 |
|
| 23 |
def gen_ref(ver, title, names): |
| 24 |
refdir = os.path.join(BASE_DIR, "ref") |
| 25 |
pkg = "heatclient" |
| 26 |
if ver: |
| 27 |
pkg = f"{pkg}.{ver}" |
| 28 |
refdir = os.path.join(refdir, ver) |
| 29 |
if not os.path.exists(refdir): |
| 30 |
os.makedirs(refdir) |
| 31 |
idxpath = os.path.join(refdir, "index.rst") |
| 32 |
with open(idxpath, "w") as idx: |
| 33 |
idx.write(("%(title)s\n" |
| 34 |
"%(signs)s\n" |
| 35 |
"\n" |
| 36 |
".. toctree::\n" |
| 37 |
" :maxdepth: 1\n" |
| 38 |
"\n") % {"title": title, "signs": "=" * len(title)}) |
| 39 |
for name, sec_title in names.items(): |
| 40 |
idx.write(" %s\n" % name) |
| 41 |
rstpath = os.path.join(refdir, "%s.rst" % name) |
| 42 |
with open(rstpath, "w") as rst: |
| 43 |
rst.write(("%(title)s\n" |
| 44 |
"%(signs)s\n" |
| 45 |
"\n" |
| 46 |
".. automodule:: %(pkg)s.%(name)s\n" |
| 47 |
" :members:\n" |
| 48 |
" :undoc-members:\n" |
| 49 |
" :show-inheritance:\n" |
| 50 |
" :noindex:\n") |
| 51 |
% {"title": sec_title, |
| 52 |
"signs": "=" * len(sec_title), |
| 53 |
"pkg": pkg, "name": name}) |
| 54 |
|
| 55 |
|
| 56 |
gen_ref("", "Client Reference", {"client": "Client", "exc": "Exceptions"}) |
| 57 |
gen_ref("v1", "Version 1 API Reference", |
| 58 |
{"stacks": "Stacks", |
| 59 |
"resources": "Resources", |
| 60 |
"events": "Events", |
| 61 |
"actions": "Actions", |
| 62 |
"software_configs": "Software Configs", |
| 63 |
"software_deployments": "Software Deployments"}) |