diff options
Diffstat (limited to 'sphinx/directives/patches.py')
-rw-r--r-- | sphinx/directives/patches.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py new file mode 100644 index 000000000..7e00bc81c --- /dev/null +++ b/sphinx/directives/patches.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +""" + sphinx.directives.patches + ~~~~~~~~~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from docutils import nodes +from docutils.parsers.rst import directives +from docutils.parsers.rst.directives import images + + +class Figure(images.Figure): + """The figure directive which applies `:name:` option to the figure node + instead of the image node. + """ + + def run(self): + name = self.options.pop('name', None) + (figure_node,) = images.Figure.run(self) + if isinstance(figure_node, nodes.system_message): + return [figure_node] + + if name: + self.options['name'] = name + self.add_name(figure_node) + + return [figure_node] + + +directives.register_directive('figure', Figure) |