예제 #1
0
    def read_doc(self, docname, app=None):
        # type: (unicode, Sphinx) -> None
        """Parse a file and add/update inventory entries for the doctree."""
        self.prepare_settings(docname)

        docutilsconf = path.join(self.srcdir, 'docutils.conf')
        # read docutils.conf from source dir, not from current dir
        OptionParser.standard_config_files[1] = docutilsconf
        if path.isfile(docutilsconf):
            self.note_dependency(docutilsconf)

        with sphinx_domains(self), rst.default_role(docname,
                                                    self.config.default_role):
            doctree = read_doc(self.app, self, self.doc2path(docname))

        # post-processing
        for domain in itervalues(self.domains):
            domain.process_doc(self, docname, doctree)

        # allow extension-specific post-processing
        if app:
            app.emit('doctree-read', doctree)

        # store time of reading, for outdated files detection
        # (Some filesystems have coarse timestamp resolution;
        # therefore time.time() can be older than filesystem's timestamp.
        # For example, FAT32 has 2sec timestamp resolution.)
        self.all_docs[docname] = max(time.time(),
                                     path.getmtime(self.doc2path(docname)))

        if self.versioning_condition:
            # add uids for versioning
            versioning.prepare(doctree)

        # cleanup
        self.temp_data.clear()
        self.ref_context.clear()

        self.write_doctree(docname, doctree)
예제 #2
0
파일: __init__.py 프로젝트: AWhetter/sphinx
    def read_doc(self, docname, app=None):
        # type: (unicode, Sphinx) -> None
        """Parse a file and add/update inventory entries for the doctree."""
        self.prepare_settings(docname)

        docutilsconf = path.join(self.srcdir, 'docutils.conf')
        # read docutils.conf from source dir, not from current dir
        OptionParser.standard_config_files[1] = docutilsconf
        if path.isfile(docutilsconf):
            self.note_dependency(docutilsconf)

        with sphinx_domains(self), rst.default_role(docname, self.config.default_role):
            doctree = read_doc(self.app, self, self.doc2path(docname))

        # post-processing
        for domain in itervalues(self.domains):
            domain.process_doc(self, docname, doctree)

        # allow extension-specific post-processing
        if app:
            app.emit('doctree-read', doctree)

        # store time of reading, for outdated files detection
        # (Some filesystems have coarse timestamp resolution;
        # therefore time.time() can be older than filesystem's timestamp.
        # For example, FAT32 has 2sec timestamp resolution.)
        self.all_docs[docname] = max(
            time.time(), path.getmtime(self.doc2path(docname)))

        if self.versioning_condition:
            # add uids for versioning
            versioning.prepare(doctree)

        # cleanup
        self.temp_data.clear()
        self.ref_context.clear()

        self.write_doctree(docname, doctree)