Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-10-05 18:49:17 +0300
committerGitHub <noreply@github.com>2020-10-05 18:49:17 +0300
commitc82d1c76e1e3518381e51450f5b2bc83bc7cc647 (patch)
tree642da1724cc5bb4f283c0c99b25181f593d9f1e8 /sphinx/application.py
parentca87e47b7dbdcf2991cf9c396db548ae668cac31 (diff)
parent7b395f6b25ce1fa78480508a1de4be2510fd2189 (diff)
Merge pull request #8281 from tk0miya/8073_update_directive_example
docs: Fix an example for add_directive()
Diffstat (limited to 'sphinx/application.py')
-rw-r--r--sphinx/application.py9
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.