diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-10-04 14:22:02 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-10-04 14:22:02 +0900 |
commit | 7b395f6b25ce1fa78480508a1de4be2510fd2189 (patch) | |
tree | 94874fe05433b3558d23b15172337058ad3ede91 /sphinx/application.py | |
parent | d8cb7aa4f668f1bf92458372568e1be110501eb8 (diff) | |
download | sphinx-git-7b395f6b25ce1fa78480508a1de4be2510fd2189.tar.gz |
docs: Fix an example for add_directive()
Diffstat (limited to 'sphinx/application.py')
-rw-r--r-- | sphinx/application.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sphinx/application.py b/sphinx/application.py index f91027bf7..d06986764 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -611,14 +611,14 @@ class Sphinx: 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 @@ -631,7 +631,8 @@ class Sphinx: 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. |