|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# MongoDB documentation build configuration file, created by |
| 4 | +# sphinx-quickstart on Mon Oct 3 09:58:40 2011. |
| 5 | +# |
| 6 | +# This file is execfile()d with the current directory set to its containing dir. |
| 7 | + |
| 8 | +import sys |
| 9 | +import os |
| 10 | +import datetime |
| 11 | + |
| 12 | +from sphinx.errors import SphinxError |
| 13 | + |
| 14 | +from giza.config.runtime import RuntimeStateConfig |
| 15 | +from giza.config.helper import fetch_config, get_manual_path |
| 16 | + |
| 17 | +conf = fetch_config(RuntimeStateConfig()) |
| 18 | +sconf = conf.system.files.data.sphinx_local |
| 19 | + |
| 20 | +sys.path.append(os.path.join(conf.paths.projectroot, conf.paths.buildsystem, 'sphinxext')) |
| 21 | + |
| 22 | +try: |
| 23 | + tags |
| 24 | +except NameError: |
| 25 | + class Tags(object): |
| 26 | + def has(self, *args): |
| 27 | + return False |
| 28 | + |
| 29 | + tags = Tags() |
| 30 | + |
| 31 | +# -- General configuration ---------------------------------------------------- |
| 32 | + |
| 33 | +needs_sphinx = '1.0' |
| 34 | + |
| 35 | +extensions = [ |
| 36 | + 'sphinx.ext.extlinks', |
| 37 | + 'sphinx.ext.todo', |
| 38 | + 'mongodb', |
| 39 | + 'directives', |
| 40 | + 'intermanual', |
| 41 | + 'testcode' |
| 42 | +] |
| 43 | + |
| 44 | +locale_dirs = [ os.path.join(conf.paths.projectroot, conf.paths.locale) ] |
| 45 | +gettext_compact = False |
| 46 | + |
| 47 | +templates_path = ['.templates'] |
| 48 | +exclude_patterns = [] |
| 49 | + |
| 50 | +source_suffix = '.txt' |
| 51 | + |
| 52 | +master_doc = sconf.master_doc |
| 53 | +language = 'en' |
| 54 | +project = sconf.project |
| 55 | +copyright = u'2008-{0}'.format(datetime.date.today().year) |
| 56 | + |
| 57 | +rst_epilog = '\n'.join([ |
| 58 | + '.. |copy| unicode:: U+000A9', |
| 59 | + '.. |ent-build| replace:: MongoDB Enterprise', |
| 60 | + '.. |year| replace:: {0}'.format(datetime.date.today().year), |
| 61 | + '.. |hardlink| replace:: {0}/{1}'.format(conf.project.url, conf.git.branches.current), |
| 62 | + '.. |branch| replace:: ``{0}``'.format(conf.git.branches.current), |
| 63 | + '.. |bi| replace:: MongoDB Connector for BI', |
| 64 | +]) |
| 65 | + |
| 66 | +pygments_style = 'sphinx' |
| 67 | + |
| 68 | +extlinks = { |
| 69 | + 'hardlink' : ( 'http://docs.mongodb.com/{0}/%s'.format(conf.git.branches.current), ''), |
| 70 | + 'issue': ('https://jira.mongodb.org/browse/%s', '' ), |
| 71 | + 'api': ('https://api.mongodb.com/%s', ''), |
| 72 | + 'gettingstarted': ('https://docs.mongodb.com/getting-started%s', ''), |
| 73 | + 'manual': ('https://docs.mongodb.com/manual%s', ''), |
| 74 | + 'ecosystem': ('https://docs.mongodb.com/ecosystem%s', ''), |
| 75 | + 'mms-docs': ('https://docs.cloudmanager.mongodb.com%s', ''), |
| 76 | + 'mms-home': ('https://www.mongodb.com/cloud/cloud-manager%s', ''), |
| 77 | + 'opsmgr': ('https://docs.opsmanager.mongodb.com/current%s', ''), |
| 78 | + 'products': ('https://www.mongodb.com/products%s', ''), |
| 79 | + 'wtdocs': ('http://source.wiredtiger.com/mongodb-3.4%s', ''), |
| 80 | + |
| 81 | +} |
| 82 | + |
| 83 | +## add `extlinks` for each published version. |
| 84 | +for i in conf.git.branches.published: |
| 85 | + extlinks[i] = ( ''.join([ conf.project.url, '/', i, '%s' ]), '' ) |
| 86 | + |
| 87 | +intersphinx_mapping = {} |
| 88 | +for i in conf.system.files.data.intersphinx: |
| 89 | + intersphinx_mapping[i.name] = ( i.url, os.path.join(conf.paths.projectroot, |
| 90 | + conf.paths.output, |
| 91 | + i.path)) |
| 92 | + |
| 93 | +languages = [ |
| 94 | + ("ar", "Arabic"), |
| 95 | + ("cn", "Chinese"), |
| 96 | + ("cs", "Czech"), |
| 97 | + ("de", "German"), |
| 98 | + ("es", "Spanish"), |
| 99 | + ("fr", "French"), |
| 100 | + ("hu", "Hungarian"), |
| 101 | + ("id", "Indonesian"), |
| 102 | + ("it", "Italian"), |
| 103 | + ("jp", "Japanese"), |
| 104 | + ("ko", "Korean"), |
| 105 | + ("lt", "Lithuanian"), |
| 106 | + ("pl", "Polish"), |
| 107 | + ("pt", "Portuguese"), |
| 108 | + ("ro", "Romanian"), |
| 109 | + ("ru", "Russian"), |
| 110 | + ("tr", "Turkish"), |
| 111 | + ("uk", "Ukrainian") |
| 112 | +] |
| 113 | + |
| 114 | +# -- Options for HTML output --------------------------------------------------- |
| 115 | + |
| 116 | +html_theme = sconf.theme.name |
| 117 | +html_theme_path = [ os.path.join(conf.paths.buildsystem, 'themes') ] |
| 118 | +html_title = conf.project.title |
| 119 | +htmlhelp_basename = 'MongoDBdoc' |
| 120 | + |
| 121 | +html_copy_source = False |
| 122 | +html_use_smartypants = True |
| 123 | +html_domain_indices = True |
| 124 | +html_use_index = True |
| 125 | +html_split_index = False |
| 126 | +html_show_sourcelink = False |
| 127 | +html_show_sphinx = True |
| 128 | +html_show_copyright = True |
| 129 | + |
| 130 | +manual_edition_path = '{0}/{1}/{2}'.format(conf.project.url, |
| 131 | + conf.git.branches.current, |
| 132 | + sconf.theme.book_path_base) |
| 133 | + |
| 134 | +html_theme_options = { |
| 135 | + 'branch': conf.git.branches.current, |
| 136 | + 'pdfpath': manual_edition_path + '-' + conf.git.branches.current + '.pdf', |
| 137 | + 'epubpath': manual_edition_path + '.epub', |
| 138 | + 'manual_path': get_manual_path(conf), |
| 139 | + 'translations': languages, |
| 140 | + 'language': language, |
| 141 | + 'repo_name': sconf.theme.repo, |
| 142 | + 'jira_project': sconf.theme.jira, |
| 143 | + 'google_analytics': sconf.theme.google_analytics, |
| 144 | + 'project': sconf.theme.project, |
| 145 | + 'sitename': sconf.theme.sitename, |
| 146 | + 'nav_excluded': sconf.theme.nav_excluded, |
| 147 | +} |
| 148 | + |
| 149 | +html_sidebars = sconf.sidebars |
| 150 | + |
| 151 | +# -- Options for LaTeX output -------------------------------------------------- |
| 152 | + |
| 153 | +latex_documents = [] |
| 154 | +if 'pdfs' in conf.system.files.data: |
| 155 | + for pdf in conf.system.files.data.pdfs: |
| 156 | + latex_documents.append((pdf.source, pdf.output, pdf.title, pdf.author, pdf.doc_class)) |
| 157 | + |
| 158 | +latex_preamble_elements = [ r'\DeclareUnicodeCharacter{FF04}{\$}', |
| 159 | + r'\DeclareUnicodeCharacter{FF0E}{.}', |
| 160 | + r'\DeclareUnicodeCharacter{2713}{Y}', |
| 161 | + r'\PassOptionsToPackage{hyphens}{url}', |
| 162 | + r'\usepackage{upquote}', |
| 163 | + r'\pagestyle{plain}', |
| 164 | + r'\pagenumbering{arabic}' ] |
| 165 | +latex_elements = { |
| 166 | + 'preamble': '\n'.join(latex_preamble_elements), |
| 167 | + 'pointsize': '10pt', |
| 168 | + 'papersize': 'letterpaper', |
| 169 | + 'tableofcontents': '\\textcopyright{ MongoDB, Inc. 2008 - 2016 } This work is licensed under a \href{http://creativecommons.org/licenses/by-nc-sa/3.0/us/}{Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License}\\clearpage\\tableofcontents' |
| 170 | +} |
| 171 | + |
| 172 | +latex_paper_size = 'letter' |
| 173 | +latex_use_parts = False |
| 174 | +latex_show_pagerefs = True |
| 175 | +latex_show_urls = 'footnote' |
| 176 | +latex_domain_indices = False |
| 177 | +latex_logo = None |
| 178 | +latex_appendices = [] |
| 179 | + |
| 180 | +# -- Options for manual page output -------------------------------------------- |
| 181 | + |
| 182 | +man_pages = [] |
| 183 | +if 'manpages' in conf.system.files.data: |
| 184 | + for mp in conf.system.files.data.manpages: |
| 185 | + man_pages.append((mp.file, mp.name, mp.title, mp.authors, mp.section)) |
| 186 | + |
| 187 | +# -- Options for Epub output --------------------------------------------------- |
| 188 | + |
| 189 | +# Bibliographic Dublin Core info. |
| 190 | +epub_title = conf.project.title |
| 191 | +epub_author = u'MongoDB, Inc.' |
| 192 | +epub_publisher = u'MongoDB, Inc.' |
| 193 | +epub_copyright = u'MongoDB, Inc. 2008 - 2016' |
| 194 | +epub_theme = 'epub_mongodb' |
| 195 | +epub_tocdup = True |
| 196 | +epub_tocdepth = 3 |
| 197 | +epub_language = language |
| 198 | +epub_scheme = 'url' |
| 199 | +epub_identifier = ''.join([conf.project.url, '/', conf.git.branches.current]) |
| 200 | +epub_exclude_files = [] |
| 201 | + |
| 202 | +epub_pre_files = [] |
| 203 | +epub_post_files = [] |
| 204 | + |
| 205 | +# put it into your conf.py |
| 206 | +def setup(app): |
| 207 | + # disable versioning for speed |
| 208 | + from sphinx.builders.gettext import I18nBuilder |
| 209 | + I18nBuilder.versioning_method = 'none' |
| 210 | + |
| 211 | + def doctree_read(app, doctree): |
| 212 | + if not isinstance(app.builder, I18nBuilder): |
| 213 | + return |
| 214 | + from docutils import nodes |
| 215 | + from sphinx.versioning import add_uids |
| 216 | + list(add_uids(doctree, nodes.TextElement)) |
| 217 | + app.connect('doctree-read', doctree_read) |
0 commit comments