diff --git a/docs/source/conf.py b/docs/source/conf.py index c5efba2..d7d83eb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,9 +18,10 @@ # import os import sys -sys.path.insert(0, os.path.abspath('.')) -ON_RTD = os.environ.get('READTHEDOCS', None) == 'True' +sys.path.insert(0, os.path.abspath(".")) + +ON_RTD = os.environ.get("READTHEDOCS", None) == "True" # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. @@ -30,47 +31,56 @@ # 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', - 'sphinx.ext.doctest', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode', - 'sphinx.ext.githubpages', - 'nbsphinx'] - -exclude_patterns = ['_build', 'source/.ipynb_checkpoints/*'] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.mathjax", + "sphinx.ext.ifconfig", + "sphinx.ext.viewcode", + "sphinx.ext.githubpages", + "nbsphinx", +] + +exclude_patterns = ["_build", "source/.ipynb_checkpoints/*"] numpydoc_class_members_toctree = False -#nbsphinx_execute = 'never' +# nbsphinx_execute = 'never' # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +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', '.ipynb'] +source_suffix = [".rst"] # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'Properimage' -copyright = u'2017, Bruno Sánchez' -author = u'Bruno Sánchez' +project = "Properimage" +copyright = "2017, Bruno Sánchez" +author = "Bruno Sánchez" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # +# Get the version from properimage package itself (not imported) +with open(os.path.join("..", "..", "properimage", "__init__.py"), "r") as f: + for line in f: + if line.startswith("__version__"): + _, _, __version__ = line.replace('"', "").split() + break +# # The short X.Y version. -version = u'0.2' +version = __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. @@ -85,7 +95,7 @@ exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True @@ -96,7 +106,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'sphinx_rtd_theme' +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 @@ -107,7 +117,7 @@ # 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'] +html_static_path = ["_static"] # Custom sidebar templates, must be a dictionary that maps document names # to template names. @@ -115,9 +125,9 @@ # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars html_sidebars = { - '**': [ - 'relations.html', # needs 'show_related': True theme option to display - 'searchbox.html', + "**": [ + "relations.html", # needs 'show_related': True theme option to display + "searchbox.html", ] } @@ -125,7 +135,7 @@ # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'Properimagedoc' +htmlhelp_basename = "Properimagedoc" # -- Options for LaTeX output --------------------------------------------- @@ -134,15 +144,12 @@ # 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', @@ -152,8 +159,13 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'Properimage.tex', u'Properimage Documentation', - u'Bruno Sánchez', 'manual'), + ( + master_doc, + "Properimage.tex", + "Properimage Documentation", + "Bruno Sánchez", + "manual", + ), ] @@ -162,8 +174,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'properimage', u'Properimage Documentation', - [author], 1) + (master_doc, "properimage", "Properimage Documentation", [author], 1) ] @@ -173,13 +184,18 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'Properimage', u'Properimage Documentation', - author, 'Properimage', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "Properimage", + "Properimage Documentation", + author, + "Properimage", + "One line description of project.", + "Miscellaneous", + ), ] - # -- Options for Epub output ---------------------------------------------- # Bibliographic Dublin Core info. @@ -198,25 +214,28 @@ # epub_uid = '' # A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] +epub_exclude_files = ["search.html"] import subs if not ON_RTD: # only import and set the theme if we're building docs locally import sphinx_rtd_theme - html_theme = 'sphinx_rtd_theme' + + html_theme = "sphinx_rtd_theme" html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] else: from mock import Mock as MagicMock + class Mock(MagicMock): @classmethod def __getattr__(cls, name): - return Mock() + return Mock() + sys.modules.update((mod_name, Mock()) for mod_name in subs.MOCK_MODULES) rst_epilog = "\n".join( [".. _{}: {}".format(k, v) for k, v in subs.TARGETS.items()] - #~ [".. |{}| replace:: {}".format(k, v) for k, v in subs.SUBSTITUTIONS.items()] + # ~ [".. |{}| replace:: {}".format(k, v) for k, v in subs.SUBSTITUTIONS.items()] ) diff --git a/docs/source/subs.py b/docs/source/subs.py index 49dcc3c..4c79e5a 100644 --- a/docs/source/subs.py +++ b/docs/source/subs.py @@ -9,7 +9,5 @@ "virtualenv": "http://www.virtualenv.org/", "virtualenvwrapper": "https://virtualenvwrapper.readthedocs.org/en/latest/", "standalone pip installer": "https://pip.pypa.io/en/latest/installing.html#install-pip", - "Git": "http://git-scm.com/", } -