Various useful tips for running the API LAB in development mode.
Before trying to do any development work, you will need to create a set-envs.sh
file in the tools
folder.
The purpose of this file is to define the local directories you would like to use for building test and staging versions of site, to ensure the site renders as expected before pushing to production.
Example directories are given in tools/set-envs-sample.sh
. Replace the values for the stated variables with those you desire.
Note the .gitignore
file is set to ignore set-envs.sh
.
New notebooks are added to the cookbooks
folder. The folder structure should not be changed, so ensure legacy URLs and internal links doesn't break.
PS The backlog
folder contains various tutorials that are being considered for publication.
The build process uses sphinx + nbsphinx to turn Python notebooks into HTML files.
If you want to test building just a few notebooks another command is available, which processes only notebooks in backlog/ACTIVE
:
$ make html_test
The build directory is the same tmp
location used for staging.
IMPORTANT: when testing, ensure that
/sphinx/index.rst
references the correct files! Seeindex.rst.TEST
for an example.
$ make html_staging
Both commands run in local and output everything to a tmp
location. See the (makefile) for more details.
Running the make html
command builds the site into the docs
folder. This folder is publically available on the web, in the public clone of this project. So, first build and push for this project:
$ make html
$ git add -A
$ git commit
$ git push
The CHANGELOG.md file is publically available to end users.
When notebooks are added or updated, changes are recorded in that file.
A few gotchas and related solutions.
The notebook export functionality will work correctly with these library versions:
docutils==0.16
nbconvert==6.0.0
markupsafe==1.1.1
jinja2==2.11.3
sphinx==3.0.0
sphinx_rtd_theme==0.5.0
nbsphinx==0.8.3
TODO: update to most recent versions, dealing with css error dues to mathjax rendering issue
Pandoc is also needed: brew install pandoc
For vis.js network visualizations, you need to manually put the HTML output in the right /docs folder.
This is because the viz is embedded via an iFrame, so it does not get exported automatically via the ipynb file.
Relevant locations are:
docs/cookbooks/....
This needs to be done for both the STG export (in /tmp) and the PROD one (in the master repo itself), before the syncing step.
Discussed here readthedocs/sphinx_rtd_theme#788
Fix:
nbsphinx_prolog = r"""
{% set docname = env.doc2path(env.docname, base=None) %}
.. raw:: html
<script src='http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js'></script>
<script>require=requirejs;</script>
...
Docs: https://sphinx-rtd-theme.readthedocs.io/en/stable/configuring.html
Solution: you have to remove titlesonly
in index.rst for that to work
.. toctree::
:caption: Clinical Trials
:maxdepth: 5
:glob:
####:titlesonly:####
Also, these settings:
'collapse_navigation': False,
'sticky_navigation': True,
'navigation_depth': -1,