30
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
31
ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", ".."))
33
sys.path.insert(0, ROOT)
34
sys.path.insert(0, BASE_DIR)
36
# This is required for ReadTheDocs.org, but isn't a bad idea anyway.
37
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
40
def write_autodoc_index():
42
def find_autodoc_modules(module_name, sourcedir):
43
"""Return a list of modules in the SOURCE directory."""
45
os.chdir(os.path.join(sourcedir, module_name))
46
print "SEARCHING %s" % sourcedir
47
for root, dirs, files in os.walk("."):
48
for filename in files:
49
if filename.endswith(".py"):
50
# remove the pieces of the root
51
elements = root.split(os.path.sep)
52
# replace the leading "." with the module name
53
elements[0] = module_name
54
# and get the base module name
55
base, extension = os.path.splitext(filename)
56
if not (base == "__init__"):
58
result = ".".join(elements)
60
modlist.append(result)
63
RSTDIR = os.path.abspath(os.path.join(BASE_DIR, "sourcecode"))
66
EXCLUDED_MODULES = ('heat.tests',
74
'heat.engine.resources',
79
if not(os.path.exists(RSTDIR)):
81
CURRENT_SOURCES[RSTDIR] = ['autoindex.rst', '.gitignore']
83
INDEXOUT = open(os.path.join(RSTDIR, "autoindex.rst"), "w")
84
INDEXOUT.write("=================\n")
85
INDEXOUT.write("Source Code Index\n")
86
INDEXOUT.write("=================\n")
88
for modulename, path in SRCS.items():
89
sys.stdout.write("Generating source documentation for %s\n" %
91
INDEXOUT.write("\n%s\n" % modulename.capitalize())
92
INDEXOUT.write("%s\n" % ("=" * len(modulename),))
93
INDEXOUT.write(".. toctree::\n")
94
INDEXOUT.write(" :maxdepth: 1\n")
97
MOD_DIR = os.path.join(RSTDIR, modulename)
98
CURRENT_SOURCES[MOD_DIR] = []
99
if not(os.path.exists(MOD_DIR)):
101
for module in find_autodoc_modules(modulename, path):
102
if any([module.startswith(exclude)
104
in EXCLUDED_MODULES]):
105
print "Excluded module %s." % module
107
mod_path = os.path.join(path, *module.split("."))
108
generated_file = os.path.join(MOD_DIR, "%s.rst" % module)
110
INDEXOUT.write(" %s/%s\n" % (modulename, module))
112
# Find the __init__.py module if this is a directory
113
if os.path.isdir(mod_path):
114
source_file = ".".join((os.path.join(mod_path, "__init__"),
117
source_file = ".".join((os.path.join(mod_path), "py"))
119
CURRENT_SOURCES[MOD_DIR].append("%s.rst" % module)
120
# Only generate a new file if the source has changed or we don't
121
# have a doc file to begin with.
122
if not os.access(generated_file, os.F_OK) or \
123
os.stat(generated_file).st_mtime < \
124
os.stat(source_file).st_mtime:
125
print "Module %s updated, generating new documentation." \
127
FILEOUT = open(generated_file, "w")
128
header = "The :mod:`%s` Module" % module
129
FILEOUT.write("%s\n" % ("=" * len(header),))
130
FILEOUT.write("%s\n" % header)
131
FILEOUT.write("%s\n" % ("=" * len(header),))
132
FILEOUT.write(".. automodule:: %s\n" % module)
133
FILEOUT.write(" :members:\n")
134
FILEOUT.write(" :undoc-members:\n")
135
FILEOUT.write(" :show-inheritance:\n")
136
FILEOUT.write(" :noindex:\n")
141
# Delete auto-generated .rst files for sources which no longer exist
142
for directory, subdirs, files in list(os.walk(RSTDIR)):
143
for old_file in files:
144
if old_file not in CURRENT_SOURCES.get(directory, []):
145
print "Removing outdated file for %s" % old_file
146
os.remove(os.path.join(directory, old_file))
149
write_autodoc_index()
18
151
# If extensions (or modules to document with autodoc) are in another directory,
19
152
# add these directories to sys.path here. If the directory is relative to the
20
153
# documentation root, use os.path.abspath to make it absolute, like shown here.
21
sys.path.insert(0, os.path.abspath('../../'))
154
#sys.path.insert(0, os.path.abspath('.'))
23
156
# -- General configuration ----------------------------------------------------
120
266
# Add any paths that contain custom static files (such as style sheets) here,
121
267
# relative to this directory. They are copied after the builtin static files,
122
268
# so a file named "default.css" will overwrite the builtin "default.css".
123
html_static_path = ['_static']
269
# html_static_path = ['_static']
125
271
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
126
272
# using the given strftime format.
127
273
#html_last_updated_fmt = '%b %d, %Y'
274
git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1"
275
html_last_updated_fmt = os.popen(git_cmd).read()
129
277
# If true, SmartyPants will be used to convert quotes and dashes to
130
278
# typographically correct entities.
170
318
# -- Options for LaTeX output -------------------------------------------------
172
320
latex_elements = {
173
# The paper size ('letterpaper' or 'a4paper').
174
#'papersize': 'letterpaper',
176
# The font size ('10pt', '11pt' or '12pt').
177
#'pointsize': '10pt',
179
# Additional stuff for the LaTeX preamble.
321
# The paper size ('letterpaper' or 'a4paper').
322
#'papersize': 'letterpaper',
324
# The font size ('10pt', '11pt' or '12pt').
325
#'pointsize': '10pt',
327
# Additional stuff for the LaTeX preamble.
183
331
# Grouping the document tree into LaTeX files. List of tuples
184
332
# (source start file, target name, title, author, documentclass [howto/manual])
185
333
latex_documents = [
186
('index', 'Heat.tex', u'Heat Documentation',
187
u'Heat Developers', 'manual'),
334
('index', 'Heat.tex', u'Heat Documentation',
335
u'Heat Developers', 'manual'),
190
338
# The name of an image file (relative to this directory) to place at the top of
214
362
# (source start file, name, description, authors, manual section).
216
364
('man/heat-api', 'heat-api',
217
u'REST API service to the heat project.',
218
[u'Heat Developers'], 1),
365
u'REST API service to the heat project.',
366
[u'Heat Developers'], 1),
219
367
('man/heat-api-cfn', 'heat-api-cfn',
220
u'CloudFormation compatible API service to the heat project.',
221
[u'Heat Developers'], 1),
368
u'CloudFormation compatible API service to the heat project.',
369
[u'Heat Developers'], 1),
222
370
('man/heat-api-cloudwatch', 'heat-api-cloudwatch',
223
u'CloudWatch alike API service to the heat project',
224
[u'Heat Developers'], 1),
225
('man/heat-boto', 'heat-boto',
226
u'Command line utility to run heat actions over the CloudFormation API',
227
[u'Heat Developers'], 1),
228
('man/heat-cfn', 'heat-cfn',
229
u'Command line utility to run heat actions over the CloudFormation API',
230
[u'Heat Developers'], 1),
371
u'CloudWatch alike API service to the heat project',
372
[u'Heat Developers'], 1),
231
373
('man/heat-db-setup', 'heat-db-setup',
232
u'Command line utility to setup the Heat database',
233
[u'Heat Developers'], 1),
374
u'Command line utility to setup the Heat database',
375
[u'Heat Developers'], 1),
234
376
('man/heat-engine', 'heat-engine',
235
u'Service which performs the actions from the API calls made by the user',
236
[u'Heat Developers'], 1),
377
u'Service which performs the actions from the API calls made by the user',
378
[u'Heat Developers'], 1),
237
379
('man/heat-keystone-setup', 'heat-keystone-setup',
238
u'Script which sets up keystone for usage by Heat',
239
[u'Heat Developers'], 1),
240
('man/heat-watch', 'heat-watch',
241
u'Command line utility to run heat watch actions over the CloudWatch API',
242
[u'Heat Developers'], 1),
380
u'Script which sets up keystone for usage by Heat',
381
[u'Heat Developers'], 1),
245
384
# If true, show URL addresses after external links.