2011-05-23 06:51:31 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-10-15 20:26:11 +00:00
|
|
|
# pylint: disable=C0103,W0622
|
|
|
|
'''
|
|
|
|
Sphinx documentation for Salt
|
|
|
|
'''
|
2012-01-16 05:33:44 +00:00
|
|
|
import sys
|
|
|
|
import os
|
2012-05-29 23:17:03 +00:00
|
|
|
import types
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2012-06-19 08:09:33 +00:00
|
|
|
from sphinx.directives import TocTree
|
|
|
|
|
|
|
|
|
2012-10-15 20:26:11 +00:00
|
|
|
# pylint: disable=R0903
|
2012-01-16 05:33:44 +00:00
|
|
|
class Mock(object):
|
|
|
|
'''
|
|
|
|
Mock out specified imports
|
|
|
|
|
|
|
|
This allows autodoc to do it's thing without having oodles of req'd
|
|
|
|
installed libs. This doesn't work with ``import *`` imports.
|
|
|
|
|
|
|
|
http://read-the-docs.readthedocs.org/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules
|
|
|
|
'''
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def __call__(self, *args, **kwargs):
|
|
|
|
return Mock()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __getattr__(self, name):
|
|
|
|
if name in ('__file__', '__path__'):
|
|
|
|
return '/dev/null'
|
|
|
|
elif name[0] == name[0].upper():
|
|
|
|
return type(name, (), {})
|
|
|
|
else:
|
|
|
|
return Mock()
|
2012-10-15 20:26:11 +00:00
|
|
|
# pylint: enable=R0903
|
2012-01-16 05:33:44 +00:00
|
|
|
|
|
|
|
MOCK_MODULES = [
|
|
|
|
# salt core
|
|
|
|
'Crypto',
|
|
|
|
'Crypto.Cipher',
|
2012-04-19 17:20:03 +00:00
|
|
|
'Crypto.Hash',
|
|
|
|
'Crypto.PublicKey',
|
|
|
|
'Crypto.Random',
|
2012-04-26 05:09:48 +00:00
|
|
|
'M2Crypto',
|
2012-10-04 20:51:45 +00:00
|
|
|
'msgpack',
|
|
|
|
'yaml',
|
|
|
|
'yaml.constructor',
|
|
|
|
'yaml.nodes',
|
|
|
|
'zmq',
|
2012-01-16 05:33:44 +00:00
|
|
|
# modules, renderers, states, returners, et al
|
2012-10-04 20:51:45 +00:00
|
|
|
'django',
|
2012-01-16 05:33:44 +00:00
|
|
|
'libvirt',
|
|
|
|
'mako',
|
|
|
|
'mako.template',
|
2012-10-04 20:51:45 +00:00
|
|
|
'MySQLdb',
|
|
|
|
'MySQLdb.cursors',
|
|
|
|
'psutil',
|
|
|
|
'pycassa',
|
2012-01-16 05:33:44 +00:00
|
|
|
'pymongo',
|
2012-10-25 00:29:27 +00:00
|
|
|
'rabbitmq_server',
|
2012-01-16 05:33:44 +00:00
|
|
|
'redis',
|
|
|
|
'rpm',
|
|
|
|
'rpmUtils',
|
|
|
|
'rpmUtils.arch',
|
2012-10-04 20:51:45 +00:00
|
|
|
'yum',
|
2012-01-16 05:33:44 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
for mod_name in MOCK_MODULES:
|
|
|
|
sys.modules[mod_name] = Mock()
|
|
|
|
|
|
|
|
|
|
|
|
# -- Add paths to PYTHONPATH ---------------------------------------------------
|
|
|
|
|
|
|
|
docs_basepath = os.path.abspath(os.path.dirname(__file__))
|
2012-01-10 13:10:34 +00:00
|
|
|
addtl_paths = (
|
2012-01-16 05:33:44 +00:00
|
|
|
os.pardir, # salt itself (for autodoc)
|
2012-01-10 13:10:34 +00:00
|
|
|
'_ext', # custom Sphinx extensions
|
|
|
|
)
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2012-01-10 13:10:34 +00:00
|
|
|
for path in addtl_paths:
|
|
|
|
sys.path.insert(0, os.path.abspath(os.path.join(docs_basepath, path)))
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2013-07-15 20:58:03 +00:00
|
|
|
from salt import version
|
2012-01-16 05:33:44 +00:00
|
|
|
|
2011-09-25 06:30:36 +00:00
|
|
|
|
2012-01-16 09:14:22 +00:00
|
|
|
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
|
|
|
|
2011-05-23 06:51:31 +00:00
|
|
|
# -- General configuration -----------------------------------------------------
|
|
|
|
|
2012-06-04 22:40:34 +00:00
|
|
|
project = 'Salt'
|
2013-01-16 03:46:43 +00:00
|
|
|
copyright = '2013, Thomas S. Hatch'
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2013-07-15 20:58:03 +00:00
|
|
|
version = version.__version__
|
|
|
|
release = '.'.join(map(str, version.__version_info__))
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2011-10-11 01:31:51 +00:00
|
|
|
master_doc = 'contents'
|
2011-10-11 01:23:39 +00:00
|
|
|
templates_path = ['_templates']
|
2013-01-24 06:46:12 +00:00
|
|
|
exclude_patterns = ['_build', '_incl/*']
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2012-10-15 20:26:11 +00:00
|
|
|
extensions = [
|
|
|
|
'saltdocs',
|
|
|
|
'sphinx.ext.autodoc',
|
|
|
|
'sphinx.ext.autosummary',
|
|
|
|
'sphinx.ext.extlinks',
|
|
|
|
]
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2011-10-11 01:23:39 +00:00
|
|
|
modindex_common_prefix = ['salt.']
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2011-11-07 07:47:06 +00:00
|
|
|
autosummary_generate = True
|
|
|
|
|
2011-10-11 01:23:39 +00:00
|
|
|
# Define a substitution for linking to the latest release tarball
|
|
|
|
rst_prolog = """\
|
2011-11-16 05:41:20 +00:00
|
|
|
.. |saltrepo| replace:: https://github.com/saltstack/salt
|
|
|
|
.. |latest| replace:: https://github.com/downloads/saltstack/salt/salt-%s.tar.gz
|
2011-10-11 01:23:39 +00:00
|
|
|
""" % __version__
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2011-09-25 06:36:41 +00:00
|
|
|
# A shortcut for linking to tickets on the GitHub issue tracker
|
|
|
|
extlinks = {
|
2012-09-24 19:20:17 +00:00
|
|
|
'blob': ('https://github.com/saltstack/salt/blob/%s/%%s' % 'develop', None),
|
2011-11-16 05:41:20 +00:00
|
|
|
'download': ('https://github.com/downloads/saltstack/salt/%s', None),
|
|
|
|
'issue': ('https://github.com/saltstack/salt/issues/%s', 'issue '),
|
2011-09-25 06:36:41 +00:00
|
|
|
}
|
2011-05-23 06:51:31 +00:00
|
|
|
|
|
|
|
|
2011-10-11 01:23:39 +00:00
|
|
|
### HTML options
|
2013-02-22 09:59:37 +00:00
|
|
|
if on_rtd:
|
|
|
|
html_theme = 'default'
|
|
|
|
else:
|
|
|
|
html_theme = 'saltstack'
|
2012-01-16 09:14:22 +00:00
|
|
|
|
2013-02-22 09:59:37 +00:00
|
|
|
html_theme_path = ['_themes']
|
2011-10-11 01:23:39 +00:00
|
|
|
html_title = None
|
|
|
|
html_short_title = 'Salt'
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2011-10-11 01:31:51 +00:00
|
|
|
html_static_path = ['_static']
|
2013-01-22 11:24:09 +00:00
|
|
|
html_logo = 'saltstack_logo.png'
|
2011-10-17 05:54:11 +00:00
|
|
|
html_favicon = 'favicon.ico'
|
2011-10-11 01:31:51 +00:00
|
|
|
html_use_smartypants = False
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2011-11-17 02:52:51 +00:00
|
|
|
html_additional_pages = {
|
|
|
|
'404': '404.html',
|
|
|
|
}
|
2011-11-13 11:44:15 +00:00
|
|
|
|
2013-02-28 17:09:11 +00:00
|
|
|
html_default_sidebars = [
|
|
|
|
'localtoc.html',
|
|
|
|
'relations.html',
|
|
|
|
'sourcelink.html',
|
|
|
|
'searchbox.html',
|
|
|
|
]
|
2011-11-13 11:44:15 +00:00
|
|
|
html_sidebars = {
|
2013-02-28 17:09:11 +00:00
|
|
|
'ref/**/all/salt.*': [
|
|
|
|
'modules-sidebar.html',
|
2012-02-06 22:45:24 +00:00
|
|
|
'localtoc.html',
|
|
|
|
'relations.html',
|
|
|
|
'sourcelink.html',
|
|
|
|
'searchbox.html',
|
|
|
|
],
|
2011-11-13 11:44:15 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 01:31:51 +00:00
|
|
|
html_context = {
|
2013-02-28 17:42:26 +00:00
|
|
|
'html_default_sidebars': html_default_sidebars,
|
2011-11-16 05:41:20 +00:00
|
|
|
'github_base': 'https://github.com/saltstack/salt',
|
|
|
|
'github_issues': 'https://github.com/saltstack/salt/issues',
|
|
|
|
'github_downloads': 'https://github.com/saltstack/salt/downloads',
|
2011-10-11 01:31:51 +00:00
|
|
|
}
|
2011-05-23 06:51:31 +00:00
|
|
|
|
2012-10-11 20:40:40 +00:00
|
|
|
html_use_index = True
|
2011-10-11 01:23:39 +00:00
|
|
|
html_last_updated_fmt = '%b %d, %Y'
|
|
|
|
html_show_sourcelink = False
|
|
|
|
html_show_sphinx = True
|
|
|
|
html_show_copyright = True
|
2011-05-23 06:51:31 +00:00
|
|
|
#html_use_opensearch = ''
|
|
|
|
|
|
|
|
|
2011-10-11 01:23:39 +00:00
|
|
|
### Latex options
|
2011-05-23 06:51:31 +00:00
|
|
|
latex_documents = [
|
2012-06-04 22:40:34 +00:00
|
|
|
('contents', 'Salt.tex', 'Salt Documentation', 'Thomas Hatch', 'manual'),
|
2011-05-23 06:51:31 +00:00
|
|
|
]
|
|
|
|
|
2013-01-22 11:24:09 +00:00
|
|
|
latex_logo = '_static/saltstack_logo.png'
|
2011-05-23 06:51:31 +00:00
|
|
|
|
|
|
|
|
2011-10-11 01:23:39 +00:00
|
|
|
### Manpage options
|
2011-05-23 06:51:31 +00:00
|
|
|
# One entry per manual page. List of tuples
|
|
|
|
# (source start file, name, description, authors, manual section).
|
|
|
|
authors = [
|
2012-07-13 15:38:59 +00:00
|
|
|
'Thomas S. Hatch <thatch45@gmail.com> and many others, please see the Authors file',
|
2011-05-23 06:51:31 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
man_pages = [
|
2012-06-04 22:40:34 +00:00
|
|
|
('ref/cli/salt', 'salt', 'salt', authors, 1),
|
|
|
|
('contents', 'salt', 'Salt Documentation', authors, 7),
|
|
|
|
('ref/cli/salt-master', 'salt-master', 'salt-master Documentation', authors, 1),
|
|
|
|
('ref/cli/salt-minion', 'salt-minion', 'salt-minion Documentation', authors, 1),
|
|
|
|
('ref/cli/salt-key', 'salt-key', 'salt-key Documentation', authors, 1),
|
|
|
|
('ref/cli/salt-cp', 'salt-cp', 'salt-cp Documentation', authors, 1),
|
|
|
|
('ref/cli/salt-call', 'salt-call', 'salt-call Documentation', authors, 1),
|
|
|
|
('ref/cli/salt-syndic', 'salt-syndic', 'salt-syndic Documentation', authors, 1),
|
|
|
|
('ref/cli/salt-run', 'salt-run', 'salt-run Documentation', authors, 1),
|
2011-05-23 06:51:31 +00:00
|
|
|
]
|
2011-11-07 02:16:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
### epub options
|
2012-06-04 22:40:34 +00:00
|
|
|
epub_title = 'Salt Documentation'
|
|
|
|
epub_author = 'Thomas S. Hatch'
|
2011-11-07 02:16:34 +00:00
|
|
|
epub_publisher = epub_author
|
2013-01-16 03:46:43 +00:00
|
|
|
epub_copyright = '2013, Thomas S. Hatch'
|
2011-11-07 02:16:34 +00:00
|
|
|
|
|
|
|
epub_scheme = 'URL'
|
|
|
|
epub_identifier = 'http://saltstack.org/'
|
|
|
|
|
|
|
|
#epub_tocdepth = 3
|
2012-05-29 23:17:03 +00:00
|
|
|
|
2012-06-19 08:09:33 +00:00
|
|
|
|
2012-05-29 23:17:03 +00:00
|
|
|
def skip_mod_init_member(app, what, name, obj, skip, options):
|
2012-06-10 15:20:47 +00:00
|
|
|
if name.startswith('_'):
|
|
|
|
return True
|
2012-05-29 23:17:03 +00:00
|
|
|
if isinstance(obj, types.FunctionType) and obj.__name__ == 'mod_init':
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2012-06-19 08:09:33 +00:00
|
|
|
|
|
|
|
def _normalize_version(args):
|
|
|
|
_, path = args
|
|
|
|
return '.'.join([x.zfill(4) for x in (path.split('/')[-1].split('.'))])
|
|
|
|
|
|
|
|
|
|
|
|
class ReleasesTree(TocTree):
|
|
|
|
option_spec = dict(TocTree.option_spec)
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
rst = super(ReleasesTree, self).run()
|
|
|
|
entries = rst[0][0]['entries'][:]
|
|
|
|
entries.sort(key=_normalize_version, reverse=True)
|
|
|
|
rst[0][0]['entries'][:] = entries
|
|
|
|
return rst
|
|
|
|
|
|
|
|
|
2012-05-29 23:17:03 +00:00
|
|
|
def setup(app):
|
2012-06-19 08:09:33 +00:00
|
|
|
app.add_directive('releasestree', ReleasesTree)
|
2012-05-29 23:17:03 +00:00
|
|
|
app.connect('autodoc-skip-member', skip_mod_init_member)
|