Skip to content

Commit

Permalink
Fix sphinx config
Browse files Browse the repository at this point in the history
Since notebook was moved to /notebooks, notebook for howtouse page was not loading the data from correct place
  • Loading branch information
rhysgt committed Oct 16, 2023
1 parent 61ae6aa commit 0c9171c
Showing 1 changed file with 24 additions and 30 deletions.
54 changes: 24 additions & 30 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
# -*- 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/master/config

import os
import shutil
import sys

# -- 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
import shutil
sys.path.insert(0, os.path.abspath('../../')) # Reference the root directory so autodocs can find the python modules

# Copy the example notebook, change %matplotlib to inline and change directory so that paths still work
# Copy the example notebook into the docs source
shutil.copyfile('../../notebooks/example_notebook.ipynb', 'howtouse.ipynb')

# Open file
with open('howtouse.ipynb') as f:
newText=f.read().replace('%matplotlib tk', r'%matplotlib inline\n%cd -q ../../')
newText=newText.replace('DefDAP Example notebook', r'How to use')
newText=newText.replace('This notebook', r'These pages')
old_text = f.read()

# change %matplotlib to inline
new_text = old_text.replace('%matplotlib tk', r'%matplotlib inline')

# change directory so that paths still work
new_text = new_text.replace('../tests/data/testDataEBSD', r'../../tests/data/testDataEBSD')
new_text = new_text.replace('../tests/data/', r'../../tests/data/')

# Change title to 'How to use'
new_text = new_text.replace('DefDAP Example notebook', r'How to use')
new_text = new_text.replace('This notebook', r'These pages')

# Write back to notebook
with open('howtouse.ipynb', "w") as f:
f.write(newText)
f.write(new_text)

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

project = 'DefDAP'
copyright = '2020, Mechanics of Microstructures Group at The University of Manchester'
copyright = '2023, Mechanics of Microstructures Group at The University of Manchester'
author = 'Michael D. Atkinson, Rhys Thomas, João Quinta da Fonseca'


Expand Down Expand Up @@ -81,7 +90,6 @@ def get_version():
"""

napoleon_use_param = True
#set_type_checking_flag = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -98,11 +106,7 @@ def get_version():
# 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.
# The language for content autogenerated by Sphinx
language = 'en'

# List of patterns, relative to source directory, that match files and
Expand Down Expand Up @@ -138,16 +142,6 @@ def get_version():
# 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 ---------------------------------------------

Expand Down

0 comments on commit 0c9171c

Please sign in to comment.