mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4588 from tk0miya/4564_rst_prolog_not_working
io: Choose FileInput using ``supported`` attribute (refs: #4564)
This commit is contained in:
commit
b53c69a4e0
@ -208,7 +208,7 @@ class SphinxBaseFileInput(FileInput):
|
||||
|
||||
class SphinxFileInput(SphinxBaseFileInput):
|
||||
"""A basic FileInput for Sphinx."""
|
||||
pass
|
||||
supported = ('*',) # special source input
|
||||
|
||||
|
||||
class SphinxRSTFileInput(SphinxBaseFileInput):
|
||||
@ -225,6 +225,7 @@ class SphinxRSTFileInput(SphinxBaseFileInput):
|
||||
For that reason, ``sphinx.parsers.RSTParser`` should be used with this to parse
|
||||
a content correctly.
|
||||
"""
|
||||
supported = ('restructuredtext',)
|
||||
|
||||
def prepend_prolog(self, text, prolog):
|
||||
# type: (StringList, unicode) -> None
|
||||
@ -295,8 +296,9 @@ def read_doc(app, env, filename):
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.registry.add_source_input('*', SphinxFileInput)
|
||||
app.registry.add_source_input('restructuredtext', SphinxRSTFileInput)
|
||||
# type: (Sphinx) -> Dict[unicode, Any]
|
||||
app.registry.add_source_input(SphinxFileInput)
|
||||
app.registry.add_source_input(SphinxRSTFileInput)
|
||||
|
||||
return {
|
||||
'version': 'builtin',
|
||||
|
@ -232,11 +232,13 @@ class SphinxComponentRegistry(object):
|
||||
parser.set_application(app)
|
||||
return parser
|
||||
|
||||
def add_source_input(self, filetype, input_class):
|
||||
# type: (unicode, Type[Input]) -> None
|
||||
if filetype in self.source_inputs:
|
||||
raise ExtensionError(__('source_input for %r is already registered') % filetype)
|
||||
self.source_inputs[filetype] = input_class
|
||||
def add_source_input(self, input_class):
|
||||
# type: (Type[Input]) -> None
|
||||
for filetype in input_class.supported:
|
||||
if filetype in self.source_inputs:
|
||||
raise ExtensionError(__('source_input for %r is already registered') %
|
||||
filetype)
|
||||
self.source_inputs[filetype] = input_class
|
||||
|
||||
def get_source_input(self, filename):
|
||||
# type: (unicode) -> Type[Input]
|
||||
|
Loading…
Reference in New Issue
Block a user