diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2015-12-31 19:31:59 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-01-17 13:18:02 +0300 |
commit | f1765c25763743edb027abe2ed504ef4f8a48775 (patch) | |
tree | 5714d4fd15397ab924f091f63f56e317914bdfdc /sphinx/parsers.py | |
parent | ed196a8adf650272f40b1f66e7ff57e317702f33 (diff) |
Add sphinx.parsers.Parser class; a base class for new parsers
The class inherits ``docutils.parsers.Parser`` and implements ``set_application()`` in addition.
It enables subclasses to read configurations, to access environments and to logging.
Diffstat (limited to 'sphinx/parsers.py')
-rw-r--r-- | sphinx/parsers.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sphinx/parsers.py b/sphinx/parsers.py new file mode 100644 index 000000000..b7ca89aa5 --- /dev/null +++ b/sphinx/parsers.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" + sphinx.parsers + ~~~~~~~~~~~~~~ + + A Base class for additional parsers. + + :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import docutils.parsers + + +class Parser(docutils.parsers.Parser): + """ + A base class of parsers. + """ + + def set_application(self, app): + """set_application will be called from Sphinx to set app and other instance variables + + :param sphinx.application.Sphinx app: Sphinx application object + """ + self.app = app + self.config = app.config + self.env = app.env + self.warn = app.warn + self.info = app.info |