|
9 | 9 | import os
|
10 | 10 | import datetime
|
11 | 11 |
|
| 12 | +from sphinx.errors import SphinxError |
| 13 | + |
12 | 14 | try:
|
13 | 15 | project_root = os.path.join(os.path.abspath(os.path.dirname(__file__)))
|
14 | 16 | except NameError:
|
|
21 | 23 | sys.path.append(os.path.join(project_root, buildsystem, 'sphinxext'))
|
22 | 24 | sys.path.append(os.path.join(project_root, buildsystem, 'bin'))
|
23 | 25 |
|
24 |
| -from utils import ingest_yaml, ingest_yaml_list |
25 |
| -from docs_meta import get_conf, get_versions, get_manual_path |
| 26 | +from utils.config import get_conf |
| 27 | +from utils.project import get_versions, get_manual_path |
| 28 | +from utils.serialization import ingest_yaml, ingest_yaml_list |
| 29 | +from utils.structures import BuildConfiguration |
| 30 | +from utils.strings import dot_concat |
26 | 31 |
|
27 | 32 | conf = get_conf()
|
28 | 33 |
|
29 | 34 | conf.paths.projectroot = project_root
|
30 |
| -pdfs = ingest_yaml_list(os.path.join(conf.paths.builddata, 'pdfs.yaml')) |
31 | 35 | intersphinx_libs = ingest_yaml_list(os.path.join(conf.paths.builddata, 'intersphinx.yaml'))
|
| 36 | +sconf = BuildConfiguration(os.path.join(conf.paths.builddata, 'sphinx-local.yaml')) |
32 | 37 |
|
33 | 38 | # -- General configuration ----------------------------------------------------
|
34 | 39 |
|
|
50 | 55 |
|
51 | 56 | source_suffix = '.txt'
|
52 | 57 |
|
53 |
| -master_doc = 'contents' |
| 58 | +master_doc = sconf.master_doc |
54 | 59 | language = 'en'
|
55 |
| -project = u'mongodb-manual' |
| 60 | +project = sconf.project |
56 | 61 | copyright = u'2011-' + str(datetime.date.today().year) + ', MongoDB, Inc.'
|
57 | 62 | version = conf.version.branch
|
58 | 63 | release = conf.version.release
|
|
72 | 77 | 'wiki': ('http://www.mongodb.org/display/DOCS/%s', ''),
|
73 | 78 | 'api': ('http://api.mongodb.org/%s', ''),
|
74 | 79 | 'source': ('https://github.com/mongodb/mongo/blob/master/%s', ''),
|
75 |
| - 'docsgithub' : ( 'http://github.com/mongodb/docs/blob/' + conf.git.branches.current + '/%s', ''), |
76 |
| - 'hardlink' : ( 'http://docs.mongodb.org/' + conf.git.branches.current + '/%s', ''), |
| 80 | + 'docsgithub' : ( 'http://github.com/mongodb/docs/blob/{0}/%s'.format(conf.git.branches.current), ''), |
| 81 | + 'hardlink' : ( 'http://docs.mongodb.org/{0}/%s'.format(conf.git.branches.current), ''), |
77 | 82 | 'manual': ('http://docs.mongodb.org/manual%s', ''),
|
78 | 83 | 'ecosystem': ('http://docs.mongodb.org/ecosystem%s', ''),
|
79 | 84 | 'meta-driver': ('http://docs.mongodb.org/meta-driver/latest%s', ''),
|
|
84 | 89 |
|
85 | 90 | ## add `extlinks` for each published version.
|
86 | 91 | for i in conf.git.branches.published:
|
87 |
| - extlinks[i] = ( conf.project.url + '/' + i + '%s', '') |
| 92 | + extlinks[i] = ( ''.join([ conf.project.url, '/', i, '%s' ]), '' ) |
88 | 93 |
|
89 | 94 | intersphinx_mapping = {}
|
90 | 95 | for i in intersphinx_libs:
|
|
115 | 120 |
|
116 | 121 | # -- Options for HTML output ---------------------------------------------------
|
117 | 122 |
|
118 |
| -html_theme = 'manual' |
| 123 | +html_theme = sconf.theme.name |
119 | 124 | html_theme_path = [ os.path.join(buildsystem, 'themes') ]
|
120 | 125 | html_title = conf.project.title
|
121 | 126 | htmlhelp_basename = 'MongoDBdoc'
|
122 | 127 |
|
123 |
| -html_logo = ".static/logo-mongodb.png" |
124 |
| -html_static_path = ['source/.static'] |
| 128 | +html_logo = sconf.logo |
| 129 | +html_static_path = sconf.paths.static |
125 | 130 |
|
126 | 131 | html_copy_source = False
|
127 | 132 | html_use_smartypants = True
|
|
132 | 137 | html_show_sphinx = True
|
133 | 138 | html_show_copyright = True
|
134 | 139 |
|
135 |
| -manual_edition_path = '{0}/{1}/MongoDB-manual'.format(conf.project.url, conf.git.branches.current) |
| 140 | +manual_edition_path = '{0}/{1}/{2}'.format(conf.project.url, |
| 141 | + conf.git.branches.current, |
| 142 | + sconf.theme.book_path_base) |
136 | 143 |
|
137 | 144 | html_theme_options = {
|
138 | 145 | 'branch': conf.git.branches.current,
|
139 |
| - 'pdfpath': manual_edition_path + '.pdf', |
140 |
| - 'epubpath': manual_edition_path + '.epub', |
| 146 | + 'pdfpath': dot_concat(manual_edition_path, 'pdf'), |
| 147 | + 'epubpath': dot_concat(manual_edition_path, 'epub'), |
141 | 148 | 'manual_path': get_manual_path(conf),
|
142 | 149 | 'translations': languages,
|
143 | 150 | 'language': language,
|
144 |
| - 'repo_name': 'docs', |
145 |
| - 'jira_project': 'DOCS', |
146 |
| - 'google_analytics': 'UA-7301842-8', |
147 |
| - 'project': 'manual', |
| 151 | + 'repo_name': sconf.theme.repo, |
| 152 | + 'jira_project': sconf.theme.jira, |
| 153 | + 'google_analytics': sconf.theme.google_analytics, |
| 154 | + 'project': sconf.theme.project, |
148 | 155 | 'version': version,
|
149 | 156 | 'version_selector': get_versions(conf),
|
150 | 157 | 'stable': conf.version.stable,
|
151 | 158 | }
|
152 | 159 |
|
153 |
| -html_sidebars = { |
154 |
| - '**': ['pagenav.html'], |
155 |
| -} |
156 |
| -html_sidebars['**'].append('formats.html') |
| 160 | +html_sidebars = sconf.sidebars |
157 | 161 |
|
158 | 162 | # -- Options for LaTeX output --------------------------------------------------
|
159 | 163 |
|
| 164 | +if tags.has('latex'): |
| 165 | + pdf_conf_path = os.path.join(conf.paths.builddata, 'pdfs.yaml') |
| 166 | + if os.path.exists(pdf_conf_path): |
| 167 | + pdfs = ingest_yaml_list(pdf_conf_path) |
| 168 | + else: |
| 169 | + raise SphinxError('[WARNING]: skipping pdf builds because of missing {0} file'.format(pdf_conf_path)) |
| 170 | +else: |
| 171 | + pdfs = [] |
| 172 | + |
160 | 173 | latex_documents = []
|
161 | 174 | for pdf in pdfs:
|
162 | 175 | _latex_document = ( pdf['source'], pdf['output'], pdf['title'], pdf['author'], pdf['class'])
|
|
184 | 197 |
|
185 | 198 | # -- Options for manual page output --------------------------------------------
|
186 | 199 |
|
187 |
| -man_pages = [ |
188 |
| - # (source start file, name, description, authors, manual section). |
189 |
| - ('reference/program/bsondump', 'bsondump', u'MongoDB BSON utility', [u'MongoDB Documentation Project'], 1), |
190 |
| - ('reference/program/mongo', 'mongo', u'MongoDB Shell', [u'MongoDB Documentation Project'], 1), |
191 |
| - ('reference/program/mongod', 'mongod', u'MongoDB Server', [u'MongoDB Documentation Project'], 1), |
192 |
| - ('reference/program/mongos', 'mongos', u'MongoDB Shard Utility', [u'MongoDB Documentation Project'], 1), |
193 |
| - ('reference/program/mongodump', 'mongodump', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
194 |
| - ('reference/program/mongoexport', 'mongoexport', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
195 |
| - ('reference/program/mongofiles', 'mongofiles', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
196 |
| - ('reference/program/mongoimport', 'mongoimport', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
197 |
| - ('reference/program/mongooplog', 'mongooplog', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
198 |
| - ('reference/program/mongorestore', 'mongorestore', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
199 |
| - ('reference/program/mongostat', 'mongostat', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
200 |
| - ('reference/program/mongosniff', 'mongosniff', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
201 |
| - ('reference/program/mongotop', 'mongotop', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
202 |
| - ('reference/program/mongoperf', 'mongoperf', u'MongoDB', [u'MongoDB Documentation Project'], 1), |
203 |
| - ('reference/parameters', 'mongodb-parameters', u'MongoDB Parameters', [u'MongoDB Documentation Project'], 5), |
204 |
| -] |
| 200 | +if tags.has('man'): |
| 201 | + man_page_conf_path = os.path.join(conf.paths.builddata, 'manpages.yaml') |
| 202 | + if os.path.exists(man_page_conf_path): |
| 203 | + man_page_definitions = ingest_yaml_list(man_page_conf_path) |
| 204 | + else: |
| 205 | + raise SphinxError('[WARNING]: skipping man builds because of missing {0} file'.format(man_page_conf_path)) |
| 206 | +else: |
| 207 | + man_page_definitions = [] |
| 208 | + |
| 209 | +man_pages = [] |
| 210 | +for mp in man_page_definitions: |
| 211 | + man_pages.append((mp['file'], mp['name'], mp['title'], mp['authors'], mp['section'])) |
205 | 212 |
|
206 | 213 | # -- Options for Epub output ---------------------------------------------------
|
207 | 214 |
|
|
215 | 222 | epub_tocdepth = 3
|
216 | 223 | epub_language = language
|
217 | 224 | epub_scheme = 'url'
|
218 |
| -epub_identifier = conf.project.url + '/' + conf.git.branches.current |
| 225 | +epub_identifier = ''.join([conf.project.url, '/', conf.git.branches.current]) |
219 | 226 | epub_exclude_files = []
|
220 | 227 |
|
221 | 228 | epub_pre_files = []
|
|
0 commit comments