1# -*- coding: utf-8 -*-
2#
3# Project ACRN documentation build configuration file, created by
4# sphinx-quickstart on Wed Jan 10 20:51:29 2018.
5#
6# This file is execfile()d with the current directory set to its
7# containing dir.
8#
9# Note that not all possible configuration values are present in this
10# autogenerated file.
11#
12# All configuration values have a default; values that are commented out
13# serve to show the default.
14
15# If extensions (or modules to document with autodoc) are in another directory,
16# add these directories to sys.path here. If the directory is relative to the
17# documentation root, use os.path.abspath to make it absolute, like shown here.
18#
19import os
20import sys
21from datetime import datetime
22
23sys.path.insert(0, os.path.abspath('.'))
24
25RELEASE = ""
26if "RELEASE" in os.environ:
27   RELEASE = os.environ["RELEASE"]
28
29# -- General configuration ------------------------------------------------
30
31# If your documentation needs a minimal Sphinx version, state it here.
32#
33# needs_sphinx = '1.0'
34
35# Add any Sphinx extension module names here, as strings. They can be
36# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
37# ones.
38
39sys.path.insert(0, os.path.join(os.path.abspath('.'), 'extensions'))
40extensions = [
41   'breathe', 'sphinx.ext.graphviz', 'sphinx.ext.extlinks',
42   'eager_only', 'html_redirects', 'link_roles','sphinx.ext.intersphinx',
43   'sphinx_tabs.tabs', 'last_updated'
44]
45
46# extlinks provides a macro template
47
48extlinks = {
49            'acrn-issue': ('https://github.com/projectacrn/acrn-hypervisor/issues/%s', '#'),
50            'acrn-pr': ('https://github.com/projectacrn/acrn-hypervisor/pull/%s', '#')
51           }
52
53# use intersphinx linking to link to previous version release notes
54# (We only need to link to an archive that has the older release notes)
55
56intersphinx_mapping = {
57        'v2.7': ('https://projectacrn.github.io/2.7', None),
58        }
59
60graphviz_output_format='png'
61graphviz_dot_args=[
62   '-Nfontname="verdana"',
63   '-Gfontname="verdana"',
64   '-Efontname="verdana"']
65
66# Add any paths that contain templates here, relative to this directory.
67templates_path = ['_templates']
68
69# The suffix(es) of source filenames.
70# You can specify multiple suffix as a list of string:
71#
72# source_suffix = ['.rst', '.md']
73source_suffix = '.rst'
74
75# The master toctree document.
76master_doc = 'index'
77
78# General information about the project.
79project = u'Project ACRN™'
80copyright = u'2018-' + str(datetime.now().year) + u' ' + project + ', a Series of LF Projects, LLC'
81author = u'Project ACRN developers'
82
83# The version info for the project you're documenting, acts as replacement for
84# |version| and |release|, also used in various other places throughout the
85# built documents.
86
87# The following code tries to extract the information by reading the
88# Makefile from the acrn-hypervisor repo by finding these lines:
89#   MAJOR_VERSION=1
90#   MINOR_VERSION=3
91#   EXTRA_VERSION=-unstable
92
93try:
94    version_major = None
95    version_minor = None
96    version_rc = None
97
98    for line in open(os.path.realpath("../../../VERSION")) :
99        # remove comments
100        line = line.split('#', 1)[0]
101        line = line.rstrip()
102        if (line.count("=") == 1) :
103           key, val = [x.strip() for x in line.split('=', 2)]
104           if key == 'MAJOR_VERSION':
105              version_major = val
106           if key == 'MINOR_VERSION':
107              version_minor = val
108           if key == 'EXTRA_VERSION':
109              version_rc = val
110           if version_major and version_minor and version_rc :
111              break
112finally:
113    if version_major and version_minor :
114        version = release = str(version_major) + '.' + str(version_minor)
115        if version_rc :
116          version = release = version + version_rc
117    else:
118        sys.stderr.write('Warning: Could not extract hypervisor version from VERSION file\n')
119        version = release = "unknown"
120
121#
122# The short X.Y version.
123# version = u'0.1'
124# The full version, including alpha/beta/rc tags.
125# release = u'0.1'
126
127# The language for content autogenerated by Sphinx. Refer to documentation
128# for a list of supported languages.
129#
130# This is also used if you do content translation via gettext catalogs.
131# Usually you set "language" from the command line for these cases.
132language = 'en'
133
134# List of patterns, relative to source directory, that match files and
135# directories to ignore when looking for source files.
136# This patterns also effect to html_static_path and html_extra_path
137exclude_patterns = ['_build', 'misc/README.rst', 'venv' ]
138
139# The name of the Pygments (syntax highlighting) style to use.
140pygments_style = 'sphinx'
141
142# If true, `todo` and `todoList` produce output, else they produce nothing.
143todo_include_todos = False
144
145# -- Options for HTML output ----------------------------------------------
146
147# The theme to use for HTML and HTML Help pages.  See the documentation for
148# a list of builtin themes.
149#
150try:
151    import sphinx_rtd_theme
152except ImportError:
153    html_theme = 'alabaster'
154    # This is required for the alabaster theme
155    # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
156    html_sidebars = {
157        '**': [
158            'relations.html',  # needs 'show_related': True theme option to display
159            'searchbox.html',
160            ]
161        }
162    sys.stderr.write('Warning: sphinx_rtd_theme missing. Use pip to install it.\n')
163else:
164    html_theme = "sphinx_rtd_theme"
165    html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
166    html_theme_options = {
167        'canonical_url': '',
168        'analytics_id': 'GTM-K4WWJZD',
169        'logo_only': False,
170        'display_version': True,
171        #'prev_next_buttons_location': 'None',
172        # Toc options
173        'collapse_navigation': False,
174        'sticky_navigation': True,
175        'navigation_depth': 4,
176    }
177
178
179# Here's where we (manually) list the document versions maintained on
180# the published doc website.  On a daily basis we publish to the
181# /latest folder but when releases are made, we publish to a /<relnum>
182# folder (specified via the VERSION file as processed earlier or
183# overridden on the make command line with RELEASE=name.
184
185if tags.has('release'):
186   is_release = True
187   docs_title = '%s' %(version)
188   current_version = version
189   if RELEASE:
190      version = release = current_version = RELEASE
191      docs_title = '%s' %(version)
192else:
193   version = current_version = "latest"
194   is_release = False
195   docs_title = 'Latest'
196
197html_context = {
198   'current_version': current_version,
199   'docs_title': docs_title,
200   'is_release': is_release,
201   'versions': ( ("latest", "/latest/"),
202                 ("3.2", "/3.2/"),
203                 ("3.1", "/3.1/"),
204                 ("3.0", "/3.0/"),
205                 ("2.7", "/2.7/"),
206                 ("2.6", "/2.6/"),
207                 ("2.5", "/2.5/"),
208                 ("2.0", "/2.0/"),
209                 ("1.6.1", "/1.6.1/"),
210                 ("1.0", "/1.0/"),   # keep 1.0
211               )
212    }
213
214
215# Theme options are theme-specific and customize the look and feel of a theme
216# further.  For a list of options available for each theme, see the
217# documentation.
218#
219# html_theme_options = {}
220
221html_logo = 'images/ACRN_Logo_200w.png'
222html_favicon = 'images/ACRN-favicon-32x32.png'
223
224numfig = True
225#numfig_secnum_depth = (2)
226numfig_format = {'figure': 'Figure %s', 'table': 'Table %s', 'code-block': 'Code Block %s'}
227
228# Add any paths that contain custom static files (such as style sheets) here,
229# relative to this directory. They are copied after the builtin static files,
230# so a file named "default.css" will overwrite the builtin "default.css".
231html_static_path = ['static']
232
233def setup(app):
234   import sphinx
235
236   if float(sphinx.__version__[0:3]) < 3.0:
237      app.add_stylesheet("acrn-custom.css")
238      app.add_javascript("https://www.googletagmanager.com/gtag/js?id=UA-831873-64")
239      # note more GA tag manager calls are in acrn-custom.js
240      app.add_javascript("acrn-custom.js")
241   else:
242      app.add_css_file("acrn-custom.css")
243      # we removed the old google analytics codes in favor or enabling analytics
244      # via the "analytics_id" provided by sphinx_RTD_theme
245      # app.add_js_file("https://www.googletagmanager.com/gtag/js?id=UA-831873-64")
246      app.add_js_file("acrn-custom.js")
247
248# Custom sidebar templates, must be a dictionary that maps document names
249# to template names.
250#
251
252# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
253html_show_sphinx = False
254
255# If true, links to the reST sources are added to the pages.
256html_show_sourcelink = True
257
258# If not '', a 'Last updated on:' timestamp is inserted at every page
259# bottom,
260# using the given strftime format.
261html_last_updated_fmt = '%b %d, %Y'
262
263# The name of a javascript file (relative to the configuration directory) that
264# implements a search results scorer. If empty, the default will be used.
265html_search_scorer = 'scorer.js'
266
267# -- Options for HTMLHelp output ------------------------------------------
268
269# Output file base name for HTML help builder.
270htmlhelp_basename = 'ACRN Project Help'
271
272
273# -- Options for LaTeX output ---------------------------------------------
274
275latex_engine = "xelatex"
276
277latex_elements = {
278    'fontpkg': r'''
279\setmainfont{DejaVu Serif}
280\setsansfont{DejaVu Sans}
281\setmonofont{DejaVu Sans Mono}
282''',
283
284    # The paper size ('letterpaper' or 'a4paper').
285    #
286    # 'papersize': 'letterpaper',
287
288    # The font size ('10pt', '11pt' or '12pt').
289    #
290    # 'pointsize': '10pt',
291
292    # Additional stuff for the LaTeX preamble.
293    #
294    'preamble': r'''
295\setcounter{tocdepth}{3}
296\renewcommand\_{\textunderscore\allowbreak}
297\usepackage{listings}
298\usepackage{xcolor}
299\definecolor{IntelMNBlue}{HTML}{003C71}
300\usepackage{titlesec}
301\title{\normalfont\\color{IntelMNBlue}}
302\usepackage{colortbl}
303\protected\def\sphinxstyletheadfamily{\cellcolor[HTML]{DCDCDC}\sffamily\bfseries\color{IntelMNBlue}}
304''',
305    'sphinxsetup': 'hmargin={0.7in,0.7in}, vmargin={1in,1in},\
306verbatimwithframe=true,\
307verbatimwrapslines=true,\
308TitleColor={HTML}{003C71},\
309HeaderFamily=\\rmfamily\\bfseries, \
310InnerLinkColor={HTML}{003C71},\
311OuterLinkColor={HTML}{003C71},\
312VerbatimColor={HTML}{F0F0F0},\
313VerbatimHighlightColor={HTML}{76CEFF},\
314VerbatimBorderColor={HTML}{00285A}',
315
316    # Latex figure (float) alignment
317    #
318    # 'figure_align': 'htbp',
319}
320
321# Grouping the document tree into LaTeX files. List of tuples
322# (source start file, target name, title,
323#  author, documentclass [howto, manual, or own class]).
324latex_documents = [
325    (master_doc, 'acrn.tex', u'Project ACRN Documentation',
326     u'Project ACRN', 'manual',True),
327]
328
329latex_logo = 'images/ACRN_Logo_PrimaryLockup_COLOR-300x300-1.png'
330
331# -- Options for manual page output ---------------------------------------
332
333# One entry per manual page. List of tuples
334# (source start file, name, description, authors, manual section).
335man_pages = [
336    (master_doc, 'acrn', u'Project ACRN Documentation',
337     [author], 1)
338]
339
340
341# -- Options for Texinfo output -------------------------------------------
342
343# Grouping the document tree into Texinfo files. List of tuples
344# (source start file, target name, title, author,
345#  dir menu entry, description, category)
346texinfo_documents = [
347    (master_doc, 'Project ACRN', u'Project ACRN Documentation',
348     author, 'Project ACRN',
349     'IoT-Optimized Hypervisor for Intel Architecture',
350     'Miscellaneous'),
351]
352
353rst_epilog = """
354.. include:: /substitutions.txt
355"""
356
357
358breathe_projects = {
359	"Project ACRN" : "doxygen/xml",
360}
361breathe_default_project = "Project ACRN"
362# breathe_default_members = ('members', 'undoc-members', 'content-only')
363breathe_domain_by_extension = {
364   "h": "c",
365   "c": "c",
366}
367
368cpp_id_attributes = [
369    '__syscall', '__deprecated', '__may_alias',
370    '__used', '__unused', '__weak',
371    '__DEPRECATED_MACRO', 'FUNC_NORETURN',
372    '__subsystem',
373]
374c_id_attributes = cpp_id_attributes
375
376
377
378
379# Custom added feature to allow redirecting old URLs (caused by
380# reorganizing doc directories)
381#
382# list of tuples (old_url, new_url) for pages to redirect
383#
384# URLs must be relative to document root (with NO leading slash),
385# and without the html extension)
386html_redirect_pages = [
387   ('developer-guides/index', 'contribute'),
388   ('getting-started/index', 'try'),
389   ('user-guides/index', 'develop'),
390   ('tutorials/index', 'develop'),
391   ('hardware', 'reference/hardware'),
392   ('release_notes', 'release_notes/index'),
393   ('getting-started/rt_industry', 'getting-started/getting-started'),
394   ('getting-started/rt_industry_ubuntu', 'getting-started/getting-started'),
395   ('getting-started/building-from-source', 'getting-started/getting-started'),
396   ('tutorials/using_vx_works_as_uos', 'tutorials/using_vx_works_as_user_vm'),
397   ('tutorials/using_xenomai_as_uos', 'tutorials/using_xenomai_as_user_vm'),
398   ('tutorials/using_zephyr_as_uos', 'tutorials/using_zephyr_as_user_vm'),
399   ('tutorials/using_windows_as_uos', 'tutorials/using_windows_as_user_vm')
400   ]
401
402# Custom last_updated extension for updating last updated date based on git information
403# needs to know the folders where the cloned files can be found, relative to
404# where the Sphinx .rst build folder
405
406last_updated_git_path = ['../..', '../../..', '../../../doc/']
407