Skip to content

Commit

Permalink
Merge pull request #222 from minrk/environment.yml
Browse files Browse the repository at this point in the history
Use conda on RTD
  • Loading branch information
takluyver committed Feb 24, 2016
2 parents 2279503 + 809cda5 commit 4e51fb1
Show file tree
Hide file tree
Showing 5 changed files with 504 additions and 62 deletions.
11 changes: 11 additions & 0 deletions docs/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: nbconvert_docs
channels:
- asmeurer
dependencies:
- pandoc
- nbformat
- jupyter_client
- sphinx
- pip:
- nbsphinx
- entrypoints
8 changes: 0 additions & 8 deletions docs/requirements.txt

This file was deleted.

278 changes: 250 additions & 28 deletions docs/source/customizing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,64 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"# coding: utf-8\n",
"\n",
"# # Example notebook\n",
"\n",
"# ### Markdown cells\n",
"# \n",
"# This is an example notebook that can be converted with `nbconvert` to different formats. This is an example of a markdown cell.\n",
"\n",
"# ### LaTeX Equations\n",
"# \n",
"# Here is an equation:\n",
"# \n",
"# $$\n",
"# y = \\sin(x)\n",
"# $$\n",
"\n",
"# ### Code cells\n",
"\n",
"# In[1]:\n",
"\n",
"print(\"This is a code cell that produces some output\")\n",
"\n",
"\n",
"# ### Inline figures\n",
"\n",
"# In[2]:\n",
"\n",
"get_ipython().magic('matplotlib inline')\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"x = np.linspace(0, 2 * np.pi, 100)\n",
"y = np.sin(x)\n",
"plt.plot(x, y)\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[NbConvertApp] Converting notebook example.ipynb to python\n"
]
}
],
"source": [
"%%bash\n",
"\n",
"jupyter nbconvert --to python 'example.ipynb' --stdout"
"!jupyter nbconvert --to python 'example.ipynb' --stdout"
]
},
{
Expand All @@ -40,11 +89,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting simplepython.tpl\n"
]
}
],
"source": [
"%%writefile simplepython.tpl\n",
"\n",
Expand All @@ -69,15 +126,45 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"# coding: utf-8\n",
"\n",
"# This was input cell with execution count: 1\n",
"print(\"This is a code cell that produces some output\")\n",
"\n",
"\n",
"# This was input cell with execution count: 2\n",
"get_ipython().magic('matplotlib inline')\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"x = np.linspace(0, 2 * np.pi, 100)\n",
"y = np.sin(x)\n",
"plt.plot(x, y)\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[NbConvertApp] Converting notebook example.ipynb to python\n"
]
}
],
"source": [
"%%bash\n",
"\n",
"jupyter nbconvert --to python 'example.ipynb' --stdout --template=simplepython.tpl"
"!jupyter nbconvert --to python 'example.ipynb' --stdout --template=simplepython.tpl"
]
},
{
Expand All @@ -95,11 +182,145 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<!--\n",
"This is an HTML fragment that gets included into a notebook & rst document\n",
"-->\n",
"<style type=\"text/css\">\n",
"/* Overrides of notebook CSS for static HTML export */\n",
".jp-tpl-structure {\n",
" font-family: sans;\n",
"}\n",
"\n",
".template_block {\n",
" background-color: hsla(120, 60%, 70%, 0.2);\n",
" margin: 10px;\n",
" padding: 5px;\n",
" border: 1px solid hsla(120, 60%, 70%, 0.5);\n",
" border-left: 2px solid black;\n",
"}\n",
"\n",
".template_block pre {\n",
" background: transparent;\n",
" padding: 0;\n",
"}\n",
"\n",
".big_vertical_ellipsis {\n",
" font-size: 24pt;\n",
"}\n",
"\n",
"</style>\n",
"\n",
"<div class='jp-tpl-structure'>\n",
"<h3>Main page</h3>\n",
"<div class=\"template_block\">header</div>\n",
"\n",
"<div class=\"template_block\">body\n",
" <div class=\"template_block\">any_cell\n",
" <div class=\"template_block\">codecell\n",
" <div class=\"template_block\">input_group\n",
" <div class=\"template_block\">in_prompt</div>\n",
" <div class=\"template_block\">input</div>\n",
" </div>\n",
" <div class=\"template_block\">output_group\n",
" <div class=\"template_block\">output_prompt</div>\n",
" <div class=\"template_block\">outputs (see below)</div>\n",
" </div>\n",
" </div>\n",
" </div>\n",
" <div class=\"template_block\">any_cell\n",
" <div class=\"template_block\">markdowncell</div>\n",
" </div>\n",
" <div class=\"template_block\">any_cell\n",
" <div class=\"template_block\">rawcell</div>\n",
" </div>\n",
" <div class=\"template_block\">any_cell\n",
" <div class=\"template_block\">unknowncell</div>\n",
" </div>\n",
" <div class=\"big_vertical_ellipsis\">&#8942;</div>\n",
"</div>\n",
"\n",
"<div class=\"template_block\">footer</div>\n",
"\n",
"<h3>Outputs</h3>\n",
"\n",
"<div class=\"template_block\">outputs\n",
" <div class=\"template_block\">output\n",
" <div class=\"template_block\">execute_result</div>\n",
" </div>\n",
" <div class=\"template_block\">output\n",
" <div class=\"template_block\">stream_stdout</div>\n",
" </div>\n",
" <div class=\"template_block\">output\n",
" <div class=\"template_block\">stream_stderr</div>\n",
" </div>\n",
" <div class=\"template_block\">output\n",
" <div class=\"template_block\">display_data\n",
" <div class=\"template_block\">data_priority\n",
" <div class=\"template_block\">data_pdf / data_svg / data_png /\n",
" data_html / data_markdown / data_jpg / data_text /\n",
" data_latex / data_javascript / data_other\n",
" </div>\n",
" </div>\n",
" </div>\n",
" </div>\n",
" <div class=\"template_block\">output\n",
" <div class=\"template_block\">error\n",
" <div class=\"template_block\">traceback_line</div>\n",
" <div class=\"big_vertical_ellipsis\">&#8942;</div>\n",
" </div>\n",
" </div>\n",
" <div class=\"big_vertical_ellipsis\">&#8942;</div>\n",
"</div>\n",
"\n",
"<h3>Extra HTML blocks (full.tpl)</h3>\n",
"<div class=\"template_block\">header\n",
" <pre>&lt;head&gt;</pre>\n",
" <div class=\"template_block\">html_head</div>\n",
" <pre>&lt;/head&gt;</pre>\n",
"</div>\n",
"\n",
"<h3>Extra Latex blocks</h3>\n",
"<div class=\"template_block\">header\n",
" <div class=\"template_block\">docclass</div>\n",
" <div class=\"template_block\">packages</div>\n",
" <div class=\"template_block\">definitions\n",
" <div class=\"template_block\">title</div>\n",
" <div class=\"template_block\">date</div>\n",
" <div class=\"template_block\">author</div>\n",
" </div>\n",
" <div class=\"template_block\">commands\n",
" <div class=\"template_block\">margins</div>\n",
" </div>\n",
"</div>\n",
"<div class=\"template_block\">body\n",
" <div class=\"template_block\">predoc\n",
" <div class=\"template_block\">maketitle</div>\n",
" <div class=\"template_block\">abstract</div>\n",
" </div>\n",
" ... other fields as above ...\n",
" <div class=\"template_block\">postdoc\n",
" <div class=\"template_block\">bibliography</div>\n",
" </div>\n",
"</div>\n",
"</div>\n",
"\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from IPython.display import HTML, display\n",
"with open('template_structure.html') as f:\n",
Expand Down Expand Up @@ -142,11 +363,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting mytemplate.tpl\n"
]
}
],
"source": [
"%%writefile mytemplate.tpl\n",
"\n",
Expand All @@ -160,22 +389,15 @@
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Once you have tagged the cells appropriately and written your template using the cell above, try converting your notebook using the following command:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%%bash\n",
"Once you have tagged the cells appropriately and written your template using the cell above, try converting your notebook using the following command:\n",
"\n",
"jupyter nbconvert --to html <your chosen notebook.ipynb> --template=mytemplate.tpl"
"```bash\n",
"jupyter nbconvert --to html <your notebook.ipynb> --template=mytemplate.tpl\n",
"```"
]
}
],
Expand All @@ -195,7 +417,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
"version": "3.5.1"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 4e51fb1

Please sign in to comment.