From f080956d4d684a33631b5029ba1b6a2f0b609f3f Mon Sep 17 00:00:00 2001 From: Martyn Gigg Date: Wed, 11 Jun 2014 13:05:45 +0100 Subject: [PATCH] Add skipping mechanism autodoc It currently just skips __init__ like the old one did Refs #9624 --- Code/Mantid/docs/source/conf.py | 3 ++- .../docs/sphinxext/mantiddoc/autodoc.py | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Code/Mantid/docs/sphinxext/mantiddoc/autodoc.py diff --git a/Code/Mantid/docs/source/conf.py b/Code/Mantid/docs/source/conf.py index cd2c935b2e96..4c727984a0df 100644 --- a/Code/Mantid/docs/source/conf.py +++ b/Code/Mantid/docs/source/conf.py @@ -23,7 +23,8 @@ 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.doctest', - 'mantiddoc.directives' + 'mantiddoc.directives', + 'mantiddoc.autodoc' ] #try: # bonus for doxygen links - TODO off for now diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/autodoc.py b/Code/Mantid/docs/sphinxext/mantiddoc/autodoc.py new file mode 100644 index 000000000000..15d7e33fa424 --- /dev/null +++ b/Code/Mantid/docs/sphinxext/mantiddoc/autodoc.py @@ -0,0 +1,24 @@ +""" +Mantid customizations for the behaviour of the Sphinx autodoc +extension +""" + +def skip(app, what, name, obj, skip, options): + """ + Arguments: + app: Sphinx application object + what: the type of the object which the docstring belongs to (one of "module", "class", "exception", "function", "method", "attribute") + name: the fully qualified name of the object + obj: the object itself + skip: a boolean indicating if autodoc will skip this member if the user handler does not override the decision + options: the options given to the directive: an object with attributes inherited_members, undoc_members, + show_inheritance and noindex that are true if the flag option of same name was given to the auto directive + """ + if name == "__init__": + return False + return skip + +def setup(app): + # Define which methods are skipped when running autodoc + # on a member + app.connect("autodoc-skip-member", skip) \ No newline at end of file