From 0ff514743f2b90d05fb1fb1959c7eab4bdee2664 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 30 Jun 2019 01:41:15 +0900 Subject: [PATCH] Close #6475: Add override argument to app.add_autodocumenter() --- CHANGES | 1 + sphinx/application.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index ca2ae34fc..2421314e0 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,7 @@ Features added :confval:`html_extra_path` directories are inside output directory * #6514: html: Add a label to search input for accessability purposes * #5602: apidoc: Add ``--templatedir`` option +* #6475: Add ``override`` argument to ``app.add_autodocumenter()`` Bugs fixed ---------- diff --git a/sphinx/application.py b/sphinx/application.py index 96471be0c..a841f52b1 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -1054,8 +1054,8 @@ class Sphinx: else: lexer_classes[alias] = lexer - def add_autodocumenter(self, cls): - # type: (Any) -> None + def add_autodocumenter(self, cls, override=False): + # type: (Any, bool) -> None """Register a new documenter class for the autodoc extension. Add *cls* as a new documenter class for the :mod:`sphinx.ext.autodoc` @@ -1067,11 +1067,13 @@ class Sphinx: .. todo:: Add real docs for Documenter and subclassing .. versionadded:: 0.6 + .. versionchanged:: 2.2 + Add *override* keyword. """ logger.debug('[app] adding autodocumenter: %r', cls) from sphinx.ext.autodoc.directive import AutodocDirective self.registry.add_documenter(cls.objtype, cls) - self.add_directive('auto' + cls.objtype, AutodocDirective) + self.add_directive('auto' + cls.objtype, AutodocDirective, override=override) def add_autodoc_attrgetter(self, typ, getter): # type: (Type, Callable[[Any, str, Any], Any]) -> None