Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshse7en committed May 23, 2020
1 parent 9636d9d commit 2dac1e7
Show file tree
Hide file tree
Showing 72 changed files with 4,835 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/Changelog.rst
@@ -0,0 +1,4 @@
Change log
==========

.. include:: ../CHANGELOG.txt
20 changes: 20 additions & 0 deletions docs/Makefile
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = IMDbPY
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Empty file added docs/_static/.gitkeep
Empty file.
161 changes: 161 additions & 0 deletions docs/conf.py
@@ -0,0 +1,161 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'IMDbPY'
copyright = '2018, Davide Alberani, H. Turgut Uyar'
author = 'Davide Alberani, H. Turgut Uyar'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '6.8'


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# A list of ignored prefixes for module index sorting.
modindex_common_prefix = ['imdb.']

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'IMDbPYdoc'


# -- Options for LaTeX output ------------------------------------------------

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

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

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

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

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'IMDbPY.tex', 'IMDbPY Documentation',
'Davide Alberani, H. Turgut Uyar', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'imdbpy', 'IMDbPY Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'IMDbPY', 'IMDbPY Documentation',
author, 'IMDbPY', 'One line description of project.',
'Miscellaneous'),
]


# -- Extension configuration -------------------------------------------------
10 changes: 10 additions & 0 deletions docs/credits.rst
@@ -0,0 +1,10 @@
Contributors
============

.. include:: ../CONTRIBUTORS.txt

.. raw:: html

<h2>Credits</h2>

.. include:: ../CREDITS.txt
172 changes: 172 additions & 0 deletions docs/devel/extend.rst
@@ -0,0 +1,172 @@
How to extend
-------------

To introduce a new data access system, you have to write a new package
inside the "parser" package; this new package must provide a subclass
of the imdb.IMDb class which must define at least the following methods:

``_search_movie(title)``
To search for a given title; must return a list of (movieID, {movieData})
tuples.

``_search_episode(title)``
To search for a given episode title; must return a list of
(movieID, {movieData}) tuples.

``_search_person(name)``
To search for a given name; must return a list of (movieID, {personData})
tuples.

``_search_character(name)``
To search for a given character's name; must return a list of
(characterID, {characterData}) tuples.

``_search_company(name)``
To search for a given company's name; must return a list of
(companyID, {companyData}) tuples.

``get_movie_*(movieID)``
A set of methods, one for every set of information defined for a Movie
object; should return a dictionary with the relative information.

This dictionary can contain some optional keys:

- 'data': must be a dictionary with the movie info
- 'titlesRefs': a dictionary of 'movie title': movieObj pairs
- 'namesRefs': a dictionary of 'person name': personObj pairs

``get_person_*(personID)``
A set of methods, one for every set of information defined for a Person
object; should return a dictionary with the relative information.

``get_character_*(characterID)``
A set of methods, one for every set of information defined for a Character
object; should return a dictionary with the relative information.

``get_company_*(companyID)``
A set of methods, one for every set of information defined for a Company
object; should return a dictionary with the relative information.

``_get_top_bottom_movies(kind)``
Kind can be one of 'top' and 'bottom'; returns the related list of movies.

``_get_keyword(keyword)``
Return a list of Movie objects with the given keyword.

``_search_keyword(key)``
Return a list of keywords similar to the given key.

``get_imdbMovieID(movieID)``
Convert the given movieID to a string representing the imdbID, as used
by the IMDb web server (e.g.: '0094226' for Brian De Palma's
"The Untouchables").

``get_imdbPersonID(personID)``
Convert the given personID to a string representing the imdbID, as used
by the IMDb web server (e.g.: '0000154' for "Mel Gibson").

``get_imdbCharacterID(characterID)``
Convert the given characterID to a string representing the imdbID, as used
by the IMDb web server (e.g.: '0000001' for "Jesse James").

``get_imdbCompanyID(companyID)``
Convert the given companyID to a string representing the imdbID, as used
by the IMDb web server (e.g.: '0071509' for "Columbia Pictures [us]").

``_normalize_movieID(movieID)``
Convert the provided movieID in a format suitable for internal use
(e.g.: convert a string to a long int).

NOTE: As a rule of thumb you *always* need to provide a way to convert
a "string representation of the movieID" into the internally used format,
and the internally used format should *always* be converted to a string,
in a way or another. Rationale: A movieID can be passed from the command
line, or from a web browser.

``_normalize_personID(personID)``
idem

``_normalize_characterID(characterID)``
idem

``_normalize_companyID(companyID)``
idem

``_get_real_movieID(movieID)``
Return the true movieID; useful to handle title aliases.

``_get_real_personID(personID)``
idem

``_get_real_characterID(characterID)``
idem

``_get_real_companyID(companyID)``
idem

The class should raise the appropriate exceptions, when needed:

- ``IMDbDataAccessError`` must be raised when you cannot access the resource
you need to retrieve movie info or you're unable to do a query (this is
*not* the case when a query returns zero matches: in this situation an
empty list must be returned).

- ``IMDbParserError`` should be raised when an error occurred parsing
some data.

Now you've to modify the ``imdb.IMDb`` function so that, when the right
data access system is selected with the "accessSystem" parameter, an instance
of your newly created class is returned.

For example, if you want to call your new data access system "mysql"
(meaning that the data are stored in a mysql database), you have to add
to the imdb.IMDb function something like:

.. code-block:: python
if accessSystem == 'mysql':
from parser.mysql import IMDbMysqlAccessSystem
return IMDbMysqlAccessSystem(*arguments, **keywords)
where "parser.mysql" is the package you've created to access the local
installation, and "IMDbMysqlAccessSystem" is the subclass of imdb.IMDbBase.

Then it's possible to use the new data access system like:

.. code-block:: python
from imdb import IMDb
i = IMDb(accessSystem='mysql')
results = i.search_movie('the matrix')
print(results)
.. note::

This is a somewhat misleading example: we already have a data access system
for SQL database (it's called 'sql' and it supports MySQL, amongst others).
Maybe I'll find a better example...

A specific data access system implementation can define its own methods.
As an example, the IMDbHTTPAccessSystem that is in the parser.http package
defines the method ``set_proxy()`` to manage the use a web proxy; you can use
it this way:

.. code-block:: python
from imdb import IMDb
i = IMDb(accessSystem='http') # the 'accessSystem' argument is not
# really needed, since "http" is the default.
i.set_proxy('http://localhost:8080/')
A list of special methods provided by the imdb.IMDbBase subclass, along with
their description, is always available calling the ``get_special_methods()``
of the IMDb class:

.. code-block:: python
i = IMDb(accessSystem='http')
print(i.get_special_methods())
will print a dictionary with the format::

{'method_name': 'method_description', ...}

0 comments on commit 2dac1e7

Please sign in to comment.