##// END OF EJS Templates
Improve history API docs
Thomas Kluyver -
Show More
@@ -29,6 +29,7 b' import threading'
29 29 # Our own packages
30 30 from IPython.config.configurable import Configurable
31 31 from IPython.external.decorator import decorator
32 from IPython.utils.decorators import undoc
32 33 from IPython.utils.path import locate_profile
33 34 from IPython.utils import py3compat
34 35 from IPython.utils.traitlets import (
@@ -40,6 +41,7 b' from IPython.utils.warn import warn'
40 41 # Classes and functions
41 42 #-----------------------------------------------------------------------------
42 43
44 @undoc
43 45 class DummyDB(object):
44 46 """Dummy DB that will act as a black hole for history.
45 47
@@ -59,7 +61,7 b' class DummyDB(object):'
59 61
60 62 @decorator
61 63 def needs_sqlite(f, self, *a, **kw):
62 """return an empty list in the absence of sqlite"""
64 """Decorator: return an empty list in the absence of sqlite."""
63 65 if sqlite3 is None or not self.enabled:
64 66 return []
65 67 else:
@@ -69,6 +71,7 b' def needs_sqlite(f, self, *a, **kw):'
69 71 if sqlite3 is not None:
70 72 DatabaseError = sqlite3.DatabaseError
71 73 else:
74 @undoc
72 75 class DatabaseError(Exception):
73 76 "Dummy exception when sqlite could not be imported. Should never occur."
74 77
@@ -159,7 +162,7 b' class HistoryAccessor(Configurable):'
159 162 hist_file : str
160 163 Path to an SQLite history database stored by IPython. If specified,
161 164 hist_file overrides profile.
162 config :
165 config : :class:`~IPython.config.loader.Config`
163 166 Config object. hist_file can also be set through this.
164 167 """
165 168 # We need a pointer back to the shell for various tasks.
@@ -254,8 +257,8 b' class HistoryAccessor(Configurable):'
254 257
255 258 @needs_sqlite
256 259 @catch_corrupt_db
257 def get_session_info(self, session=0):
258 """get info about a session
260 def get_session_info(self, session):
261 """Get info about a session.
259 262
260 263 Parameters
261 264 ----------
@@ -383,6 +386,7 b' class HistoryAccessor(Configurable):'
383 386
384 387 Returns
385 388 -------
389 entries
386 390 An iterator over the desired lines. Each line is a 3-tuple, either
387 391 (session, line, input) if output is False, or
388 392 (session, line, (input, output)) if output is True.
@@ -545,14 +549,14 b' class HistoryManager(HistoryAccessor):'
545 549 # Methods for retrieving history
546 550 # ------------------------------
547 551 def get_session_info(self, session=0):
548 """get info about a session
552 """Get info about a session.
549 553
550 554 Parameters
551 555 ----------
552 556
553 557 session : int
554 558 Session number to retrieve. The current session is 0, and negative
555 numbers count back from current session, so -1 is previous session.
559 numbers count back from current session, so -1 is the previous session.
556 560
557 561 Returns
558 562 -------
@@ -616,6 +620,7 b' class HistoryManager(HistoryAccessor):'
616 620
617 621 Returns
618 622 -------
623 entries
619 624 An iterator over the desired lines. Each line is a 3-tuple, either
620 625 (session, line, input) if output is False, or
621 626 (session, line, (input, output)) if output is True.
@@ -632,7 +637,7 b' class HistoryManager(HistoryAccessor):'
632 637 ## ----------------------------
633 638 def store_inputs(self, line_num, source, source_raw=None):
634 639 """Store source and raw input in history and create input cache
635 variables _i*.
640 variables ``_i*``.
636 641
637 642 Parameters
638 643 ----------
@@ -803,7 +808,7 b' def extract_hist_ranges(ranges_str):'
803 808
804 809 Examples
805 810 --------
806 list(extract_input_ranges("~8/5-~7/4 2"))
811 >>> list(extract_input_ranges("~8/5-~7/4 2"))
807 812 [(-8, 5, None), (-7, 1, 4), (0, 2, 3)]
808 813 """
809 814 for range_str in ranges_str.split():
General Comments 0
You need to be logged in to leave comments. Login now