Skip to content

Commit

Permalink
DOC: injecting docs source path into the docs shell
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Apr 23, 2018
1 parent 9d6ed2e commit 5f03a82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 11 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
import pyblp


# get the location of the source directory
source_path = Path(__file__).resolve().parent

# configure locations of other configuration files
html_static_path = ['static']
templates_path = ['templates']
exclude_patterns = templates_path

# configure project information
language = 'en'
project = 'pyblp'
Expand All @@ -29,7 +37,6 @@
'sphinx.ext.mathjax',
'sphinx.ext.napoleon'
]
ipython_execlines = Path(Path(__file__).resolve().parent / 'static' / 'header.py').read_text().splitlines()
intersphinx_mapping = {
'matplotlib': ('https://matplotlib.org/', None),
'python': ('https://docs.python.org/3.6/', None),
Expand All @@ -42,11 +49,10 @@
html_show_sourcelink = False
ipython_savefig_dir = 'images'
numpydoc_show_class_members = False
ipython_execlines = Path(source_path / 'static' / 'header.py').read_text().splitlines()

# configure locations of other configuration files
html_static_path = ['static']
templates_path = ['templates']
exclude_patterns = templates_path
# add a line to be executed by IPython that stores the location of the source directory so that files can be saved
ipython_execlines.append(f'source_path = \'{source_path.as_posix()}\'')

# configure theme information
html_theme = 'sphinx_rtd_theme'
Expand Down
5 changes: 4 additions & 1 deletion docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ In this section, we'll also import :mod:`matplotlib.pyplot`, which, although not
import matplotlib
matplotlib.use('agg')
from pathlib import Path
def savefig(path):
plt.savefig(path, transparent=True, bbox_inches='tight')
global source_path
plt.savefig(Path(source_path) / path, transparent=True, bbox_inches='tight')
plt.clf()
Expand Down

0 comments on commit 5f03a82

Please sign in to comment.