@@ -51,18 +51,19 @@ def add_custom_nl2br_filters(self, app):
5151 @app .template_filter ()
5252 @evalcontextfilter
5353 def nl2br (eval_ctx , value ):
54- result = '\n \n ' .join ('%s' % p .replace ('\n ' , '<br>\n ' ) for p in _paragraph_re .split (value ))
54+ result = '\n \n ' .join ('%s' % p .replace ('\n ' , '<br>\n ' )
55+ for p in _paragraph_re .split (value ))
5556 return result
5657
5758 def doc (self , group = None , aa = None , groups = None ):
58- """Decorator to add flask route to autodoc for automatic documentation\
59+ """Add flask route to autodoc for automatic documentation
5960
60- Any route decorated with this method will be added to the list of routes to be documented by the generate() or
61- html() methods.
61+ Any route decorated with this method will be added to the list of
62+ routes to be documented by the generate() or html() methods.
6263
6364 By default, the route is added to the 'all' group.
64- By specifying group or groups argument, the route can be added to one or multiple other groups as well, besides
65- the 'all' group.
65+ By specifying group or groups argument, the route can be added to one
66+ or multiple other groups as well, besides the 'all' group.
6667 """
6768 def decorator (f ):
6869 if groups :
@@ -78,7 +79,8 @@ def decorator(f):
7879 return decorator
7980
8081 def generate (self , group = 'all' , groups = [], sort = None ):
81- """Returns a list of dict describing the routes specified by the doc() method
82+ """Return a list of dict describing the routes specified by the
83+ doc() method
8284
8385 Each dict contains:
8486 - methods: the set of allowed methods (ie ['GET', 'POST'])
@@ -88,7 +90,8 @@ def generate(self, group='all', groups=[], sort=None):
8890 - args: function arguments
8991 - defaults: defaults values for the arguments
9092
91- By specifying the group or groups arguments, only routes belonging to those groups will be returned.
93+ By specifying the group or groups arguments, only routes belonging to
94+ those groups will be returned.
9295
9396 Routes are sorted alphabetically based on the rule.
9497 """
@@ -101,8 +104,8 @@ def generate(self, group='all', groups=[], sort=None):
101104 func = current_app .view_functions [rule .endpoint ]
102105 arguments = rule .arguments if rule .arguments else ['None' ]
103106
104- if (groups and [True for g in groups if func in self .groups [g ]]) or \
105- (not groups and func in self .groups [group ]):
107+ if (groups and [True for g in groups if func in self .groups [g ]]) \
108+ or (not groups and func in self .groups [group ]):
106109 links .append (
107110 dict (
108111 methods = rule .methods ,
@@ -119,16 +122,20 @@ def generate(self, group='all', groups=[], sort=None):
119122 return sorted (links , key = itemgetter ('rule' ))
120123
121124 def html (self , template = None , group = 'all' , groups = None , ** context ):
122- """Returns an html string of the routes specified by the doc() method
125+ """Return an html string of the routes specified by the doc() method
123126
124- A template can be specified. A list of routes is available under the 'autodoc' value (refer to the documentation
125- for the generate() for a description of available values). If no template is specified, a default template is
126- used.
127+ A template can be specified. A list of routes is available under the
128+ 'autodoc' value (refer to the documentation for the generate() for a
129+ description of available values). If no template is specified, a
130+ default template is used.
127131
128- By specifying the group or groups arguments, only routes belonging to those groups will be returned.
132+ By specifying the group or groups arguments, only routes belonging to
133+ those groups will be returned.
129134 """
130135 if template :
131- return render_template (template , autodoc = self .generate (group ), ** context )
136+ return render_template (template ,
137+ autodoc = self .generate (group ),
138+ ** context )
132139 else :
133140 filename = os .path .join (
134141 os .path .dirname (__file__ ),
@@ -138,4 +145,7 @@ def html(self, template=None, group='all', groups=None, **context):
138145 with open (filename ) as file :
139146 content = file .read ()
140147 with current_app .app_context ():
141- return render_template_string (content , autodoc = self .generate (group = group , groups = groups ), ** context )
148+ return render_template_string (
149+ content ,
150+ autodoc = self .generate (group = group , groups = groups ),
151+ ** context )
0 commit comments