Skip to content

Commit

Permalink
docs: Fix an example for add_directive()
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Oct 4, 2020
1 parent d8cb7aa commit 7b395f6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sphinx/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,14 @@ class which inherits ``docutils.parsers.rst.Directive``. For more
details, see `the Docutils docs
<http://docutils.sourceforge.net/docs/howto/rst-directives.html>`_ .
For example, the (already existing) :rst:dir:`literalinclude` directive
would be added like this:
For example, a custom directive named ``my-directive`` would be added
like this:
.. code-block:: python
from docutils.parsers.rst import Directive, directives
class LiteralIncludeDirective(Directive):
class MyDirective(Directive):
has_content = True
required_arguments = 1
optional_arguments = 0
Expand All @@ -631,7 +631,8 @@ class LiteralIncludeDirective(Directive):
def run(self):
...
add_directive('literalinclude', LiteralIncludeDirective)
def setup(app):
add_directive('my-directive', MyDirective)
.. versionchanged:: 0.6
Docutils 0.5-style directive classes are now supported.
Expand Down

0 comments on commit 7b395f6

Please sign in to comment.