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