Debian Codegraph @

doc/source/ext/gen_ref.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # 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, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
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"})