From ae00f6d149c353e1ecb683ccbf01be221324a646 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 7 Aug 2011 14:15:33 +0200 Subject: [PATCH] Tweaked autodoc to skip :internal: methods. --- docs/conf.py | 4 +++- docs/flaskdocext.py | 16 ++++++++++++++++ flask/app.py | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 docs/flaskdocext.py diff --git a/docs/conf.py b/docs/conf.py index 390361a6..16d7e670 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,6 +17,7 @@ import sys, os # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.append(os.path.abspath('_themes')) +sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- @@ -25,7 +26,8 @@ sys.path.append(os.path.abspath('_themes')) # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx'] +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', + 'flaskdocext'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/docs/flaskdocext.py b/docs/flaskdocext.py new file mode 100644 index 00000000..db4cfd20 --- /dev/null +++ b/docs/flaskdocext.py @@ -0,0 +1,16 @@ +import re +import inspect + + +_internal_mark_re = re.compile(r'^\s*:internal:\s*$(?m)') + + +def skip_member(app, what, name, obj, skip, options): + docstring = inspect.getdoc(obj) + if skip: + return True + return _internal_mark_re.search(docstring or '') is not None + + +def setup(app): + app.connect('autodoc-skip-member', skip_member) diff --git a/flask/app.py b/flask/app.py index d299b4fb..8995c511 100644 --- a/flask/app.py +++ b/flask/app.py @@ -257,7 +257,7 @@ class Flask(_PackageBoundObject): #: to load a config from files. self.config = Config(self.root_path, self.default_config) - #: Prepare the deferred setup of the logger. + # Prepare the deferred setup of the logger. self._logger = None self.logger_name = self.import_name @@ -1181,7 +1181,7 @@ class Flask(_PackageBoundObject): the :attr:`before_first_request_funcs` and only exactly once per application instance (which means process usually). - .. versionadded:: 0.8 + :internal: """ if self._got_first_request: return