diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-10-06 00:49:17 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-06 00:49:17 +0900 |
commit | c82d1c76e1e3518381e51450f5b2bc83bc7cc647 (patch) | |
tree | 642da1724cc5bb4f283c0c99b25181f593d9f1e8 | |
parent | ca87e47b7dbdcf2991cf9c396db548ae668cac31 (diff) | |
parent | 7b395f6b25ce1fa78480508a1de4be2510fd2189 (diff) | |
download | sphinx-git-c82d1c76e1e3518381e51450f5b2bc83bc7cc647.tar.gz |
Merge pull request #8281 from tk0miya/8073_update_directive_example
docs: Fix an example for add_directive()
-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 4a3db25e7..59ac04b20 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -623,14 +623,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 @@ -643,7 +643,8 @@ class Sphinx: 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. |