[MERGE] forward port of branch 8.0 up to 591e329
[odoo/odoo.git] / doc / conf.py
1 # -*- coding: utf-8 -*-
2 import sys, os
3 import sphinx
4
5 # If extensions (or modules to document with autodoc) are in another directory,
6 # add these directories to sys.path here. If the directory is relative to the
7 # documentation root, use os.path.abspath to make it absolute, like shown here.
8 DIR = os.path.dirname(__file__)
9 sys.path.append(
10     os.path.abspath(
11         os.path.join(DIR, '_themes')))
12 # autodoc
13 sys.path.append(os.path.abspath(os.path.join(DIR, '..')))
14
15 # -- General configuration -----------------------------------------------------
16
17 # If your documentation needs a minimal Sphinx version, state it here.
18 needs_sphinx = '1.1'
19
20 # Add any Sphinx extension module names here, as strings. They can be extensions
21 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
22 extensions = [
23     'sphinx.ext.ifconfig',
24     'sphinx.ext.todo',
25     'sphinx.ext.autodoc',
26     'sphinx.ext.intersphinx',
27     'odoodoc',
28     'patchqueue'
29 ]
30 if sphinx.__version__.split('.') >= ['1', '2']:
31     # linkcode is only available from Sphinx 1.2
32     extensions.insert(0, 'sphinx.ext.linkcode')
33
34
35 # Add any paths that contain templates here, relative to this directory.
36 templates_path = ['_templates']
37
38 # The suffix of source filenames.
39 source_suffix = '.rst'
40
41 # The encoding of source files.
42 #source_encoding = 'utf-8-sig'
43
44 # The master toctree document.
45 master_doc = 'index'
46
47 # General information about the project.
48 project = u'odoo'
49 copyright = u'Odoo S.A.'
50
51 # The version info for the project you're documenting, acts as replacement for
52 # |version| and |release|, also used in various other places throughout the
53 # built documents.
54 #
55 # The short X.Y version.
56 version = 'master'
57 # The full version, including alpha/beta/rc tags.
58 release = 'master'
59
60 # There are two options for replacing |today|: either, you set today to some
61 # non-false value, then it is used:
62 #today = ''
63 # Else, today_fmt is used as the format for a strftime call.
64 today_fmt = '%B %d, %Y'
65
66 # List of patterns, relative to source directory, that match files and
67 # directories to ignore when looking for source files.
68 exclude_patterns = ['_build']
69
70 # The reST default role (used for this markup: `text`) to use for all documents.
71 #default_role = None
72
73 # If true, '()' will be appended to :func: etc. cross-reference text.
74 add_function_parentheses = True
75
76 # If true, the current module name will be prepended to all description
77 # unit titles (such as .. function::).
78 #add_module_names = True
79
80 # If true, sectionauthor and moduleauthor directives will be shown in the
81 # output. They are ignored by default.
82 #show_authors = False
83
84 # The name of the Pygments (syntax highlighting) style to use.
85 pygments_style = 'odoo'
86
87 # A list of ignored prefixes for module index sorting.
88 #modindex_common_prefix = []
89
90
91 # -- Options for HTML output ---------------------------------------------------
92 # The theme to use for HTML and HTML Help pages.  See the documentation for
93 # a list of builtin themes.
94 html_theme = 'odoodoc'
95
96 # Theme options are theme-specific and customize the look and feel of a theme
97 # further.  For a list of options available for each theme, see the
98 # documentation.
99 #html_theme_options = {}
100
101 # Add any paths that contain custom themes here, relative to this directory.
102 html_theme_path = ['_themes']
103
104 # The name for this set of Sphinx documents.  If None, it defaults to
105 # "<project> v<release> documentation".
106 #html_title = None
107
108 # A shorter title for the navigation bar.  Default is the same as html_title.
109 #html_short_title = None
110
111 # The name of an image file (relative to this directory) to place at the top
112 # of the sidebar.
113 #html_logo = None
114
115 # The name of an image file (within the static path) to use as favicon of the
116 # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
117 # pixels large.
118 #html_favicon = None
119
120 # Add any paths that contain custom static files (such as style sheets) here,
121 # relative to this directory. They are copied after the builtin static files,
122 # so a file named "default.css" will overwrite the builtin "default.css".
123 html_static_path = ['_static']
124
125 html_style = "odoo.css"
126
127 html_add_permalinks = False
128
129 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
130 # using the given strftime format.
131 #html_last_updated_fmt = '%b %d, %Y'
132
133 # If true, SmartyPants will be used to convert quotes and dashes to
134 # typographically correct entities.
135 #html_use_smartypants = True
136
137 # Custom sidebar templates, maps document names to template names.
138 # FIXME: no sidebar on index?
139 html_sidebars = {
140 }
141
142 # Additional templates that should be rendered to pages, maps page names to
143 # template names.
144 #html_additional_pages = {}
145
146 # If false, no module index is generated.
147 #html_domain_indices = True
148
149 # If false, no index is generated.
150 #html_use_index = True
151
152 # If true, the index is split into individual pages for each letter.
153 #html_split_index = False
154
155 # If true, links to the reST sources are added to the pages.
156 #html_show_sourcelink = True
157
158 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
159 #html_show_sphinx = True
160
161 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
162 #html_show_copyright = True
163
164 # If true, an OpenSearch description file will be output, and all pages will
165 # contain a <link> tag referring to it.  The value of this option must be the
166 # base URL from which the finished HTML is served.
167 #html_use_opensearch = ''
168
169 latex_elements = {
170     'papersize': r'a4paper',
171     'preamble': u'''\\setcounter{tocdepth}{2}
172 ''',
173 }
174
175 # default must be set otherwise ifconfig blows up
176 todo_include_todos = False
177
178 intersphinx_mapping = {
179     'python': ('https://docs.python.org/2/', None),
180     'werkzeug': ('http://werkzeug.pocoo.org/docs/', None),
181     'sqlalchemy': ('http://docs.sqlalchemy.org/en/rel_0_9/', None),
182     'django': ('https://django.readthedocs.org/en/latest/', None),
183 }
184
185 github_user = 'odoo'
186 github_project = 'odoo'
187
188 def setup(app):
189     app.connect('html-page-context', canonicalize)
190     app.add_config_value('canonical_root', None, 'env')
191     app.add_config_value('canonical_branch', 'master', 'env')
192
193     app.connect('html-page-context', versionize)
194     app.add_config_value('versions', '', 'env')
195
196     app.connect('html-page-context', analytics)
197     app.add_config_value('google_analytics_key', False, 'env')
198
199 def canonicalize(app, pagename, templatename, context, doctree):
200     """ Adds a 'canonical' URL for the current document in the rendering
201     context. Requires the ``canonical_root`` setting being set. The canonical
202     branch is ``master`` but can be overridden using ``canonical_branch``.
203     """
204     if not app.config.canonical_root:
205         return
206
207     context['canonical'] = _build_url(
208         app.config.canonical_root, app.config.canonical_branch, pagename)
209
210 def versionize(app, pagename, templatename, context, doctree):
211     """ Adds a version switcher below the menu, requires ``canonical_root``
212     and ``versions`` (an ordered, space-separated lists of all possible
213     versions).
214     """
215     if not (app.config.canonical_root and app.config.versions):
216         return
217
218     context['versions'] = [
219         (vs, _build_url(app.config.canonical_root, vs, pagename))
220         for vs in app.config.versions.split(',')
221         if vs != app.config.version
222     ]
223
224 def analytics(app, pagename, templatename, context, doctree):
225     if not app.config.google_analytics_key:
226         return
227
228     context['google_analytics_key'] = app.config.google_analytics_key
229
230 def _build_url(root, branch, pagename):
231     return "{canonical_url}{canonical_branch}/{canonical_page}".format(
232         canonical_url=root,
233         canonical_branch=branch,
234         canonical_page=(pagename + '.html').replace('index.html', '')
235                                            .replace('index/', ''),
236     )
237