updated docs/api/history/

This commit is contained in:
Hugo Wang 2016-12-17 00:06:03 +08:00
parent 23ec9ab316
commit a3027d020b
10 changed files with 48 additions and 13 deletions

View file

@ -1,10 +0,0 @@
.. _xonsh_history:
******************************************************
History (``xonsh.history``)
******************************************************
.. automodule:: xonsh.history
:members:
:undoc-members:
:inherited-members:

10
docs/api/history/base.rst Normal file
View file

@ -0,0 +1,10 @@
.. _xonsh_history_base:
===============================================
History Base Class -- :mod:`xonsh.history.base`
===============================================
.. currentmodule:: xonsh.history.base
.. automodule:: xonsh.history.base
:members:

10
docs/api/history/json.rst Normal file
View file

@ -0,0 +1,10 @@
.. _xonsh_history_json:
=================================================
History Backend JSON -- :mod:`xonsh.history.json`
=================================================
.. currentmodule:: xonsh.history.json
.. automodule:: xonsh.history.json
:members:

10
docs/api/history/main.rst Normal file
View file

@ -0,0 +1,10 @@
.. _xonsh_history_main:
======================================================
History Main Entry Points -- :mod:`xonsh.history.main`
======================================================
.. automodule:: xonsh.history.main
:members:
:undoc-members:
:inherited-members:

View file

@ -0,0 +1,10 @@
.. _xonsh_history_sqlite:
=====================================================
History Backend Sqlite -- :mod:`xonsh.history.sqlite`
=====================================================
.. currentmodule:: xonsh.history.sqlite
.. automodule:: xonsh.history.sqlite
:members:

View file

@ -473,7 +473,8 @@ xonsh when xonsh get launched. In this case, sqlite history backend should
work better. work better.
To use sqlite history backend, set ``$XONSH_HISTORY_BACKEND = 'sqlite'`` in To use sqlite history backend, set ``$XONSH_HISTORY_BACKEND = 'sqlite'`` in
your ``~/.xonshrc`` file. your ``~/.xonshrc`` file. To switch back to JSON version, remove this line,
or set it to `'json'`.
.. tip:: If you have `sqlite-web <https://pypi.python.org/pypi/sqlite-web>`_ .. tip:: If you have `sqlite-web <https://pypi.python.org/pypi/sqlite-web>`_
installed, you can read the history easily with command: installed, you can read the history easily with command:

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Implements the xonsh history object.""" """Implements JSON version of xonsh history backend."""
import os import os
import time import time
import builtins import builtins

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Implements the xonsh history object.""" """Main entry points of the xonsh history."""
import argparse import argparse
import builtins import builtins
import datetime import datetime
@ -23,6 +23,7 @@ HISTORY_BACKENDS = {
def construct_history(**kwargs): def construct_history(**kwargs):
"""Construct the history backend object."""
env = builtins.__xonsh_env__ env = builtins.__xonsh_env__
backend = env.get('XONSH_HISTORY_BACKEND') backend = env.get('XONSH_HISTORY_BACKEND')
if backend not in HISTORY_BACKENDS: if backend not in HISTORY_BACKENDS:

View file

@ -169,6 +169,8 @@ class SqliteHistoryGC(threading.Thread):
class SqliteHistory(History): class SqliteHistory(History):
"""Xonsh history backend implemented with sqlite3."""
def __init__(self, gc=True, filename=None, **kwargs): def __init__(self, gc=True, filename=None, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
if filename is None: if filename is None:

View file

@ -1698,5 +1698,6 @@ def ensure_timestamp(t, datetime_format=None):
def format_datetime(dt): def format_datetime(dt):
"""Format datetime object to string base on $XONSH_DATETIME_FORMAT Env."""
format_ = builtins.__xonsh_env__['XONSH_DATETIME_FORMAT'] format_ = builtins.__xonsh_env__['XONSH_DATETIME_FORMAT']
return dt.strftime(format_) return dt.strftime(format_)