Skip to content

Commit

Permalink
Version number in docs/conf.py grabbed from __init__ now. This fixes #43
Browse files Browse the repository at this point in the history
  • Loading branch information
martinberoiz committed Aug 27, 2020
1 parent d862c65 commit 3b5c1ce
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 46 deletions.
107 changes: 63 additions & 44 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -107,25 +117,25 @@
# 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.
#
# 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",
]
}


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

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


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -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',
Expand All @@ -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",
),
]


Expand All @@ -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)
]


Expand All @@ -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.
Expand All @@ -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()]
)
2 changes: 0 additions & 2 deletions docs/source/subs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
}

0 comments on commit 3b5c1ce

Please sign in to comment.