DOC Shows kwargs in API signature
@@ -460,8 +460,30 @@ def generate_min_dependency_substitutions(app):
# we use the issues path for PRs since the issues URL will forward
issues_github_path = 'scikit-learn/scikit-learn'
+# Hack to get kwargs to appear in docstring #18434
+# TODO: Remove when https://github.com/sphinx-doc/sphinx/pull/8234 gets
+# merged
+from sphinx.util import inspect # noqa
+from sphinx.ext.autodoc import ClassDocumenter # noqa
+
+
+class PatchedClassDocumenter(ClassDocumenter):
+
+ def _get_signature(self):
+ old_signature = inspect.signature
+
+ def patch_signature(subject, bound_method=False, follow_wrapped=True):
+ # changes the default of follow_wrapped to True
+ return old_signature(subject, bound_method=bound_method,
+ follow_wrapped=follow_wrapped)
+ inspect.signature = patch_signature
+ result = super()._get_signature()
+ inspect.signature = old_signature
+ return result
+
def setup(app):
+ app.registry.documenters['class'] = PatchedClassDocumenter
app.connect('builder-inited', generate_min_dependency_table)
app.connect('builder-inited', generate_min_dependency_substitutions)
# to hide/show the prompt in code examples:
