Skip to content

Commit abeebe0

Browse files
committed
Improve documentation around generate_stats.
Added a line for the 1.4 release which will contain this new method. Revised the sphinx method references for generate_stats and process_response to actually link to each other. Following the existing format to link to process_response lead to a link being generated to Django's actual process_response method on the middleware. I had to specifically mention the toolbar's process_response and then updated the generate_stats reference to be consistent between the two methods.
1 parent 7d89994 commit abeebe0

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

debug_toolbar/panels/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ def process_view(self, request, view_func, view_args, view_kwargs):
168168
def process_response(self, request, response):
169169
"""
170170
Like process_response in Django's middleware. This is similar to
171-
:meth:`generate_stats`, but will be executed on every request. It
172-
should be used when either the logic needs to be executed on every
173-
request or it needs to change the response entirely, such as
174-
:class:`RedirectsPanel`.
171+
:meth:`generate_stats <debug_toolbar.panels.Panel.generate_stats>`,
172+
but will be executed on every request. It should be used when either
173+
the logic needs to be executed on every request or it needs to change
174+
the response entirely, such as :class:`RedirectsPanel`.
175175
176176
Write panel logic related to the response there. Post-process data
177177
gathered while the view executed. Save data with :meth:`record_stats`.
@@ -181,9 +181,10 @@ def process_response(self, request, response):
181181

182182
def generate_stats(self, request, response):
183183
"""
184-
Similar to :meth:`process_response`, but may not be executed on every
185-
request. This will only be called if the toolbar will be inserted into
186-
the request.
184+
Similar to :meth:`process_response
185+
<debug_toolbar.panels.Panel.process_response>`,
186+
but may not be executed on every request. This will only be called if
187+
the toolbar will be inserted into the request.
187188
188189
Write panel logic related to the response there. Post-process data
189190
gathered while the view executed. Save data with :meth:`record_stats`.

debug_toolbar/panels/profiling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Occasionally the disable method on the profiler is listed before
1414
# the actual view functions. This function call should be ignored as
1515
# it leads to an error within the tests.
16-
INVALID_PROFILER_FUNC = "<method 'disable' of '_lsprof.Profiler' objects>"
16+
INVALID_PROFILER_FUNC = '_lsprof.Profiler'
1717

1818

1919
class DjangoDebugToolbarStats(Stats):

docs/changes.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
Change log
22
==========
33

4+
1.4
5+
---
6+
7+
New features
8+
~~~~~~~~~~~~
9+
10+
* New panel method :meth:`debug_toolbar.panels.Panel.generate_stats` allows panels
11+
to only record stats when the toolbar is going to be inserted into the
12+
response.
13+
14+
Bugfixes
15+
~~~~~~~~
16+
17+
* Response time for requests of projects with numerous media files has
18+
been improved.
19+
420
1.3
521
---
622

docs/panels.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ CSS API at this time.
315315

316316
.. automethod:: debug_toolbar.panels.Panel.process_response
317317

318+
.. automethod:: debug_toolbar.panels.Panel.generate_stats
319+
318320
.. _javascript-api:
319321

320322
JavaScript API

0 commit comments

Comments
 (0)