conf.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. from __future__ import unicode_literals
  5. import os
  6. import re
  7. import sys
  8. from datetime import datetime
  9. # Set up Python environment to load build system packages.
  10. OUR_DIR = os.path.dirname(__file__)
  11. topsrcdir = os.path.normpath(os.path.join(OUR_DIR, '..', '..'))
  12. EXTRA_PATHS = (
  13. 'layout/tools/reftest',
  14. 'python/futures',
  15. 'python/jsmin',
  16. 'python/mach',
  17. 'python/mozbuild',
  18. 'python/mozversioncontrol',
  19. 'python/which',
  20. 'testing/mozbase/manifestparser',
  21. 'testing/mozbase/mozfile',
  22. 'testing/mozbase/mozprocess',
  23. )
  24. sys.path[:0] = [os.path.join(topsrcdir, p) for p in EXTRA_PATHS]
  25. sys.path.insert(0, OUR_DIR)
  26. extensions = [
  27. 'sphinx.ext.autodoc',
  28. 'sphinx.ext.graphviz',
  29. 'sphinx.ext.todo',
  30. 'mozbuild.sphinx',
  31. ]
  32. templates_path = ['_templates']
  33. source_suffix = '.rst'
  34. master_doc = 'index'
  35. project = u'Mozilla Source Tree Docs'
  36. year = datetime.utcnow().year
  37. # Grab the version from the source tree's milestone.
  38. # FUTURE Use Python API from bug 941299.
  39. with open(os.path.join(topsrcdir, 'config', 'milestone.txt'), 'rt') as fh:
  40. for line in fh:
  41. line = line.strip()
  42. if not line or line.startswith('#'):
  43. continue
  44. release = line
  45. break
  46. version = re.sub(r'[ab]\d+$', '', release)
  47. exclude_patterns = ['_build', '_staging', '_venv']
  48. pygments_style = 'sphinx'
  49. # We need to perform some adjustment of the settings and environment
  50. # when running on Read The Docs.
  51. on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
  52. if on_rtd:
  53. # SHELL isn't set on RTD and mach.mixin.process's import raises if a
  54. # shell-related environment variable can't be found. Set the variable here
  55. # to hack us into working on RTD.
  56. assert 'SHELL' not in os.environ
  57. os.environ['SHELL'] = '/bin/bash'
  58. else:
  59. # We only need to set the RTD theme when not on RTD because the RTD
  60. # environment handles this otherwise.
  61. import sphinx_rtd_theme
  62. html_theme = 'sphinx_rtd_theme'
  63. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  64. html_static_path = ['_static']
  65. htmlhelp_basename = 'MozillaTreeDocs'