def resolve_builder_path(builder, edition, language, conf): dirname = builder if edition is not None and edition != conf.project.name: dirname = hyph_concat(dirname, edition) if language is not None and language != "en": dirname = hyph_concat(dirname, language) return os.path.join(conf.paths.projectroot, conf.paths.branch_output, dirname)
def register(self, builder, language, edition): self.language = language self.builder = builder self.edition = edition if edition is None: lookup = self.builder else: lookup = hyph_concat(self.builder, self.edition) base = self._raw[lookup] for i in ['excluded', 'tags', 'languages']: if i in base: setattr(self, i, base[i]) m = 'registered language, builder, and edition options: ({0}, {1}, {2})' logger.debug(m.format(language, builder, edition))
def update(conf): logger.info('updating translation artifacts. Long running.') project_name = conf.project.title.lower().split() if conf.project.edition is not None and conf.project.edition != conf.project.name: project_name.append(conf.project.edition) project_name = hyph_concat(*project_name) logger.info('starting translation upload with sphinx-intl') flogger = FileLogger(logger) update_txconfig_resources(transifex_project_name=project_name, locale_dir=conf.paths.locale, pot_dir=os.path.join(conf.paths.locale, 'pot'), out=flogger) logger.info('sphinx-intl: updated pot directory')
def register(self, builder, language, edition): self.language = language self.builder = builder self.edition = edition if edition is None: lookup = self.builder else: lookup = hyph_concat(self.builder, self.edition) self.name = lookup base = self._raw[lookup] for i in ["excluded", "tags", "languages"]: if i in base: setattr(self, i, base[i]) m = "registered language, builder, and edition options: ({0}, {1}, {2})" logger.debug(m.format(language, builder, edition))
def main(): m = MakefileCloth() conf = new_config() output_file = os.path.join(conf.paths.projectroot, conf.paths.output, 'makefile.giza_build') m.section_break('giza build integration') m.newline() m.section_break('content generation targets') for gen_target in [ 'api', 'assets', 'images', 'intersphinx', 'options', 'primer', 'steps', 'tables', 'toc']: m.target(hyph_concat('giza', gen_target)) m.job('giza generate ' + gen_target) m.target(hyph_concat('giza', 'force', gen_target)) m.job('giza --force generate ' + gen_target) m.newline() m.section_break('sphinx targets') sconf = ingest_yaml_doc(os.path.join(conf.paths.projectroot, conf.paths.builddata, 'sphinx.yaml')) builders = [b for b in sconf if not b.endswith('base') and b not in ('prerequisites', 'generated-source', 'languages', 'editions', 'sphinx_builders')] if 'editions' in sconf: editions = sconf['editions'] else: editions = [] if 'root-base' in sconf and 'languages' in sconf['root-base']: languages = sconf['root-base']['languages'] else: languages = [] complete = [] for builder in builders: if '-' in builder: builder = builder.split('-')[0] if builder in complete: continue m.comment(builder + ' targets') for edition in editions: m.target(hyph_concat('giza', builder, edition)) m.job('giza sphinx --builder {0} --edition {1}'.format(builder, edition)) for language in languages: m.target(hyph_concat('giza', builder, edition, language)) m.job('giza sphinx --builder {0} --edition {1} --language {2}'.format(builder, edition, language)) if len(editions) == 0: m.target(hyph_concat('giza', builder)) m.job('giza sphinx --builder ' + builder) for language in languages: m.target(hyph_concat('giza', builder, language)) m.job('giza sphinx --builder {0} --language {1}'.format(builder, language)) else: m.target(hyph_concat('giza', builder)) m.job('giza sphinx --builder {0} --edition {1}'.format(builder, ' '.join(editions))) m.newline() complete.append(builder) m.section_break('deploy targets') if 'push' in conf.system.files.data: for ptarget in conf.system.files.data.push: name = ptarget['target'] m.target(hyph_concat('giza-deploy', name)) m.job('giza deploy --target ' + name) m.newline() integration_path = os.path.join(conf.paths.projectroot, conf.paths.builddata, 'integration.yaml') if os.path.exists(integration_path): m.section_break('integration and publish targets') iconf = ingest_yaml_doc(integration_path) if 'base' in iconf: languages = [ k for k in iconf.keys() if not k.endswith('base') ] iconf = iconf['base'] else: languages = [] targets = set([ target.split('-')[0] for target in iconf['targets'] if '/' not in target and not target.startswith('htaccess') ]) base_job = 'giza sphinx --builder {0}'.format(' '.join(targets)) if len(editions) > 0: base_job += " --serial_sphinx --edition " + ' '.join(editions) m.target('giza-publish') m.job(base_job) m.newline() for lang in languages: m.target('giza-publish-' + lang) m.job(base_job + ' --language ' + lang) m.newline() # following targets build a group of sphinx targets followed by running # one or more deploy actions. m.section_break('push targets') if 'push' in conf.system.files.data: for ptarget in conf.system.files.data.push: push_base_job = 'giza push --deploy {0} --builder {1}'.format(ptarget['target'], ' '.join(targets)) if len(editions) > 0: push_base_job += " --serial_sphinx --edition " + ' '.join(editions) m.target('giza-' + ptarget['target']) m.job(push_base_job) m.newline() for lang in languages: m.target('giza-{0}-{1}'.format(ptarget['target'], lang)) m.job(push_base_job + ' --language ' + lang) m.newline() m.write(output_file) print('[meta-build]: built "build/makefile.giza_build" to integrate giza')
def pdf_tasks(sconf, conf, app): target = sconf.builder if 'pdfs' not in conf.system.files.data: return app.pool = 'thread' tex_regexes = [ ( re.compile(r'(index|bfcode)\{(.*)--(.*)\}'), r'\1\{\2-\{-\}\3\}'), ( re.compile(r'\\PYGZsq{}'), "'"), ( re.compile(r'\\code\{/(?!.*{}/|etc|usr|data|var|srv)'), r'\code{' + conf.project.url + r'/' + conf.project.tag) ] clean_app = app.add('app') cache_app = app.add('app') render_app = app.add('app') migrate_app = app.add('app') link_app = app.add('app') for i in conf.system.files.data.pdfs: tagged_name = i['output'][:-4] + '-' + i['tag'] deploy_fn = tagged_name + '-' + conf.git.branches.current + '.pdf' link_name = deploy_fn.replace('-' + conf.git.branches.current, '') if 'edition' in conf.project and conf.project.edition != conf.project.name: if 'edition' in i and conf.project.edition != i['edition']: continue latex_dir = os.path.join(conf.paths.branch_output, hyph_concat(target, conf.project.edition)) else: latex_dir = os.path.join(conf.paths.branch_output, target) deploy_path = conf.paths.public_site_output i['source'] = os.path.join(latex_dir, i['output']) i['processed'] = os.path.join(latex_dir, tagged_name + '.tex') i['pdf'] = os.path.join(latex_dir, tagged_name + '.pdf') i['deployed'] = os.path.join(deploy_path, deploy_fn) i['link'] = os.path.join(deploy_path, link_name) i['path'] = latex_dir clean_task = clean_app.add('task') clean_task.target = i['source'] clean_task.job = _clean_sphinx_latex clean_task.args = (i['source'], tex_regexes) cache_task = cache_app.add('task') cache_task.dependency = i['source'] cache_task.target = i['processed'] cache_task.job = copy_if_needed cache_task.args = (i['source'], i['processed'], 'pdf') render_task = render_app.add('task') render_task.dependency = i['processed'] render_task.target = i['pdf'] render_task.job = _render_tex_into_pdf render_task.args = (i['processed'], i['path']) migrate_task = migrate_app.add('task') migrate_task.dependency = i['pdf'] migrate_task.target = i['deployed'] migrate_task.job = copy_if_needed migrate_task.args = (i['pdf'], i['deployed'], 'pdf') if i['link'] != i['deployed']: link_task = link_app.add('task') link_task.dependency = i['deployed'] link_task.target = i['link'] link_task.job = create_link link_task.args = (deploy_fn, i['link'])
def locale(self): if self.conf.project.edition is not None and self.conf.project.edition != self.conf.project.name: return hyph_concat(self.state['locale'], self.conf.project.edition) else: return self.state['locale']