Skip to content

Commit

Permalink
Merge pull request #8281 from tk0miya/8073_update_directive_example
Browse files Browse the repository at this point in the history
docs: Fix an example for add_directive()
  • Loading branch information
tk0miya committed Oct 5, 2020
2 parents ca87e47 + 7b395f6 commit c82d1c7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sphinx/application.py
Expand Up @@ -623,14 +623,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 @@ -643,7 +643,8 @@ class LiteralIncludeDirective(Directive):
def run(self):
...
add_directive('literalinclude', LiteralIncludeDirective)
def setup(app):
add_directive('my-directive', MyDirective)
If *override* is True, the given *cls* is forcedly installed even if
a directive named as *name* is already installed.
Expand Down

0 comments on commit c82d1c7

Please sign in to comment.