diff --git a/sphinxcontrib/jupyter/builders/jupyter.py b/sphinxcontrib/jupyter/builders/jupyter.py index 66bc6050..5453801a 100644 --- a/sphinxcontrib/jupyter/builders/jupyter.py +++ b/sphinxcontrib/jupyter/builders/jupyter.py @@ -16,6 +16,7 @@ import pdb import time from ..writers.utils import copy_dependencies +from shutil import copyfile class JupyterBuilder(Builder): """ @@ -42,8 +43,8 @@ def init(self): self.executedir = self.outdir + '/executed' self.reportdir = self.outdir + '/reports/' self.errordir = self.outdir + "/reports/{}" - self.downloadsdir = self.outdir + "/_downloads" - self.downloadsExecutedir = self.downloadsdir + "/executed" + self.download_ipynb_dir = self.outdir + "/_downloads_ipynb" + self.downloads_ipynb_executed_dir = self.download_ipynb_dir + "/executed" self.client = None # Check default language is defined in the jupyter kernels @@ -62,7 +63,7 @@ def init(self): instructions = overrides.split(",") for instruction in instructions: - if instruction: + if instruction: #TODO: @AAKASH what is this doing? if instruction == 'code_only': self.config["jupyter_conversion_mode"] = "code" else: @@ -102,9 +103,16 @@ def init(self): 'delayed_notebooks': dict(), 'futures': [], 'delayed_futures': [], - 'destination': self.downloadsExecutedir + 'destination': self.downloads_ipynb_executed_dir } + self.image_library = { + 'index' : [], + } + self.download_library = { + 'index' : [], + } + def get_outdated_docs(self): for docname in self.env.found_docs: if docname not in self.env.all_docs: @@ -133,11 +141,10 @@ def prepare_writing(self, docnames): copy_dependencies(self) if (self.config["jupyter_execute_notebooks"]): - ## copies the dependencies to the executed folder copy_dependencies(self, self.executedir) if (self.config["jupyter_download_nb_execute"]): - copy_dependencies(self, self.downloadsExecutedir) + copy_dependencies(self, self.downloads_ipynb_executed_dir) def write_doc(self, docname, doctree): # work around multiple string % tuple issues in docutils; @@ -147,7 +154,7 @@ def write_doc(self, docname, doctree): ### print an output for downloading notebooks as well with proper links if variable is set if "jupyter_download_nb" in self.config and self.config["jupyter_download_nb"]: - outfilename = os.path.join(self.downloadsdir, os_path(docname) + self.out_suffix) + outfilename = os.path.join(self.download_ipynb_dir, os_path(docname) + self.out_suffix) ensuredir(os.path.dirname(outfilename)) self.writer._set_ref_urlpath(self.config["jupyter_download_nb_urlpath"]) self.writer._set_jupyter_download_nb_image_urlpath((self.config["jupyter_download_nb_image_urlpath"])) @@ -210,57 +217,103 @@ def update_Metadata(self, nb): return nb def copy_static_files(self): - # copy all static files - self.logger.info(bold("copying static files... "), nonl=True) - ensuredir(os.path.join(self.outdir, '_static')) - if (self.config["jupyter_execute_notebooks"]): - self.logger.info(bold("copying static files to executed folder... \n"), nonl=True) - ensuredir(os.path.join(self.executed_notebook_dir, '_static')) - - - # excluded = Matcher(self.config.exclude_patterns + ["**/.*"]) - for static_path in self.config["jupyter_static_file_path"]: - entry = os.path.join(self.confdir, static_path) - if not os.path.exists(entry): - self.logger.warning( - "jupyter_static_path entry {} does not exist" - .format(entry)) + """ + Process Static Files including image and download libraries + """ + self.process_image_library(self.outdir) + self.process_download_library(self.outdir) + + if self.config['jupyter_execute_notebooks']: + self.process_image_library(self.executed_notebook_dir) + self.process_download_library(self.executed_notebook_dir) + + # # copy all static files to build folder + # target = os.path.join(self.outdir, '_static') + # self.logger.info(bold("[builder] copying bulk static files to {}\n".format(target)), nonl=True) + # ensuredir(target) + # if self.config["jupyter_execute_notebooks"]: + # target = os.path.join(self.executed_notebook_dir, '_static') + # self.logger.info(bold("[builder] copying bulk static files to {}\n".format(target)), nonl=True) + # ensuredir(target) + + # # excluded = Matcher(self.config.exclude_patterns + ["**/.*"]) + # for static_path in self.config["jupyter_static_file_path"]: + # entry = os.path.join(self.confdir, static_path) + # if not os.path.exists(entry): + # self.logger.warning( + # "[builder] jupyter_static_path entry {} does not exist" + # .format(entry) + # ) + # else: + # copy_asset(entry, os.path.join(self.outdir, "_static")) + # if self.config["jupyter_execute_notebooks"]: + # copy_asset(entry, os.path.join(self.executed_notebook_dir, "_static")) + + def process_image_library(self, context): + """ + Action self.image_library + """ + image_path = os.path.join(context, "_images") + self.logger.info(bold("[builder] copy images to {}".format(image_path))) + ensuredir(image_path) + for uri in self.image_library.keys(): + if uri == "index": + continue + file, internal_image = self.image_library[uri] + if "../" in uri and internal_image == False: + num_steps = uri.count("../") + srcdir = "/".join(self.srcdir.split("/")[0:-1*num_steps]) else: - copy_asset(entry, os.path.join(self.outdir, "_static")) - if (self.config["jupyter_execute_notebooks"]): - copy_asset(entry, os.path.join(self.executed_notebook_dir, "_static")) - self.logger.info("done") - + srcdir = self.srcdir + uri = uri.replace("../", "") + src = os.path.join(srcdir, uri) + target = os.path.join(image_path, file) + copyfile(src, target) + + def process_download_library(self, context): + """ + Action self.download_library + """ + download_path = os.path.join(context, "_downloads") + self.logger.info(bold("[builder] copy downloads to {}".format(download_path))) + ensuredir(download_path) + for fl in self.download_library.keys(): + if fl == "index": + continue + filename, internal_file, subfolder_depth = self.download_library[fl] + if "../" in fl and internal_file == False: + num_steps = fl.count("../") + srcdir = "/".join(self.srcdir.split("/")[0:-1*(num_steps - subfolder_depth)]) + else: + srcdir = self.srcdir + fl = fl.replace("../", "") + src = os.path.join(srcdir, fl) + if not os.path.exists(src): + self.logger.info(bold("[builder] cannot find download: {}".format(src))) + else: + target = os.path.join(download_path, filename) + copyfile(src, target) def finish(self): + self.finish_tasks.add_task(self.copy_static_files) - if (self.config["jupyter_execute_notebooks"]): + if self.config["jupyter_execute_notebooks"]: self.finish_tasks.add_task(self.copy_static_files) self.save_executed_and_generate_coverage(self.execution_vars,'website', self.config['jupyter_make_coverage']) - if (self.config["jupyter_download_nb_execute"]): + if self.config["jupyter_download_nb_execute"]: self.finish_tasks.add_task(self.copy_static_files) self.save_executed_and_generate_coverage(self.download_execution_vars, 'downloads') - ### create a website folder if "jupyter_make_site" in self.config and self.config['jupyter_make_site']: - self._make_site_class.build_website(self) - - def save_executed_and_generate_coverage(self, params, target, coverage = False): - - # watch progress of the execution of futures - self.logger.info(bold("Starting notebook execution for %s and html conversion(if set in config)..."), target) - #progress(self.futures) + self._make_site_class.build_website() + def save_executed_and_generate_coverage(self, params, target, coverage=False): + self.logger.info(bold("[builder] Starting notebook execution for {} and html conversion...".format(target))) # save executed notebook error_results = self._execute_notebook_class.save_executed_notebook(self, params) - ##generate coverage if config value set if coverage: - ## produces a JSON file of dask execution - self._execute_notebook_class.produce_dask_processing_report(self, params) - - ## generate the JSON code execution reports file + self._execute_notebook_class.produce_dask_processing_report(self, params) error_results = self._execute_notebook_class.produce_code_execution_report(self, error_results, params) - self._execute_notebook_class.create_coverage_report(self, error_results, params) diff --git a/sphinxcontrib/jupyter/writers/make_site.py b/sphinxcontrib/jupyter/writers/make_site.py index 9013a8c0..d05e6a1d 100644 --- a/sphinxcontrib/jupyter/writers/make_site.py +++ b/sphinxcontrib/jupyter/writers/make_site.py @@ -6,82 +6,89 @@ class MakeSiteWriter(): """ - Makes website for each package + Compile website from components """ logger = logging.getLogger(__name__) - def __init__(self, builderSelf): - builddir = builderSelf.outdir + + def __init__(self, builder): + self.builder = builder ## removing the /jupyter from path to get the top directory - index = builddir.rfind('/jupyter') + index = self.builder.outdir.rfind('/jupyter') if index > 0: - builddir = builddir[0:index] + self.outdir = self.builder.outdir[0:index] ## defining directories - self.websitedir = builddir + "/jupyter_html/" - self.downloadipynbdir = self.websitedir + "/_downloads/ipynb/" - - def build_website(self, builderSelf): - if os.path.exists(self.websitedir): - shutil.rmtree(self.websitedir) - - builderSelf.themePath = builderSelf.config['jupyter_theme_path'] - themeFolder = builderSelf.config['jupyter_theme'] - - if themeFolder is not None: - builderSelf.themePath = builderSelf.themePath + "/" + themeFolder - - if os.path.exists(builderSelf.themePath): - pass + self.website_folder = self.outdir + "/jupyter_html/" + self.download_ipynb_folder = self.website_folder + "/_downloads/ipynb/" + + def copy_theme_assets(self): + """ copies theme assets """ + self.theme_path = self.builder.config['jupyter_theme_path'] + self.theme_folder = self.builder.config['jupyter_theme'] + if self.theme_folder is not None: + self.theme_path = self.theme_path + "/" + self.theme_folder + #-Check Theme Path-# + if not os.path.exists(self.theme_path): + self.logger.warning("[copy_theme_assets] the theme directory {} is not found".format(self.theme_path)) + exit(1) + #-Copy HTML theme files to self.website_dir-# + self.html_assets_source = self.theme_path + "/html/" + if os.path.exists(self.html_assets_source): + copy_tree(self.html_assets_source, self.website_folder, preserve_symlinks=1) else: - self.logger.warning("theme directory not found") - exit() - - htmlFolder = builderSelf.themePath + "/html/" - staticFolder = builderSelf.themePath + "/static" - - ## copies the html and downloads folder - shutil.copytree(builderSelf.outdir + "/html/", self.websitedir, symlinks=True) - - ## copies all the static files - shutil.copytree(builderSelf.outdir + "/_static/", self.websitedir + "_static/", symlinks=True) - - ## copies all theme files to _static folder - if os.path.exists(staticFolder): - copy_tree(staticFolder, self.websitedir + "_static/", preserve_symlinks=1) - else: - self.logger.warning("static folder not present in the themes directory") - - ## copies the helper html files - if os.path.exists(htmlFolder): - copy_tree(htmlFolder, self.websitedir, preserve_symlinks=1) + self.logger.warning("[copy_theme_assets] html folder not present in the themes directory") #@AAKASH will there always be an html folder required in theme folder? + #-Copy other static assets to _static-# + self.static_theme_source = self.theme_path + "/static" + if os.path.exists(self.static_theme_source): + copy_tree(self.static_theme_source, self.website_folder + "_static/", preserve_symlinks=1) else: - self.logger.warning("html folder not present in the themes directory") - - - if "jupyter_coverage_dir" in builderSelf.config and builderSelf.config["jupyter_coverage_dir"]: - if os.path.exists(builderSelf.config['jupyter_coverage_dir']): - self.coveragedir = builderSelf.config['jupyter_coverage_dir'] + self.logger.warning("[copy_theme_assets] static folder not present in the themes directory") + + def copy_image_library(self): + """ copies image library """ + image_path = os.path.join(self.builder.outdir, "_images") + if os.path.exists(image_path): + shutil.copytree(image_path, self.website_folder + "_images/", symlinks=True) + + def copy_download_library(self): + """ copies download library """ + download_path = os.path.join(self.builder.outdir, "_downloads") + if os.path.exists(download_path): + shutil.copytree(download_path, self.website_folder + "_downloads/", symlinks=True) + + def build_website(self): + # clean old website + if os.path.exists(self.website_folder): + shutil.rmtree(self.website_folder) + + # copies html and downloads folder + shutil.copytree(self.builder.outdir + "/html/", self.website_folder, symlinks=True) + self.copy_image_library() + self.copy_download_library() + self.copy_theme_assets() + + ## copies all the static files (TODO: disable to debug!) + # shutil.copytree(self.builder.outdir + "/_static/", self.website_folder + "_static/", symlinks=True) + + if "jupyter_coverage_dir" in self.builder.config and self.builder.config["jupyter_coverage_dir"]: + if os.path.exists(self.builder.config['jupyter_coverage_dir']): + self.coveragedir = self.builder.config['jupyter_coverage_dir'] ## copies the report of execution results if os.path.exists(self.coveragedir + "/jupyter/reports/code-execution-results.json"): - shutil.copy2(self.coveragedir + "/jupyter/reports/code-execution-results.json", self.websitedir + "_static/") + shutil.copy2(self.coveragedir + "/jupyter/reports/code-execution-results.json", self.website_folder + "_static/") else: - self.logger.error("coverage directory not found. Please ensure to run coverage build before running website build") - else: - self.logger.error(" coverage directory nbot specified. Please specify coverage directory for creating website reports ") - - - ## copies the downloads folder - if "jupyter_download_nb" in builderSelf.config and builderSelf.config["jupyter_download_nb"]: - if builderSelf.config["jupyter_download_nb_execute"]: - sourceDownloads = builderSelf.outdir + "/_downloads/executed" - else: - sourceDownloads = builderSelf.outdir + "/_downloads" - if os.path.exists(sourceDownloads): - shutil.copytree(sourceDownloads, self.downloadipynbdir, symlinks=True) + self.logger.error("[coverage] coverage directory {} not found. Please ensure to run coverage build \ + before running website build".format(self.builder.config['jupyter_coverage_dir']) + ) + + ## copies the downloadable ipynb assets to downloads ipynb support folder + if "jupyter_download_nb" in self.builder.config and self.builder.config["jupyter_download_nb"]: + if self.builder.config['jupyter_download_nb_execute']: + download_ipynb_source = self.outdir + "/jupyter/_downloads_ipynb/executed" else: - self.logger.warning("Downloads folder not created during build") - - - - + download_ipynb_source = self.outdir + "/jupyter/_downloads_ipynb" + if os.path.exists(download_ipynb_source): + shutil.copytree(download_ipynb_source, self.download_ipynb_folder, symlinks=True) + else: + self.logger.warning("[make_site] IPYNB downloads folder {} not created during build".format(download_ipynb_source)) \ No newline at end of file diff --git a/sphinxcontrib/jupyter/writers/translate_all.py b/sphinxcontrib/jupyter/writers/translate_all.py index 2ac8fd69..5dac81c7 100644 --- a/sphinxcontrib/jupyter/writers/translate_all.py +++ b/sphinxcontrib/jupyter/writers/translate_all.py @@ -42,6 +42,7 @@ def __init__(self, builder, document): self.in_list = False self.in_math = False self.in_math_block = False + self.in_image = False self.code_lines = [] self.markdown_lines = [] @@ -181,18 +182,54 @@ def visit_image(self, node): implementation as is done in http://docutils.sourceforge.net/docs/ref/rst/directives.html#image """ + self.in_image = True uri = node.attributes["uri"] - self.images.append(uri) #TODO: list of image files + internal_image = True + file_depth = len(self.source_file_name.split("/")) + #-Adjust Absolute Path-# + if "?" not in node['candidates'] and file_depth > 2 and "../" not in uri: + uri = "../"*(file_depth - 2) + uri + #Adjust for Relative References as spphinx returns uri with subfolders before uri provided in rst file + adjust_relative_path = False + if "../" in uri: + adjust_relative_path = True + num_path_steps = uri.count("../") + #-Determine if local image-# + if num_path_steps > (file_depth - 2): + internal_image = False + #remove leading folders for subdirectories added by sphinx for internal + uri = "/".join(uri.split("/")[num_path_steps:]) + if '?' in node['candidates']: + # don't rewrite nonlocal image URIs + internal_image = False + pass + elif uri not in self.builder.image_library.keys(): + #add files to image libary for builder + path, filename = self.check_duplicate_files(uri) + self.builder.image_library[uri] = (filename, internal_image) + uri = os.path.join("_images", filename) + else: + #Already added to image libary for builder to copy asset + path, filename = os.path.split(uri) + uri = os.path.join("_images", filename) + #-Adjustment for nested folders added by sphinx-# + if adjust_relative_path: + #Note: A depth of 2 is in the root level of the project directory + if file_depth > 2: + uri = "../"*(file_depth-2) + uri + #-Parse link updating for jupyter_download_nb_image_urlpath if self.jupyter_download_nb_image_urlpath: - for file_path in self.jupyter_static_file_path: - if file_path in uri: - uri = uri.replace(file_path +"/", self.jupyter_download_nb_image_urlpath) - break #don't need to check other matches - attrs = node.attributes + if '?' in node['candidates']: + pass + else: + path, filename = os.path.split(uri) + uri = os.path.join(self.jupyter_download_nb_image_urlpath, filename) + #-Write to Markdown-# if self.jupyter_images_markdown: #-Construct MD image image = "![{0}]({0})".format(uri) else: + attrs = node.attributes # Construct HTML image image = ' (doc_depth - 2): + internal_file = False + if sourcefile not in self.builder.download_library.keys(): + #add files to download libary for builder + path, filename = self.check_duplicate_files(sourcefile) + subfolder_depth = doc_depth - 2 + self.builder.download_library[sourcefile] = (filename, internal_file, subfolder_depth) + targetfile = os.path.join("_downloads", filename) + else: + #Already added to download libary for builder to copy asset + path, filename = os.path.split(sourcefile) + targetfile = os.path.join("_downloads", filename) + if doc_depth > 2: #Note: A depth of 2 is in the root level of the project directory + targetfile = "../"*(doc_depth-2) + targetfile + html = "".format(targetfile) self.markdown_lines.append(html) def depart_download_reference(self, node): @@ -925,6 +986,33 @@ def add_markdown_cell(self, slide_type="slide", title=False): self.output["cells"].append(new_md_cell) self.markdown_lines = [] + def check_duplicate_files(self, uri): + """ + Parse URI for duplicate files in catalog + """ + #Check for file by the same name in library and increment if found + def rename_file(filename, library): + while filename in library['index']: + base, ext = os.path.splitext(filename) + if re.search("-\d*", base): + base, num = base.split("-") + num = str(int(num) + 1) #increment value + filename = base+"-"+num+ext + else: + filename = base+"-1"+ext + return filename + + path, filename = os.path.split(uri) + if self.in_image: + filename = rename_file(filename, self.builder.image_library) + self.builder.image_library['index'].append(filename) + elif self.in_download_reference: + filename = rename_file(filename, self.builder.download_library) + self.builder.download_library['index'].append(filename) + else: + raise NotImplementedError + return path, filename + @classmethod def split_uri_id(cls, uri): return re.search(cls.SPLIT_URI_ID_REGEX, uri).groups() diff --git a/sphinxcontrib/jupyter/writers/utils.py b/sphinxcontrib/jupyter/writers/utils.py index e58a987a..8528e724 100644 --- a/sphinxcontrib/jupyter/writers/utils.py +++ b/sphinxcontrib/jupyter/writers/utils.py @@ -143,7 +143,7 @@ def _str_to_lines(x): return x -def copy_dependencies(builderSelf, outdir = None): +def copy_dependencies(builderSelf, outdir=None): """ Copies the dependencies of source files or folders specified in the config to their respective output directories """ @@ -161,7 +161,7 @@ def copy_dependencies(builderSelf, outdir = None): full_dest_path = outdir + "/" + key ensuredir(full_dest_path) for dep in deps: - copy(full_src_path + "/" + dep, full_dest_path,follow_symlinks=True) + copy(full_src_path + "/" + dep, full_dest_path, follow_symlinks=True) elif os.path.isfile(full_src_path): ## handling the case of key being a file # removing the filename to get the directory path @@ -172,7 +172,7 @@ def copy_dependencies(builderSelf, outdir = None): full_src_path = srcdir + "/" + key full_dest_path = outdir + "/" + key for dep in deps: - copy(full_src_path + "/" + dep, full_dest_path,follow_symlinks=True) + copy(full_src_path + "/" + dep, full_dest_path, follow_symlinks=True) def python27_glob(path, pattern): diff --git a/tests/_static/simple_notebook.png b/tests/_static/simple_notebook.png new file mode 100644 index 00000000..854da176 Binary files /dev/null and b/tests/_static/simple_notebook.png differ diff --git a/tests/_static/test_pwt.csv b/tests/_static/test_pwt.csv new file mode 100644 index 00000000..03ae3be0 --- /dev/null +++ b/tests/_static/test_pwt.csv @@ -0,0 +1,9 @@ +"country","country isocode","year","POP","XRAT","tcgdp","cc","cg" +"Argentina","ARG","2000","37335.653","0.9995","295072.21869","75.716805379","5.5788042896" +"Australia","AUS","2000","19053.186","1.72483","541804.6521","67.759025993","6.7200975332" +"India","IND","2000","1006300.297","44.9416","1728144.3748","64.575551328","14.072205773" +"Israel","ISR","2000","6114.57","4.07733","129253.89423","64.436450847","10.266688415" +"Malawi","MWI","2000","11801.505","59.543808333","5026.2217836","74.707624181","11.658954494" +"South Africa","ZAF","2000","45064.098","6.93983","227242.36949","72.718710427","5.7265463933" +"United States","USA","2000","282171.957","1","9898700","72.347054303","6.0324539789" +"Uruguay","URY","2000","3219.793","12.099591667","25255.961693","78.978740282","5.108067988" diff --git a/tests/base/_static/level1/hood.jpg b/tests/base/_static/level1/hood.jpg new file mode 100644 index 00000000..e0426a4c Binary files /dev/null and b/tests/base/_static/level1/hood.jpg differ diff --git a/tests/base/download.rst b/tests/base/download.rst index 347bfe35..f775061c 100644 --- a/tests/base/download.rst +++ b/tests/base/download.rst @@ -1,4 +1,9 @@ Download ======== -Add test for download directive :download:`here <_static/test_pwt.csv>` \ No newline at end of file +Add test for download directive :download:`here <_static/test_pwt.csv>` + +and at a root location specification :download:`root ` + +and referencing a file that is in a different +relative location :download:`second here <../_static/test_pwt.csv>` \ No newline at end of file diff --git a/tests/base/images.rst b/tests/base/images.rst index 902587a8..df0c5d7e 100644 --- a/tests/base/images.rst +++ b/tests/base/images.rst @@ -48,3 +48,40 @@ Testing the **.. figure::** directive .. figure:: _static/hood.jpg :scale: 50 % + +File Collisions +--------------- + +Add a figure of the same name in a different folder + +Most basic image directive + +.. image:: _static/level1/hood.jpg + +Remote Images +------------- + +Adding a test for remote images specified by url + +.. image:: https://s3-ap-southeast-2.amazonaws.com/assets.quantecon.org/img/sloan_logo.png + +and using figure directive + +.. figure:: https://s3-ap-southeast-2.amazonaws.com/assets.quantecon.org/img/sloan_logo.png + :scale: 50 % + +Supported Image Path Specifications +----------------------------------- + +Adding a relative path image reference + +.. image:: _static/hood.jpg + +Adding a root level path image reference + +.. image:: /_static/hood.jpg + +Adding a path to base level _static folder outside of `base` project folder + +.. image:: ../_static/simple_notebook.png + diff --git a/tests/base/ipynb/download.ipynb b/tests/base/ipynb/download.ipynb index 84443fd0..7c9c21b0 100644 --- a/tests/base/ipynb/download.ipynb +++ b/tests/base/ipynb/download.ipynb @@ -6,7 +6,12 @@ "source": [ "# Download\n", "\n", - "Add test for download directive here" + "Add test for download directive here\n", + "\n", + "and at a root location specification root\n", + "\n", + "and referencing a file that is in a different\n", + "relative location second here" ] } ], diff --git a/tests/base/ipynb/images.ipynb b/tests/base/ipynb/images.ipynb index 3d2cc448..f2bf312a 100644 --- a/tests/base/ipynb/images.ipynb +++ b/tests/base/ipynb/images.ipynb @@ -19,27 +19,27 @@ "\n", "Most basic image directive\n", "\n", - "\n", + "\n", "\n", "A scaled down version with 25 % width\n", "\n", - "\n", + "\n", "\n", "A height of 50px\n", "\n", - "\n", + "\n", "\n", "Including *alt*\n", "\n", - "\"A\n", + "\"A\n", "\n", "An image with a *right* alignment\n", "\n", - "\n", + "\n", "\n", "An image with a *left* alignment\n", "\n", - "" + "" ] }, { @@ -52,7 +52,54 @@ "\n", "Testing the **.. figure::** directive\n", "\n", - "" + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## File Collisions\n", + "\n", + "Add a figure of the same name in a different folder\n", + "\n", + "Most basic image directive\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Remote Images\n", + "\n", + "Adding a test for remote images specified by url\n", + "\n", + "\n", + "\n", + "and using figure directive\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Supported Image Path Specifications\n", + "\n", + "Adding a relative path image reference\n", + "\n", + "\n", + "\n", + "Adding a root level path image reference\n", + "\n", + "\n", + "\n", + "Adding a path to base level _static folder outside of base project folder\n", + "\n", + "" ] } ], diff --git a/tests/base/ipynb/index.ipynb b/tests/base/ipynb/index.ipynb index de6e5678..375861be 100644 --- a/tests/base/ipynb/index.ipynb +++ b/tests/base/ipynb/index.ipynb @@ -24,6 +24,9 @@ "- [Images](images.ipynb)\n", " - [Image](images.ipynb#image)\n", " - [Figure](images.ipynb#figure)\n", + " - [File Collisions](images.ipynb#file-collisions)\n", + " - [Remote Images](images.ipynb#remote-images)\n", + " - [Supported Image Path Specifications](images.ipynb#supported-image-path-specifications)\n", "- [Inline](inline.ipynb)\n", " - [Code](inline.ipynb#code)\n", " - [Math](inline.ipynb#math)\n", @@ -82,7 +85,9 @@ "- [Section 2](section2/index.ipynb)\n", " - [Exercise List from section2 (all)](section2/exercise_list_sec2_all.ipynb)\n", " - [Exercise List from section2 (section2 only)](section2/exercise_list_sec2.ipynb)\n", - " - [Exercises in section 2](section2/exercises_section2.ipynb)" + " - [Exercises in section 2](section2/exercises_section2.ipynb)\n", + " - [Images](section2/images.ipynb)\n", + " - [Download](section2/download.ipynb)" ] }, { diff --git a/tests/base/ipynb/section2/download.ipynb b/tests/base/ipynb/section2/download.ipynb new file mode 100644 index 00000000..4a3a7a67 --- /dev/null +++ b/tests/base/ipynb/section2/download.ipynb @@ -0,0 +1,29 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Download\n", + "\n", + "Add test for download directive here\n", + "\n", + "and at a root location specification root\n", + "\n", + "and referencing a file that is in a different\n", + "relative location second here" + ] + } + ], + "metadata": { + "filename": "download.rst", + "kernelspec": { + "display_name": "Python", + "language": "python3", + "name": "python3" + }, + "title": "Download" + }, + "nbformat": 4, + "nbformat_minor": 2 +} \ No newline at end of file diff --git a/tests/base/ipynb/section2/images.ipynb b/tests/base/ipynb/section2/images.ipynb new file mode 100644 index 00000000..198b6914 --- /dev/null +++ b/tests/base/ipynb/section2/images.ipynb @@ -0,0 +1,41 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Images" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Supported Image Path Specifications\n", + "\n", + "Adding a relative path image reference\n", + "\n", + "\n", + "\n", + "Adding a root level path image reference\n", + "\n", + "\n", + "\n", + "Adding a path to base level _static folder outside of base project folder\n", + "\n", + "" + ] + } + ], + "metadata": { + "filename": "images.rst", + "kernelspec": { + "display_name": "Python", + "language": "python3", + "name": "python3" + }, + "title": "Images" + }, + "nbformat": 4, + "nbformat_minor": 2 +} \ No newline at end of file diff --git a/tests/base/ipynb/section2/index.ipynb b/tests/base/ipynb/section2/index.ipynb index 9ac95e0d..9457fcef 100644 --- a/tests/base/ipynb/section2/index.ipynb +++ b/tests/base/ipynb/section2/index.ipynb @@ -12,7 +12,10 @@ "\n", "- [Exercise List from section2 (all)](exercise_list_sec2_all.ipynb)\n", "- [Exercise List from section2 (section2 only)](exercise_list_sec2.ipynb)\n", - "- [Exercises in section 2](exercises_section2.ipynb)" + "- [Exercises in section 2](exercises_section2.ipynb)\n", + "- [Images](images.ipynb)\n", + " - [Supported Image Path Specifications](images.ipynb#supported-image-path-specifications)\n", + "- [Download](download.ipynb)" ] } ], diff --git a/tests/base/ipynb/simple_notebook.ipynb b/tests/base/ipynb/simple_notebook.ipynb index 34b0f2a4..8efdfd6a 100644 --- a/tests/base/ipynb/simple_notebook.ipynb +++ b/tests/base/ipynb/simple_notebook.ipynb @@ -60,7 +60,7 @@ "source": [ "Figures can be include using the **figure** directive\n", "\n", - "" + "" ] }, { diff --git a/tests/base/ipynb/slides.ipynb b/tests/base/ipynb/slides.ipynb index 376d0b15..e95e0eea 100644 --- a/tests/base/ipynb/slides.ipynb +++ b/tests/base/ipynb/slides.ipynb @@ -89,7 +89,7 @@ "source": [ "We can also include the figures from some folder\n", "\n", - "" + "" ] }, { diff --git a/tests/base/section2/download.rst b/tests/base/section2/download.rst new file mode 100644 index 00000000..a145cd55 --- /dev/null +++ b/tests/base/section2/download.rst @@ -0,0 +1,9 @@ +Download +======== + +Add test for download directive :download:`here <../_static/test_pwt.csv>` + +and at a root location specification :download:`root ` + +and referencing a file that is in a different +relative location :download:`second here <../../_static/test_pwt.csv>` \ No newline at end of file diff --git a/tests/base/section2/images.rst b/tests/base/section2/images.rst new file mode 100644 index 00000000..7d09c5b8 --- /dev/null +++ b/tests/base/section2/images.rst @@ -0,0 +1,18 @@ +Images +====== + +Supported Image Path Specifications +----------------------------------- + +Adding a relative path image reference + +.. image:: ../_static/hood.jpg + +Adding a root level path image reference + +.. image:: /_static/hood.jpg + +Adding a path to base level _static folder outside of `base` project folder + +.. image:: ../../_static/simple_notebook.png + diff --git a/tests/base/section2/index.rst b/tests/base/section2/index.rst index 90f08b1e..20527a79 100644 --- a/tests/base/section2/index.rst +++ b/tests/base/section2/index.rst @@ -13,3 +13,5 @@ This is the index for section2 exercise_list_sec2_all exercise_list_sec2 exercises_section2 + images + download