diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-11-15 11:02:36 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-12-12 18:24:52 +0900 |
commit | a0200ad4995967fc28f0e6ac70d0f15779d0e8bb (patch) | |
tree | ac36d9b5e020dbeacd249e8a53fba67ccb846bad /sphinx/io.py | |
parent | a12399dbe429f552ab012099491c577de668a81d (diff) | |
download | sphinx-git-a0200ad4995967fc28f0e6ac70d0f15779d0e8bb.tar.gz |
Refactor sphinx.io; dependent parser detection from SphinxFileInput
Diffstat (limited to 'sphinx/io.py')
-rw-r--r-- | sphinx/io.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/sphinx/io.py b/sphinx/io.py index 47e701f35..71701e10d 100644 --- a/sphinx/io.py +++ b/sphinx/io.py @@ -140,22 +140,15 @@ class SphinxFileInput(FileInput): def read(self): # type: () -> unicode - def get_parser_type(source_path): - # type: (unicode) -> Tuple[unicode] - for suffix, parser_class in iteritems(self.app.registry.get_source_parsers()): - if source_path.endswith(suffix): - if isinstance(parser_class, string_types): - parser_class = import_object(parser_class, 'source parser') # type: ignore # NOQA - return parser_class.supported - return ('restructuredtext',) - data = FileInput.read(self) if self.app: arg = [data] self.app.emit('source-read', self.env.docname, arg) data = arg[0] + + parser = self.app.registry.get_source_parser(self.source_path) docinfo, data = split_docinfo(data) - if 'restructuredtext' in get_parser_type(self.source_path): + if 'restructuredtext' in parser.supported: if self.env.config.rst_epilog: data = data + '\n' + self.env.config.rst_epilog + '\n' if self.env.config.rst_prolog: |