Skip to content

Commit

Permalink
Merge pull request #222 from Erotemic/dev/default-profile
Browse files Browse the repository at this point in the history
FEAT: Explicit top-level `profile` decorator.
  • Loading branch information
Erotemic authored Aug 10, 2023
2 parents 6d141fc + b0a9df4 commit fdd69e1
Show file tree
Hide file tree
Showing 17 changed files with 801 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes
* FIX: ``show_text`` now increases column sizes or switches to scientific notation to maintain alignment
* ENH: ``show_text`` now has new options: sort and summarize
* ENH: Added new CLI arguments ``-srm`` to ``line_profiler`` to control sorting, rich printing, and summary printing.
* ENH: New global ``profile`` function that can be enabled by ``--profile`` or ``LINE_PROFILE=1``.

4.0.3
~~~~
Expand Down
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def visit_Assign(self, node):
'xdoctest': ('https://xdoctest.readthedocs.io/en/latest/', None),
'networkx': ('https://networkx.org/documentation/stable/', None),
'scriptconfig': ('https://scriptconfig.readthedocs.io/en/latest/', None),
'xdev': ('https://xdev.readthedocs.io/en/latest/', None),

}
__dev_note__ = """
Expand Down
15 changes: 4 additions & 11 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
.. The large version wont work because github strips rst image rescaling. https://i.imgur.com/AcWVroL.png
# TODO: Add a logo
.. image:: https://i.imgur.com/PoYIsWE.png
:height: 100px
:align: left
Welcome to line_profiler's documentation!
=========================================

.. The __init__ files contains the top-level documentation overview
.. automodule:: line_profiler.__init__
:show-inheritance:

.. toctree::
:maxdepth: 5
:maxdepth: 8
:caption: Package Layout

line_profiler
kernprof


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`modindex`
10 changes: 10 additions & 0 deletions docs/source/kernprof.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. .. manually created (not sure how to get automodule to do it)
kernprof module
===============

.. automodule:: kernprof
:members:
:undoc-members:
:show-inheritance:
:private-members:
8 changes: 8 additions & 0 deletions docs/source/line_profiler.__main__.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
line\_profiler.\_\_main\_\_ module
==================================

.. automodule:: line_profiler.__main__
:members:
:undoc-members:
:show-inheritance:
:private-members:
8 changes: 8 additions & 0 deletions docs/source/line_profiler._line_profiler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
line\_profiler.\_line\_profiler module
======================================

.. automodule:: line_profiler._line_profiler
:members:
:undoc-members:
:show-inheritance:
:private-members:
8 changes: 8 additions & 0 deletions docs/source/line_profiler.explicit_profiler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
line\_profiler.explicit\_profiler module
========================================

.. automodule:: line_profiler.explicit_profiler
:members:
:undoc-members:
:show-inheritance:
:private-members:
8 changes: 8 additions & 0 deletions docs/source/line_profiler.ipython_extension.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
line\_profiler.ipython\_extension module
========================================

.. automodule:: line_profiler.ipython_extension
:members:
:undoc-members:
:show-inheritance:
:private-members:
8 changes: 8 additions & 0 deletions docs/source/line_profiler.line_profiler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
line\_profiler.line\_profiler module
====================================

.. automodule:: line_profiler.line_profiler
:members:
:undoc-members:
:show-inheritance:
:private-members:
23 changes: 23 additions & 0 deletions docs/source/line_profiler.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
line\_profiler package
======================

Submodules
----------

.. toctree::
:maxdepth: 4

line_profiler.__main__
line_profiler._line_profiler
line_profiler.explicit_profiler
line_profiler.ipython_extension
line_profiler.line_profiler

Module contents
---------------

.. automodule:: line_profiler
:members:
:undoc-members:
:show-inheritance:
:private-members:
7 changes: 7 additions & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
line_profiler
=============

.. toctree::
:maxdepth: 4

line_profiler
2 changes: 2 additions & 0 deletions kernprof.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ def positive_float(value):
import line_profiler
prof = line_profiler.LineProfiler()
options.builtin = True
# Overwrite the explicit profile decorator
line_profiler.profile._kernprof_overwrite(prof)
else:
prof = ContextualProfile()
if options.builtin:
Expand Down
28 changes: 26 additions & 2 deletions line_profiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
"""
The line_profiler modula for doing line-by-line profiling of functions
Line Profiler
=============
The line_profiler module for doing line-by-line profiling of functions
+---------------+-------------------------------------------+
| Github | https://github.com/pyutils/line_profiler |
+---------------+-------------------------------------------+
| Pypi | https://pypi.org/project/line_profiler |
+---------------+-------------------------------------------+
Installation
============
Releases of ``line_profiler`` can be installed using pip
.. code:: bash
pip install line_profiler
"""
__submodules__ = [
'line_profiler',
Expand All @@ -21,6 +41,10 @@
load_ipython_extension, load_stats, main,
show_func, show_text,)


from .explicit_profiler import profile


__all__ = ['LineProfiler', 'line_profiler',
'load_ipython_extension', 'load_stats', 'main', 'show_func',
'show_text', '__version__']
'show_text', '__version__', 'profile']
Loading

0 comments on commit fdd69e1

Please sign in to comment.