Commits

Roman Podoliaka committed 08cac93

httpdomain: add the ``undoc-blueprints`` option to the Flask ``autohttp`` module

This options allows one to prevent whole Flask blueprints from being documented.

  • Participants
  • Parent commits 8c81d06

Comments (0)

Files changed (2)

File httpdomain/doc/index.rst

 
          .. _undoc-members: http://sphinx.pocoo.org/ext/autodoc.html#directive-automodule
 
+   ``undoc-blueprints``
+      Excludes specified blueprints from generated references.
+
    ``undoc-static``
       Excludes a view function that serves static files, which is included
       in Flask by default.

File httpdomain/sphinxcontrib/autohttp/flask.py

     required_arguments = 1
     option_spec = {'endpoints': str,
                    'undoc-endpoints': str,
+                   'undoc-blueprints': str,
                    'undoc-static': str,
                    'include-empty-docstring': str}
 
             return frozenset()
         return frozenset(endpoints)
 
+    @property
+    def undoc_blueprints(self):
+        try:
+            blueprints = re.split(r'\s*,\s*', self.options['undoc-blueprints'])
+        except KeyError:
+            return frozenset()
+        return frozenset(blueprints)
+
     def make_rst(self):
         app = import_object(self.arguments[0])
         for method, path, endpoint in get_routes(app):
+            try:
+                blueprint, endpoint_internal = endpoint.split('.')
+                if blueprint in self.undoc_blueprints:
+                    continue
+            except ValueError:
+                pass  # endpoint is not within a blueprint
+
             if self.endpoints and endpoint not in self.endpoints:
                 continue
             if endpoint in self.undoc_endpoints: