Skip to content

Commit

Permalink
Merge pull request #18 from thombashi/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
thombashi committed Apr 2, 2016
2 parents acc255e + 51303eb commit dd4616a
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 177 deletions.
77 changes: 66 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import pkg_resources
import sys

import sphinx_rtd_theme

Expand All @@ -34,8 +35,10 @@
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx',
]

intersphinx_mapping = {'python': ('http://docs.python.org/', None)}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -61,9 +64,9 @@
# built documents.
#
# The short X.Y version.
version = u'0.2.1'
version = pkg_resources.get_distribution("SimpleSQLite").version
# The full version, including alpha/beta/rc tags.
release = u'0.2.1'
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -211,17 +214,17 @@
# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
#'preamble': '',

# Latex figure (float) alignment
#'figure_align': 'htbp',
# Latex figure (float) alignment
#'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
Expand Down Expand Up @@ -288,3 +291,55 @@

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False


# ------------------------------------------------

rp_builtin = u"""
.. |False| replace:: :py:obj:`False`
.. |True| replace:: :py:obj:`True`
.. |None| replace:: :py:obj:`None`
.. |bool| replace:: :py:class:`bool`
.. |dict| replace:: :py:class:`dict`
.. |int| replace:: :py:class:`int`
.. |list| replace:: :py:class:`list`
.. |float| replace:: :py:class:`float`
.. |str| replace:: :py:class:`str`
.. |tuple| replace:: :py:obj:`tuple`
"""

rp_func = u"""
.. |namedtuple| replace:: :py:func:`~collections.namedtuple`
"""

rp_class = u"""
.. |Connection| replace:: :py:class:`sqlite3.Connection`
.. |datetime| replace:: :py:class:`datetime.datetime`
.. |timedelta| replace:: :py:class:`datetime.timedelta`
"""

rp_module = u"""
.. |sqlite3| replace:: :py:mod:`sqlite3`
"""

rp_raises = u"""
.. |raises_check_connection| replace::
If not connected to a SQLite database file.
.. |raises_verify_table_existence| replace::
If the table not found in the database.
.. |raises_operational_error| replace::
If failed to execute query.
.. |raises_validate_table_name| replace::
If the name is invalid for a SQLite table name.
.. |raises_write_permission| replace::
If the open |attr_mode| is neither ``"w"`` nor ``"a"``.
"""

rst_prolog = rp_builtin + rp_func + rp_class + rp_module + rp_raises + u"""
.. |attr_mode| replace:: :py:attr:`.mode`
"""
7 changes: 1 addition & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
Welcome to SimpleSQLite's documentation!
========================================

GitHub repository
=================

https://github.com/thombashi/SimpleSQLite


.. toctree::
:caption: Table of Contents
:maxdepth: 3
Expand All @@ -22,6 +16,7 @@ https://github.com/thombashi/SimpleSQLite
pages/examples/index
pages/reference/index
pages/genindex
pages/links


Indices and tables
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/examples/create_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Create a table from data matrix

:py:meth:`~simplesqlite.core.SimpleSQLite.create_table_with_data`
method can get create a table from data matrix.
Data matrix is a list of ``dictionary``/``namedtuple``/``list``/``tuple``.
Data matrix is a list of |dict|/|namedtuple|/|list|/|tuple|.

.. include:: create_table_from_data_matrix.rst

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/examples/insert_record.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Insert records into a table

:py:meth:`~simplesqlite.core.SimpleSQLite.insert`/:py:meth:`~simplesqlite.core.SimpleSQLite.insert_many`
method can insert record(s) into a table.
Record is one of the ``dictionary``/``namedtuple``/``list``/``tuple``.
Record is one of the |dict|/|namedtuple|/|list|/|tuple|.

.. include:: insert_record_example.rst
9 changes: 9 additions & 0 deletions docs/pages/links.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Links
=====

- pip: tool for installing python packages
- https://pip.pypa.io/en/stable/
- GitHub repository
- https://github.com/thombashi/SimpleSQLite
- PyPI
- https://pypi.python.org/pypi/SimpleSQLite
17 changes: 13 additions & 4 deletions simplesqlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def validate_table_name(name):
"""
:param str name: Table name to validate.
:raises ValueError: If ``name`` is invalid for a table name.
:raises ValueError: |raises_validate_table_name|
"""

if dataproperty.is_empty_string(name):
Expand All @@ -32,13 +32,14 @@ def append_table(con_src, con_dst, table_name):
:param SimpleSQLite con_src: Source of the database.
:param SimpleSQLite con_dst: Destination of the database.
:param str table_name: Table name to copy.
:return: ``True`` if success.
:return: |True| if success.
:rtype: bool
:raises simplesqlite.TableNotFoundError:
|raises_verify_table_existence|
:raises ValueError: If attribute of the table is different from each other.
.. seealso::
:py:meth:`simplesqlite.core.SimpleSQLite.verify_table_existence`
:py:meth:`simplesqlite.core.SimpleSQLite.create_table_with_data`
"""

Expand Down Expand Up @@ -70,7 +71,7 @@ def append_table(con_src, con_dst, table_name):

def connect_sqlite_db_mem():
"""
:return: Instance of a in memory database
:return: Instance of a in memory database.
:rtype: SimpleSQLite
:Examples:
Expand All @@ -97,8 +98,16 @@ class NullDatabaseConnectionError(Exception):


class TableNotFoundError(Exception):
"""
Raised when accessed the table that not exists in the database.
"""

pass


class AttributeNotFoundError(Exception):
"""
Raised when accessed the attribute that not exists in the table.
"""

pass

0 comments on commit dd4616a

Please sign in to comment.