Example #1
0
    def path2doc(self, filename: str) -> Optional[str]:
        """Return the docname for the filename if the file is a document.

        *filename* should be absolute or relative to the source directory.
        """
        if filename.startswith(self.srcdir):
            filename = relpath(filename, self.srcdir)
        for suffix in self.source_suffix:
            if filename.endswith(suffix):
                filename = path_stabilize(filename)
                return filename[:-len(suffix)]

        # the file does not have docname
        return None
Example #2
0
def _path2doc(self, filename):
    # type: (str) -> str
    """Return the docname for the filename if the file is document.

    *filename* should be absolute or relative to the source directory.
    """
    if filename.startswith(self.srcdir):
        filename = relpath(filename, self.srcdir)
    for suffix in self.source_suffix:
        if filename.endswith(suffix):
            if sphinx.version_info[:3] >= (2, 3, 0):
                # This line was added in https://github.com/sphinx-doc/sphinx/commit/155f4b0d00e72d16eed47581f2fee75e41c452cf, starting in v2.3.0. It's a patch to fix https://github.com/sphinx-doc/sphinx/issues/6813.
                filename = path_stabilize(filename)
            return filename[:-len(suffix)]

    # The following code was added.
    if is_supported_language(filename):
        return filename

    # This was the existing code.
    # the file does not have docname
    return None
Example #3
0
 def to_domain(fpath):
     docname, _ = path.splitext(path_stabilize(fpath))
     dom = find_catalog(docname, self.config.gettext_compact)
     return dom
Example #4
0
 def to_domain(fpath):
     docname, _ = path.splitext(path_stabilize(fpath))
     dom = find_catalog(docname, self.config.gettext_compact)
     return dom