def init(self): # type: () -> None Builder.init(self) self.env.set_versioning_method(self.versioning_method, self.env.config.gettext_uuid) self.tags = I18nTags() self.catalogs = defaultdict(Catalog) # type: DefaultDict[unicode, Catalog]
def post_process_images(self, doctree): # type: (nodes.Node) -> None """Pick the best candidate for an image and link down-scaled images to their high res version. """ Builder.post_process_images(self, doctree) if self.config.html_scaled_image_link and self.html_scaled_image_link: for node in doctree.traverse(nodes.image): scale_keys = ('scale', 'width', 'height') if not any((key in node) for key in scale_keys) or \ isinstance(node.parent, nodes.reference): # docutils does unfortunately not preserve the # ``target`` attribute on images, so we need to check # the parent node here. continue uri = node['uri'] reference = nodes.reference('', '', internal=True) if uri in self.images: reference['refuri'] = posixpath.join(self.imgpath, self.images[uri]) else: reference['refuri'] = uri node.replace_self(reference) reference.append(node)
def __init__(self, *args, **kwargs): """ Constructor, add a logger. """ Builder.__init__(self, *args, **kwargs) self.logger = logging.getLogger("DocFxMdBuilder") self.file_mapping = {}
def __init__(self, *args, **kwargs): """ Constructor, add a logger. """ Builder.__init__(self, *args, **kwargs) self.logger = logging.getLogger("RstBuilder") # Should not be populated, it may be due to a function # implemented for HTML but used for RST. self.body = _BodyPlaceholder(self)
def finish(self): Builder.finish(self) output_path = path.join(self.config.omegat_translated_path, self.config.language, "LC_MESSAGES") ensuredir(output_path) sourcedir = path.join(self.config.omegat_project_path, "target") for filename in os.listdir(sourcedir): if not filename.endswith(".po"): continue infile = path.join(sourcedir, filename) outfile = path.join(output_path, path.splitext(filename)[0] + ".mo") if path.exists(outfile): if path.getmtime(infile) < path.getmtime(outfile): continue self._make(infile, outfile)
def finish(self): Builder.finish(self) output_path = path.join( self.config.omegat_translated_path, self.config.language, "LC_MESSAGES") ensuredir(output_path) sourcedir = path.join(self.config.omegat_project_path, 'target') for filename in os.listdir(sourcedir): if not filename.endswith(".po"): continue infile = path.join(sourcedir, filename) outfile = path.join(output_path, path.splitext(filename)[0] + '.mo') if path.exists(outfile): if path.getmtime(infile) < path.getmtime(outfile): continue self._make(infile, outfile)
def init(self): Builder.init(self) errors = False if not self.config.omegat_translated_path: self.info(red("'omegat_translated_path' should not be empty.")) errors = True if not self.config.omegat_project_path: self.info(red("'omegat_project_path' should not be empty.")) errors = True if self.config.omegat_translated_path not in self.config.locale_dirs: self.info(red("'omegat_translated_path' should be in locale_dirs.")) errors = True if not self.config.language: self.info(red("'language' should be set.")) errors = True if errors: self.info(red(" -> Please check conf.py")) raise RuntimeError("lack setting")
def ensure_tempdir(builder: Builder) -> str: """Create temporary directory. use only one tempdir per build -- the use of a directory is cleaner than using temporary files, since we can clean up everything at once just removing the whole directory (see cleanup_tempdir) """ if not hasattr(builder, '_imgmath_tempdir'): builder._imgmath_tempdir = tempfile.mkdtemp() # type: ignore return builder._imgmath_tempdir # type: ignore
def post_process_images(self, doctree): """Pick the best candidate for an image and link down-scaled images to their high res version. """ Builder.post_process_images(self, doctree) for node in doctree.traverse(nodes.image): scale_keys = ("scale", "width", "height") if not any((key in node) for key in scale_keys) or isinstance(node.parent, nodes.reference): # docutils does unfortunately not preserve the # ``target`` attribute on images, so we need to check # the parent node here. continue uri = node["uri"] reference = nodes.reference("", "", internal=True) if uri in self.images: reference["refuri"] = posixpath.join(self.imgpath, self.images[uri]) else: reference["refuri"] = uri node.replace_self(reference) reference.append(node)
def post_process_images(self, doctree): """Pick the best candidate for an image and link down-scaled images to their high res version. """ Builder.post_process_images(self, doctree) for node in doctree.traverse(nodes.image): if not node.has_key('scale') or \ isinstance(node.parent, nodes.reference): # docutils does unfortunately not preserve the # ``target`` attribute on images, so we need to check # the parent node here. continue uri = node['uri'] reference = nodes.reference('', '', internal=True) if uri in self.images: reference['refuri'] = posixpath.join(self.imgpath, self.images[uri]) else: reference['refuri'] = uri node.replace_self(reference) reference.append(node)
def mkref(self, builder: Builder, term: Term, match: GlossaryListing, textnode): """Make a referenc node""" refuri = None if match: refuri = builder.get_relative_uri(match.doc, match.identifier) refnode = nodes.reference("", "", internal=True, reftitle="", refuri=refuri, refid=f"termref-{term}") if not match: refnode['classes'].append("term-missing") refnode.append(textnode) return refnode
def resolve_xref( self, env: BuildEnvironment, fromdocname: str, builder: Builder, type: str, target: str, node: nodes.pending_xref, contnode: Element ) -> Optional[Element]: reftarget = node.attributes['reftarget'] td_package_ref = node.attributes['reftype'] tdproto_target = TDPROTO_TARGETS.get((td_package_ref, reftarget)) if tdproto_target is None: return None refuri = ( builder.get_relative_uri(fromdocname, DATA_INDEX_DOC_NAME) + f"#{td_package_ref}-{reftarget}" ) return nodes.reference( text=reftarget, refuri=refuri, internal=False)
def init(self): Builder.init(self) self.catalogs = defaultdict(Catalog)
def init(self): Builder.init(self) self.tags = I18nTags() self.catalogs = defaultdict(Catalog)
def post_process_images(self, doctree): Builder.post_process_images(self, doctree)
def init(self): # type: () -> None Builder.init(self) self.tags = I18nTags() self.catalogs = defaultdict( Catalog) # type: defaultdict[unicode, Catalog]
def __init__(self, *args, **kwargs): """ Constructor, add a logger. """ Builder.__init__(self, *args, **kwargs) self.logger = logging.getLogger("RstBuilder")
def init(self): # type: () -> None Builder.init(self) self.tags = I18nTags() self.catalogs = defaultdict(Catalog) # type: defaultdict[unicode, Catalog]
def __init__(self, app): """ """ Builder.__init__(self, app)