salt/doc/conf.py

385 lines
11 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2012-10-15 20:26:11 +00:00
# pylint: disable=C0103,W0622
'''
Sphinx documentation for Salt
'''
2014-06-19 05:05:26 +00:00
import functools
2012-01-16 05:33:44 +00:00
import sys
import os
import types
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
2014-04-30 19:06:27 +00:00
This allows autodoc to do its thing without having oodles of req'd
2012-01-16 05:33:44 +00:00
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):
ret = Mock()
# If mocked function is used as a decorator, expose decorated function.
# if args and callable(args[-1]):
# functools.update_wrapper(ret, args[0])
return ret
2012-01-16 05:33:44 +00:00
@classmethod
2012-10-15 17:48:56 +00:00
def __getattr__(cls, name):
2012-01-16 05:33:44 +00:00
if name in ('__file__', '__path__'):
return '/dev/null'
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',
'Crypto.Hash',
'Crypto.PublicKey',
'Crypto.Random',
'M2Crypto',
'msgpack',
'yaml',
'yaml.constructor',
'yaml.nodes',
2013-11-10 21:38:51 +00:00
'yaml.scanner',
'zmq',
# third-party libs for cloud modules
'libcloud',
'libcloud.compute',
'libcloud.compute.base',
'libcloud.compute.deployment',
'libcloud.compute.providers',
'libcloud.compute.types',
2014-02-26 18:51:43 +00:00
'libcloud.loadbalancer',
'libcloud.loadbalancer.types',
'libcloud.loadbalancer.providers',
'libcloud.common',
'libcloud.common.google',
# third-party libs for netapi modules
2012-11-15 21:55:54 +00:00
'cherrypy',
'cherrypy.lib',
2014-05-19 14:58:16 +00:00
'cherrypy.process',
2012-11-15 21:55:54 +00:00
'cherrypy.wsgiserver',
'cherrypy.wsgiserver.ssl_builtin',
'tornado',
'tornado.concurrent',
'tornado.gen',
'tornado.httpserver',
'tornado.ioloop',
'tornado.web',
'tornado.websocket',
2014-05-19 14:58:16 +00:00
'ws4py',
'ws4py.server',
'ws4py.server.cherrypyserver',
'ws4py.websocket',
2012-01-16 05:33:44 +00:00
# modules, renderers, states, returners, et al
'django',
2012-01-16 05:33:44 +00:00
'libvirt',
'mako',
'mako.template',
'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',
2014-04-11 20:21:58 +00:00
'requests',
2012-01-16 05:33:44 +00:00
'rpm',
'rpmUtils',
'rpmUtils.arch',
'yum',
'OpenSSL',
'zfs'
2012-01-16 05:33:44 +00:00
]
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = Mock()
# -- Add paths to PYTHONPATH ---------------------------------------------------
try:
docs_basepath = os.path.abspath(os.path.dirname(__file__))
except NameError:
# sphinx-intl and six execute some code which will raise this NameError
# assume we're in the doc/ directory
docs_basepath = os.path.abspath(os.path.dirname('.'))
2012-01-16 05:33:44 +00:00
addtl_paths = (
2013-12-03 22:54:38 +00:00
os.pardir, # salt itself (for autodoc)
'_ext', # custom Sphinx extensions
)
for path in addtl_paths:
sys.path.insert(0, os.path.abspath(os.path.join(docs_basepath, path)))
# We're now able to import salt
import salt.version
2012-01-16 05:33:44 +00:00
formulas_dir = os.path.join(os.pardir, docs_basepath, 'formulas')
# ----- Intersphinx Settings ------------------------------------------------>
intersphinx_mapping = {
'python2': ('http://docs.python.org/2', None),
'python3': ('http://docs.python.org/3', None)
}
# <---- Intersphinx Settings -------------------------------------------------
2013-10-29 08:13:07 +00:00
# -- General Configuration -----------------------------------------------------
2012-06-04 22:40:34 +00:00
project = 'Salt'
copyright = '2014 SaltStack, Inc.'
version = salt.version.__version__
2013-08-12 18:50:46 +00:00
#release = '.'.join(map(str, salt.version.__version_info__))
2014-08-14 23:33:04 +00:00
release = '2014.1.10'
spelling_lang = 'en_US'
language = 'en'
locale_dirs = [
'_locale',
]
master_doc = 'contents'
2011-10-11 01:23:39 +00:00
templates_path = ['_templates']
exclude_patterns = ['_build', '_incl/*', 'ref/cli/_includes/*.rst']
2012-10-15 20:26:11 +00:00
extensions = [
2013-12-14 05:33:50 +00:00
'saltdomain', # Must come early
2012-10-15 20:26:11 +00:00
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
'httpdomain',
'youtube',
2013-12-14 05:33:50 +00:00
'saltautodoc', # Must be AFTER autodoc
'shorturls',
2012-10-15 20:26:11 +00:00
]
2014-07-14 21:18:52 +00:00
try:
import sphinxcontrib.spelling
except ImportError:
pass
else:
extensions += ['sphinxcontrib.spelling']
2011-10-11 01:23:39 +00:00
modindex_common_prefix = ['salt.']
autosummary_generate = True
2011-10-11 01:23:39 +00:00
# Define a substitution for linking to the latest release tarball
rst_prolog = """\
.. |saltrepo| replace:: https://github.com/saltstack/salt
.. _`salt-users`: https://groups.google.com/forum/#!forum/salt-users
.. _`salt-announce`: https://groups.google.com/forum/#!forum/salt-announce
.. _`salt-packagers`: https://groups.google.com/forum/#!forum/salt-packagers
2014-01-02 21:58:13 +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),
'download': ('https://cloud.github.com/downloads/saltstack/salt/%s', None),
'issue': ('https://github.com/saltstack/salt/issues/%s', 'issue '),
'formula': ('https://github.com/saltstack-formulas/%s', ''),
}
# ----- Localization -------------------------------------------------------->
locale_dirs = ['locale/']
gettext_compact = False
# <---- Localization ---------------------------------------------------------
2014-04-17 05:58:58 +00:00
### HTML options
html_theme = 'saltstack'
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'
html_static_path = ['_static']
2014-03-21 17:15:08 +00:00
html_logo = None # specfied in the theme layout.html
2011-10-17 05:54:11 +00:00
html_favicon = 'favicon.ico'
html_use_smartypants = False
# Set a var if we're building docs for the live site or not
on_saltstack = 'SALT_ON_SALTSTACK' in os.environ
# Use Google customized search or use Sphinx built-in JavaScript search
if on_saltstack:
html_search_template = 'googlesearch.html'
else:
html_search_template = 'searchbox.html'
html_additional_pages = {
'404': '404.html',
}
html_default_sidebars = [
html_search_template,
'version.html',
'localtoc.html',
'relations.html',
'sourcelink.html',
'saltstack.html',
]
html_sidebars = {
'ref/**/all/salt.*': [
html_search_template,
'version.html',
'modules-sidebar.html',
'localtoc.html',
'relations.html',
'sourcelink.html',
'saltstack.html',
],
2013-09-11 14:46:58 +00:00
'ref/formula/all/*': [
],
}
html_context = {
'on_saltstack': on_saltstack,
'html_default_sidebars': html_default_sidebars,
'github_base': 'https://github.com/saltstack/salt',
'github_issues': 'https://github.com/saltstack/salt/issues',
'github_downloads': 'https://github.com/saltstack/salt/downloads',
}
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-10-11 01:23:39 +00:00
### Latex options
latex_documents = [
('contents', 'Salt.tex', 'Salt Documentation', 'SaltStack, Inc.', 'manual'),
]
latex_logo = '_static/salt-logo.pdf'
latex_elements = {
'inputenc': '', # use XeTeX instead of the inputenc LaTeX package.
'utf8extra': '',
'preamble': '''
\usepackage{fontspec}
\setsansfont{DejaVu Sans}
\setromanfont{DejaVu Serif}
\setmonofont{DejaVu Sans Mono}
''',
}
### Linkcheck options
linkcheck_ignore = [r'http://127.0.0.1',
r'http://salt:\d+',
r'http://local:\d+',
r'https://console.aws.amazon.com',
r'http://192.168.33.10',
r'http://domain:\d+',
r'http://123.456.789.012:\d+',
r'http://localhost',
r'https://groups.google.com/forum/#!forum/salt-users',
r'http://logstash.net/docs/latest/inputs/udp',
r'http://logstash.net/docs/latest/inputs/zeromq',
r'http://www.youtube.com/saltstack',
r'http://raven.readthedocs.org',
r'https://getsentry.com',
r'http://salt-cloud.readthedocs.org',
r'http://salt.readthedocs.org',
r'http://www.pip-installer.org/',
r'http://www.windowsazure.com/',
r'https://github.com/watching',
r'dash-feed://',
r'https://github.com/saltstack/salt/',
r'http://bootstrap.saltstack.org',
r'https://bootstrap.saltstack.com',
r'https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh',
r'media.readthedocs.org/dash/salt/latest/salt.xml',
r'https://portal.aws.amazon.com/gp/aws/securityCredentials',
r'https://help.github.com/articles/fork-a-repo',
r'dash-feed://https%3A//media.readthedocs.org/dash/salt/latest/salt.xml'
]
linkcheck_anchors = False
2011-10-11 01:23:39 +00:00
### Manpage options
# 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',
]
man_pages = [
2012-06-04 22:40:34 +00:00
('contents', 'salt', 'Salt Documentation', authors, 7),
2013-08-10 15:03:07 +00:00
('ref/cli/salt', 'salt', 'salt', authors, 1),
2012-06-04 22:40:34 +00:00
('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),
2013-08-10 15:03:07 +00:00
('ref/cli/salt-ssh', 'salt-ssh', 'salt-ssh Documentation', authors, 1),
('ref/cli/salt-cloud', 'salt-cloud', 'Salt Cloud Command', authors, 1),
2014-06-20 16:19:27 +00:00
('ref/cli/salt-api', 'salt-api', 'salt-api Command', authors, 1),
('ref/cli/salt-unity', 'salt-unity', 'salt-unity Command', authors, 1),
]
2011-11-07 02:16:34 +00:00
### epub options
2012-06-04 22:40:34 +00:00
epub_title = 'Salt Documentation'
epub_author = 'SaltStack, Inc.'
2011-11-07 02:16:34 +00:00
epub_publisher = epub_author
epub_copyright = copyright
2011-11-07 02:16:34 +00:00
epub_scheme = 'URL'
epub_identifier = 'http://saltstack.org/'
#epub_tocdepth = 3
2012-06-19 08:09:33 +00:00
def skip_mod_init_member(app, what, name, obj, skip, options):
if name.startswith('_'):
return True
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
def setup(app):
2012-06-19 08:09:33 +00:00
app.add_directive('releasestree', ReleasesTree)
app.connect('autodoc-skip-member', skip_mod_init_member)