Remove support for stencila

Changes in stencila mean it doesn't work anymore and it's not feasible to update nbstencilaproxy

Instead, show only a warning about removed support for stencila
pull/985/head
Min RK 2020-11-11 10:57:04 +01:00
rodzic 968cc43a9e
commit edfca79371
21 zmienionych plików z 18 dodań i 1278 usunięć

Wyświetl plik

@ -74,7 +74,6 @@ jobs:
- nix
- pipfile
- r
- stencila-py
- unit
- venv
include:

Wyświetl plik

@ -44,10 +44,9 @@ It takes the following steps to determine this:
repository' by returning `True`. Usually buildpacks look for presence of specific files
(`requirements.txt`, `environment.yml`, `install.R`, `manifest.xml` etc) to determine if they can handle a
repository or not. Buildpacks may also look into specific files to determine specifics of the
required environment, such as the Stencila integration which extracts the required language-specific
executions contexts from an XML file (see base `BuildPack`). More than one buildpack may use such
information, as properties can be inherited (e.g. the R buildpack uses the list of required Stencila
contexts to see if R must be installed).
required environment.
More than one buildpack may use such information,
as properties can be inherited.
3. If no `BuildPack` returns true, then repo2docker will use the default `BuildPack` (defined in
`Repo2Docker.default_buildpack` traitlet).

Wyświetl plik

@ -149,25 +149,6 @@ You also need to have a ``runtime.txt`` file that is formatted as
used for your R installation.
.. _manifest.xml:
``manifest.xml`` - Install Stencila
===================================
`Stencila <https://stenci.la/>`_ is an open source office suite for reproducible research.
It is powered by the open file format `Dar <https://github.com/substance/dar>`_.
If your repository contains a Stencila document, repo2docker detects it based on the file ``manifest.xml``.
The required `execution contexts <https://stenci.la/learn/intro.html>`_ are extracted from a Dar article (i.e.
files named ``*.jats.xml``).
You may also have a ``runtime.txt`` and/or an ``install.R`` to manually configure your R installation.
To see example repositories, visit our
`Stencila with R <https://github.com/binder-examples/stencila-r/>`_ and
`Stencila with Python <https://github.com/binder-examples/stencila-py>`_ examples.
.. _postBuild:
``postBuild`` - Run code after installing the environment

Wyświetl plik

@ -112,18 +112,7 @@ http://mybinder.org/v2/gh/binder-examples/r/master?urlpath=shiny/bus-dashboard/
Stencila
========
The Stencila user interface is automatically enabled if a Stencila document (i.e.
a file ``manifest.xml``) is detected. Stencila will be accessible by appending
``/stencila`` to the URL, like so:
.. note::
.. code-block:: none
http(s)://<server:port>/stencila
The editor will open the Stencila document corresponding to the last ``manifest.xml``
found in the file tree. If you want to open a different document, you can configure
the path in the URL parameter ``archive``:
.. code-block:: none
http(s)://<server:port>/stencila/?archive=other-dir
Stencila support has been removed due to changes in stencila making it incompatible.
Please `get in touch <https://discourse.jupyter.org>`__ if you would like to help restore stencila support.

Wyświetl plik

@ -311,70 +311,16 @@ class BuildPack:
"""
return {}
@property
def stencila_manifest_dir(self):
"""Find the stencila manifest dir if it exists"""
if hasattr(self, "_stencila_manifest_dir"):
return self._stencila_manifest_dir
# look for a manifest.xml that suggests stencila could be used
# when we find one, stencila should be installed
# and set environment variables such that
# this file is located at:
# ${STENCILA_ARCHIVE_DIR}/${STENCILA_ARCHIVE}/manifest.xml
self._stencila_manifest_dir = None
def _check_stencila(self):
"""Find the stencila manifest dir if it exists
And warn about removed stencila support
"""
for root, dirs, files in os.walk("."):
if "manifest.xml" in files:
self.log.debug("Found a manifest.xml at %s", root)
self._stencila_manifest_dir = root.split(os.path.sep, 1)[1]
self.log.info(
"Using stencila manifest.xml in %s", self._stencila_manifest_dir
self.log.error(
f"Found a stencila manifest.xml at {root}. Stencila is no longer supported."
)
break
return self._stencila_manifest_dir
@property
def stencila_contexts(self):
"""Find the stencila manifest contexts from file path in manifest"""
if hasattr(self, "_stencila_contexts"):
return self._stencila_contexts
# look at the content of the documents in the manifest
# to extract the required execution contexts
self._stencila_contexts = set()
# get paths to the article files from manifest
files = []
if self.stencila_manifest_dir:
manifest = ET.parse(
os.path.join(self.stencila_manifest_dir, "manifest.xml")
)
documents = manifest.findall("./documents/document")
files = [
os.path.join(self.stencila_manifest_dir, x.get("path"))
for x in documents
]
else:
return self._stencila_contexts
for filename in files:
self.log.debug("Extracting contexts from %s", filename)
# extract code languages from file
document = ET.parse(filename)
code_chunks = document.findall('.//code[@specific-use="source"]')
languages = [x.get("language") for x in code_chunks]
self._stencila_contexts.update(languages)
self.log.info(
"Added executions contexts, now have %s", self._stencila_contexts
)
break
return self._stencila_contexts
def get_build_scripts(self):
"""
@ -553,6 +499,9 @@ class BuildPack:
for k, v in self.get_build_script_files().items()
}
# check if there's a stencila manifest, support for which has been removd
self._check_stencila()
return t.render(
packages=sorted(self.get_packages()),
path=self.get_path(),
@ -706,23 +655,7 @@ class BaseImage(BuildPack):
def get_env(self):
"""Return env directives to be set after build"""
env = []
if self.stencila_manifest_dir:
# manifest_dir is the path containing the manifest.xml
# archive_dir is the directory containing archive directories
# (one level up) default archive is the name of the directory
# in the archive_dir such that
# ${STENCILA_ARCHIVE_DIR}/${STENCILA_ARCHIVE}/manifest.xml
# exists.
archive_dir, archive = os.path.split(self.stencila_manifest_dir)
env.extend(
[
("STENCILA_ARCHIVE_DIR", "${REPO_DIR}/" + archive_dir),
("STENCILA_ARCHIVE", archive),
]
)
return env
return []
def detect(self):
return True
@ -765,32 +698,6 @@ class BaseImage(BuildPack):
except FileNotFoundError:
pass
if "py" in self.stencila_contexts:
scripts.extend(
[
(
"${NB_USER}",
r"""
${KERNEL_PYTHON_PREFIX}/bin/pip install --no-cache https://github.com/stencila/py/archive/f1260796.tar.gz && \
${KERNEL_PYTHON_PREFIX}/bin/python -m stencila register
""",
)
]
)
if self.stencila_manifest_dir:
scripts.extend(
[
(
"${NB_USER}",
r"""
${NB_PYTHON_PREFIX}/bin/pip install --no-cache nbstencilaproxy==0.1.1 && \
jupyter serverextension enable --sys-prefix --py nbstencilaproxy && \
jupyter nbextension install --sys-prefix --py nbstencilaproxy && \
jupyter nbextension enable --sys-prefix --py nbstencilaproxy
""",
)
]
)
return scripts
def get_assemble_scripts(self):

Wyświetl plik

@ -25,8 +25,6 @@ class RBuildPack(PythonBuildPack):
2. A `DESCRIPTION` file signaling an R package
3. A Stencila document (*.jats.xml) with R code chunks (i.e. language="r")
If there is no `runtime.txt`, then the MRAN snapshot is set to latest
date that is guaranteed to exist across timezones.
@ -37,8 +35,7 @@ class RBuildPack(PythonBuildPack):
- as dependencies in a `DESCRIPTION` file
- are needed by a specific tool, for example the package `stencila` is
installed and configured if a Stencila document is given.
- are needed by a specific tool
The `r-base` package from Ubuntu apt repositories is used to install
R itself, rather than any of the methods from https://cran.r-project.org/.
@ -129,9 +126,7 @@ class RBuildPack(PythonBuildPack):
return True
description_R = "DESCRIPTION"
if (
not self.binder_dir and os.path.exists(description_R)
) or "r" in self.stencila_contexts:
if not self.binder_dir and os.path.exists(description_R):
if not self.checkpoint_date:
# no R snapshot date set through runtime.txt
# set the R runtime to the latest date that is guaranteed to
@ -226,7 +221,6 @@ class RBuildPack(PythonBuildPack):
(determined by MRAN)
- IRKernel
- nbrsessionproxy (to access RStudio via Jupyter Notebook)
- stencila R package (if Stencila document with R code chunks detected)
We set the snapshot date used to install R libraries from based on the
contents of runtime.txt.
@ -325,34 +319,6 @@ class RBuildPack(PythonBuildPack):
),
]
if "r" in self.stencila_contexts:
# new versions of R require a different way of installing bioconductor
if V(self.r_version) <= V("3.5"):
scripts += [
(
"${NB_USER}",
# Install and register stencila library
r"""
R --quiet -e "source('https://bioconductor.org/biocLite.R'); biocLite('graph')" && \
R --quiet -e "devtools::install_github('stencila/r', ref = '361bbf560f3f0561a8612349bca66cd8978f4f24')" && \
R --quiet -e "stencila::register()"
""",
)
]
else:
scripts += [
(
"${NB_USER}",
# Install and register stencila library
r"""
R --quiet -e "install.packages('BiocManager'); BiocManager::install(); BiocManager::install(c('graph'))" && \
R --quiet -e "devtools::install_github('stencila/r', ref = '361bbf560f3f0561a8612349bca66cd8978f4f24')" && \
R --quiet -e "stencila::register()"
""",
)
]
return super().get_build_scripts() + scripts
def get_preassemble_script_files(self):

Wyświetl plik

@ -1,21 +0,0 @@
@article{kluyver2016jupyter,
title={Jupyter Notebooks-a publishing format for reproducible computational workflows.},
author={Kluyver, Thomas and Ragan-Kelley, Benjamin and P{\'e}rez, Fernando and Granger, Brian E and Bussonnier, Matthias and Frederic, Jonathan and Kelley, Kyle and Hamrick, Jessica B and Grout, Jason and Corlay, Sylvain and others},
journal={ELPUB},
pages={87--90},
year={2016}
}
@article{ragan2014jupyter,
title={The Jupyter/IPython architecture: a unified view of computational research, from interactive exploration to communication and publication.},
author={Ragan-Kelley, M and Perez, F and Granger, B and Kluyver, T and Ivanov, P and Frederic, J and Bussonnier, M},
journal={AGU Fall Meeting Abstracts},
year={2014}
}
@article{perez2015project,
title={Project Jupyter: Computational narratives as the engine of collaborative data science},
author={Perez, Fernando and Granger, Brian E},
journal={Retrieved September},
volume={11},
pages={207},
year={2015}
}

Wyświetl plik

@ -1,6 +0,0 @@
<dar>
<documents>
<document id="py.ipynb" name="py.ipynb" type="article" path="py.ipynb.jats.xml" src="py.ipynb" />
</documents>
<assets/>
</dar>

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1,212 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.1d3 20150301//EN" "JATS-archivearticle1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">
<front>
<article-meta>
<title-group>
<article-title>Jupyter and Stencila</article-title>
</title-group>
<contrib-group content-type="author">
<contrib contrib-type="person">
<name>
<surname>Pawlik</surname>
<given-names>Aleksandra</given-names>
</name>
</contrib>
</contrib-group>
<abstract>
<p>An example of a Jupyter notebook converted into a JATS document for editing in Stencila.</p>
</abstract>
</article-meta>
</front>
<body>
<sec id="introduction-1">
<title>Introduction</title>
<p>Jupyter notebooks (<xref ref-type="bibr" rid="ref-1">1</xref>&#x2013;<xref ref-type="bibr" rid="ref-3">3</xref>) are one of the most popular platforms for doing reproducible research. Stencila supports importing of Jupyter Notebook <monospace>.ipynb</monospace> files. This allows you to work with collegues to refine a document for final publication while still retaining the code cells, and thus reprodubility of your the work. In the future we also plan to support exporting to <monospace>.ipynb</monospace> files.</p>
</sec>
<sec id="markdown-cells-1">
<title>Markdown cells</title>
<p>Most standard Markdown should be supported by the importer including inline <monospace>code</monospace>, headings etc (although the Stencila user interface do not currently support rendering of some elements e.g.&#xA0;math and lists).</p>
</sec>
<sec id="code-cells-1">
<title>Code cells</title>
<p>Code cells in notebooks are imported without loss. Stencila&#x2019;s user interface currently differs from Jupyter in that code cells are executed on update while you are typing. This produces a very reactive user experience but is inappropriate for more compute intensive, longer running code cells. We are currently working on improving this to allowing users to decide to execute cells explicitly (e.g.&#xA0;using <monospace>Ctrl+Enter</monospace>).</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="py" executable="yes">import sys
import time
&apos;Hello this is Python %s.%s and it is %s&apos; % (sys.version_info[0], sys.version_info[1], time.strftime(&apos;%c&apos;))</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
<p>Stencila also support Jupyter code cells that produce plots. The cell below produces a simple plot based on the example from <ext-link ext-link-type="uri" xlink:href="https://matplotlib.org/examples/shapes_and_collections/scatter_demo.html">the Matplotlib website</ext-link>. Try changing the code below (for example, the variable <monospace>N</monospace>).</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="py" executable="yes">import numpy as np
import matplotlib.pyplot as plt
N = 50
N = min(N, 1000) # Prevent generation of too many numbers :)
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radii
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
<p>We are currently working on supporting <ext-link ext-link-type="uri" xlink:href="http://ipython.readthedocs.io/en/stable/interactive/magics.html">Jupyter&#x2019;s magic commands</ext-link> in Stencila via a bridge to Jupyter kernels.</p>
</sec>
<sec id="metadata-1">
<title>Metadata</title>
<p>To add some metadata about the document (such as authors, title, abstract and so on), In Jupyter, select <monospace>Edit -&gt; Edit Notebook metadata</monospace> from the top menu. Add the title and abstract as JSON strings and authors and organisations metadata as <ext-link ext-link-type="uri" xlink:href="https://www.w3schools.com/js/js_json_arrays.asp">JSON arrays</ext-link>. Author <monospace>affiliation</monospace> identifiers (like <monospace>university-of-earth</monospace> below) must be unique and preferably use only lowercase characters and no spaces.</p>
<p>For example,</p>
<preformat> &quot;authors&quot;: [
{
&quot;given-names&quot;: &quot;Your first name goes here&quot;,
&quot;surname&quot;: &quot;Your last name goes here&quot;,
&quot;email&quot;: &quot;your.email@your-organisation&quot;,
&quot;corresponding&quot;: &quot;yes / no&quot;,
&quot;affiliation&quot;: &quot;university-of-earth&quot;
}
],
&quot;organisations&quot;: [
{
&quot;university-of-earth&quot;: {
&quot;institution&quot;: &quot;Your organisation name&quot;,
&quot;city&quot;: &quot;Your city&quot;,
&quot;country&quot;: &quot;Your country&quot;
}
],
&quot;title&quot;: &quot;Your title goes here&quot;,
&quot;abstract&quot;: &quot;This is a paper about lots of different interesting things&quot;,
</preformat>
</sec>
<sec id="citations-and-references-1">
<title>Citations and references</title>
<p>Stencila supports Pandoc style citations and reference lists within Jupyter notebook Markdown cells. Add a <monospace>bibliography</monospace> entry to the notebook&#x2019;s metadata which points to a file containing your list of references e.g.</p>
<code language="json">&quot;bibliography&quot;: &quot;my-bibliography.bibtex&quot;</code>
<p>Then, within Markdown cells, you can insert citations inside square brackets and separated by semicolons. Each citation is represented using the <monospace>@</monospace> symbol followed by the citation identifier from the bibliography database e.g.</p>
<code language="json">[@perez2015project; @kluyver2016jupyter]</code>
<p>The <ext-link ext-link-type="uri" xlink:href="https://github.com/takluyver/cite2c">cite2c</ext-link> Jupyter extension allows for easier, &#x201C;cite-while-you-write&#x201D; insertion of citations from a Zotero library. We&#x2019;re hoping to support conversion of cite2cstyle citations/references in the <ext-link ext-link-type="uri" xlink:href="https://github.com/stencila/convert/issues/14">future</ext-link>.</p>
</sec>
</body>
<back>
<ref-list>
<ref id="ref-1">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Perez</surname>
<given-names>Fernando</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>Brian E</given-names>
</name>
</person-group>
<article-title>Project jupyter: Computational narratives as the engine of collaborative data science</article-title>
<source>Retrieved September</source>
<year>2015</year>
<volume>11</volume>
<fpage>207</fpage>
</element-citation>
</ref>
<ref id="ref-2">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Kluyver</surname>
<given-names>Thomas</given-names>
</name>
<name>
<surname>Ragan-Kelley</surname>
<given-names>Benjamin</given-names>
</name>
<name>
<surname>P&#xE9;rez</surname>
<given-names>Fernando</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>Brian E</given-names>
</name>
<name>
<surname>Bussonnier</surname>
<given-names>Matthias</given-names>
</name>
<name>
<surname>Frederic</surname>
<given-names>Jonathan</given-names>
</name>
<name>
<surname>Kelley</surname>
<given-names>Kyle</given-names>
</name>
<name>
<surname>Hamrick</surname>
<given-names>Jessica B</given-names>
</name>
<name>
<surname>Grout</surname>
<given-names>Jason</given-names>
</name>
<name>
<surname>Corlay</surname>
<given-names>Sylvain</given-names>
</name>
<name>
<surname>Others</surname>
</name>
</person-group>
<article-title>Jupyter notebooks-a publishing format for reproducible computational workflows.</article-title>
<source>ELPUB</source>
<year>2016</year>
<fpage>87</fpage>
</element-citation>
</ref>
<ref id="ref-3">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Ragan-Kelley</surname>
<given-names>M</given-names>
</name>
<name>
<surname>Perez</surname>
<given-names>F</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>B</given-names>
</name>
<name>
<surname>Kluyver</surname>
<given-names>T</given-names>
</name>
<name>
<surname>Ivanov</surname>
<given-names>P</given-names>
</name>
<name>
<surname>Frederic</surname>
<given-names>J</given-names>
</name>
<name>
<surname>Bussonnier</surname>
<given-names>M</given-names>
</name>
</person-group>
<article-title>The jupyter/ipython architecture: A unified view of computational research, from interactive exploration to communication and publication.</article-title>
<source>AGU Fall Meeting Abstracts</source>
<year>2014</year>
</element-citation>
</ref>
</ref-list>
</back>
</article>

Wyświetl plik

@ -1,5 +0,0 @@
#!/bin/sh
jupyter serverextension list 2>&1 | grep nbstencilaproxy
jupyter nbextension list 2>&1 | grep nbstencilaproxy
python3 -c "import stencila"

Wyświetl plik

@ -1,21 +0,0 @@
@article{kluyver2016jupyter,
title={Jupyter Notebooks-a publishing format for reproducible computational workflows.},
author={Kluyver, Thomas and Ragan-Kelley, Benjamin and P{\'e}rez, Fernando and Granger, Brian E and Bussonnier, Matthias and Frederic, Jonathan and Kelley, Kyle and Hamrick, Jessica B and Grout, Jason and Corlay, Sylvain and others},
journal={ELPUB},
pages={87--90},
year={2016}
}
@article{ragan2014jupyter,
title={The Jupyter/IPython architecture: a unified view of computational research, from interactive exploration to communication and publication.},
author={Ragan-Kelley, M and Perez, F and Granger, B and Kluyver, T and Ivanov, P and Frederic, J and Bussonnier, M},
journal={AGU Fall Meeting Abstracts},
year={2014}
}
@article{perez2015project,
title={Project Jupyter: Computational narratives as the engine of collaborative data science},
author={Perez, Fernando and Granger, Brian E},
journal={Retrieved September},
volume={11},
pages={207},
year={2015}
}

Wyświetl plik

@ -1,6 +0,0 @@
<dar>
<documents>
<document id="py-jupyter.ipynb" name="py-jupyter.ipynb" type="article" path="py-jupyter.ipynb.jats.xml" src="py-jupyter.ipynb" />
</documents>
<assets/>
</dar>

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -1,212 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.1d3 20150301//EN" "JATS-archivearticle1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">
<front>
<article-meta>
<title-group>
<article-title>Jupyter and Stencila</article-title>
</title-group>
<contrib-group content-type="author">
<contrib contrib-type="person">
<name>
<surname>Pawlik</surname>
<given-names>Aleksandra</given-names>
</name>
</contrib>
</contrib-group>
<abstract>
<p>An example of a Jupyter notebook converted into a JATS document for editing in Stencila.</p>
</abstract>
</article-meta>
</front>
<body>
<sec id="introduction-1">
<title>Introduction</title>
<p>Jupyter notebooks (<xref ref-type="bibr" rid="ref-1">1</xref>&#x2013;<xref ref-type="bibr" rid="ref-3">3</xref>) are one of the most popular platforms for doing reproducible research. Stencila supports importing of Jupyter Notebook <monospace>.ipynb</monospace> files. This allows you to work with collegues to refine a document for final publication while still retaining the code cells, and thus reprodubility of your the work. In the future we also plan to support exporting to <monospace>.ipynb</monospace> files.</p>
</sec>
<sec id="markdown-cells-1">
<title>Markdown cells</title>
<p>Most standard Markdown should be supported by the importer including inline <monospace>code</monospace>, headings etc (although the Stencila user interface do not currently support rendering of some elements e.g.&#xA0;math and lists).</p>
</sec>
<sec id="code-cells-1">
<title>Code cells</title>
<p>Code cells in notebooks are imported without loss. Stencila&#x2019;s user interface currently differs from Jupyter in that code cells are executed on update while you are typing. This produces a very reactive user experience but is inappropriate for more compute intensive, longer running code cells. We are currently working on improving this to allowing users to decide to execute cells explicitly (e.g.&#xA0;using <monospace>Ctrl+Enter</monospace>).</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="pyjp" executable="yes">import sys
import time
&apos;Hello this is Python %s.%s and it is %s&apos; % (sys.version_info[0], sys.version_info[1], time.strftime(&apos;%c&apos;))</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
<p>Stencila also support Jupyter code cells that produce plots. The cell below produces a simple plot based on the example from <ext-link ext-link-type="uri" xlink:href="https://matplotlib.org/examples/shapes_and_collections/scatter_demo.html">the Matplotlib website</ext-link>. Try changing the code below (for example, the variable <monospace>N</monospace>).</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="pyjp" executable="yes">import numpy as np
import matplotlib.pyplot as plt
N = 50
N = min(N, 1000) # Prevent generation of too many numbers :)
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radii
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
<p>We are currently working on supporting <ext-link ext-link-type="uri" xlink:href="http://ipython.readthedocs.io/en/stable/interactive/magics.html">Jupyter&#x2019;s magic commands</ext-link> in Stencila via a bridge to Jupyter kernels.</p>
</sec>
<sec id="metadata-1">
<title>Metadata</title>
<p>To add some metadata about the document (such as authors, title, abstract and so on), In Jupyter, select <monospace>Edit -&gt; Edit Notebook metadata</monospace> from the top menu. Add the title and abstract as JSON strings and authors and organisations metadata as <ext-link ext-link-type="uri" xlink:href="https://www.w3schools.com/js/js_json_arrays.asp">JSON arrays</ext-link>. Author <monospace>affiliation</monospace> identifiers (like <monospace>university-of-earth</monospace> below) must be unique and preferably use only lowercase characters and no spaces.</p>
<p>For example,</p>
<preformat> &quot;authors&quot;: [
{
&quot;given-names&quot;: &quot;Your first name goes here&quot;,
&quot;surname&quot;: &quot;Your last name goes here&quot;,
&quot;email&quot;: &quot;your.email@your-organisation&quot;,
&quot;corresponding&quot;: &quot;yes / no&quot;,
&quot;affiliation&quot;: &quot;university-of-earth&quot;
}
],
&quot;organisations&quot;: [
{
&quot;university-of-earth&quot;: {
&quot;institution&quot;: &quot;Your organisation name&quot;,
&quot;city&quot;: &quot;Your city&quot;,
&quot;country&quot;: &quot;Your country&quot;
}
],
&quot;title&quot;: &quot;Your title goes here&quot;,
&quot;abstract&quot;: &quot;This is a paper about lots of different interesting things&quot;,
</preformat>
</sec>
<sec id="citations-and-references-1">
<title>Citations and references</title>
<p>Stencila supports Pandoc style citations and reference lists within Jupyter notebook Markdown cells. Add a <monospace>bibliography</monospace> entry to the notebook&#x2019;s metadata which points to a file containing your list of references e.g.</p>
<code language="json">&quot;bibliography&quot;: &quot;my-bibliography.bibtex&quot;</code>
<p>Then, within Markdown cells, you can insert citations inside square brackets and separated by semicolons. Each citation is represented using the <monospace>@</monospace> symbol followed by the citation identifier from the bibliography database e.g.</p>
<code language="json">[@perez2015project; @kluyver2016jupyter]</code>
<p>The <ext-link ext-link-type="uri" xlink:href="https://github.com/takluyver/cite2c">cite2c</ext-link> Jupyter extension allows for easier, &#x201C;cite-while-you-write&#x201D; insertion of citations from a Zotero library. We&#x2019;re hoping to support conversion of cite2cstyle citations/references in the <ext-link ext-link-type="uri" xlink:href="https://github.com/stencila/convert/issues/14">future</ext-link>.</p>
</sec>
</body>
<back>
<ref-list>
<ref id="ref-1">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Perez</surname>
<given-names>Fernando</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>Brian E</given-names>
</name>
</person-group>
<article-title>Project jupyter: Computational narratives as the engine of collaborative data science</article-title>
<source>Retrieved September</source>
<year>2015</year>
<volume>11</volume>
<fpage>207</fpage>
</element-citation>
</ref>
<ref id="ref-2">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Kluyver</surname>
<given-names>Thomas</given-names>
</name>
<name>
<surname>Ragan-Kelley</surname>
<given-names>Benjamin</given-names>
</name>
<name>
<surname>P&#xE9;rez</surname>
<given-names>Fernando</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>Brian E</given-names>
</name>
<name>
<surname>Bussonnier</surname>
<given-names>Matthias</given-names>
</name>
<name>
<surname>Frederic</surname>
<given-names>Jonathan</given-names>
</name>
<name>
<surname>Kelley</surname>
<given-names>Kyle</given-names>
</name>
<name>
<surname>Hamrick</surname>
<given-names>Jessica B</given-names>
</name>
<name>
<surname>Grout</surname>
<given-names>Jason</given-names>
</name>
<name>
<surname>Corlay</surname>
<given-names>Sylvain</given-names>
</name>
<name>
<surname>Others</surname>
</name>
</person-group>
<article-title>Jupyter notebooks-a publishing format for reproducible computational workflows.</article-title>
<source>ELPUB</source>
<year>2016</year>
<fpage>87</fpage>
</element-citation>
</ref>
<ref id="ref-3">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Ragan-Kelley</surname>
<given-names>M</given-names>
</name>
<name>
<surname>Perez</surname>
<given-names>F</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>B</given-names>
</name>
<name>
<surname>Kluyver</surname>
<given-names>T</given-names>
</name>
<name>
<surname>Ivanov</surname>
<given-names>P</given-names>
</name>
<name>
<surname>Frederic</surname>
<given-names>J</given-names>
</name>
<name>
<surname>Bussonnier</surname>
<given-names>M</given-names>
</name>
</person-group>
<article-title>The jupyter/ipython architecture: A unified view of computational research, from interactive exploration to communication and publication.</article-title>
<source>AGU Fall Meeting Abstracts</source>
<year>2014</year>
</element-citation>
</ref>
</ref-list>
</back>
</article>

Wyświetl plik

@ -1,5 +0,0 @@
#!/bin/sh
jupyter serverextension list 2>&1 | grep nbstencilaproxy
jupyter nbextension list 2>&1 | grep nbstencilaproxy
python3 -c "import stencila" 2>&1 | grep ModuleNotFoundError

Wyświetl plik

@ -1,13 +0,0 @@
@article{baumer2014r,
title={R Markdown: Integrating a reproducible analysis tool into introductory statistics},
author={Baumer, Ben and Cetinkaya-Rundel, Mine and Bray, Andrew and Loi, Linda and Horton, Nicholas J},
journal={arXiv preprint arXiv:1402.1894},
year={2014}
}
@book{xie2016bookdown,
title={Bookdown: Authoring Books and Technical Documents with R Markdown},
author={Xie, Yihui},
year={2016},
publisher={CRC Press}
}

Wyświetl plik

@ -1,6 +0,0 @@
<dar>
<documents>
<document id="rmarkdown.Rmd" name="rmarkdown.Rmd" type="article" path="rmarkdown.Rmd.jats.xml" src="rmarkdown.Rmd" />
</documents>
<assets/>
</dar>

Wyświetl plik

@ -1,57 +0,0 @@
---
title: RMarkdown and Stencila
author:
- surname: Bentley
given-names: Nokome
affiliation: stencila
- surname: Pawlik
given-names: Aleksandra
- surname: Aufrieter
given-names: Michael
affiliation: substance
- surname: Buchtala
given-names: Oliver
affiliation: substance
organisations:
- id: stencila
name: Stencila
city: Kaikoura
country: New Zealand
- id: substance
name: Substance GmbH
city: Linz
country: Austria
abstract: |
Stencila currently supports import of RMarkdown documents. This allows use cases like allowing collaborators to work on the same document using a WYSIWYG editing environment, or for you to put the final touches on a paper before final submission to a journal.
bibliography: bibliography.bibtex
---
# Introduction
[RMarkdown](https://rmarkdown.rstudio.com/) is a popular format for reproducible research using the R programming language ([@baumer2014r],[@xie2016bookdown]). Stencila is a able to import RMarkdown documents. For example, the source for this example document is available on [Github](https://github.com/stencila/stencila/blob/more-examples/data/r-markdown/rmarkdown.Rmd). Eventually, we'll also support exporting to RMarkdown, allowing WYSIWYG editing of RMarkdown documents in Stencila.
# Code chunks
In RMarkdown, code "chunks" are written using "fenced" code blocks. Stencila converts these code "chunks" into Stencila code "cells" like this one:
```{r}
n <- 500
```
Stencila cells behave like functions having zero or more named `inputs` (like function arguments) and an optional `output` (like a assigning a function's return value). A cell's inputs and outputs are determined by analyzing the cell's code. The cell above has no inputs but produces an output variable named `n`. Stencila's execution engine uses this information to make code cells reactive. For instance, the cell below has `n` as an input i.e it is dependent on the first cell. So when you update the `n` in the cell above, the following plot will update.
```{r}
s <- min(1000, n)
x <- runif(s)
y <- x + runif(s)
z <- y + rnorm(s)
plot(x, y, cex=z*2, col=rainbow(length(z), alpha=0.5)[rank(x+z)], pch=16)
```
# Figures
In RMarkdown, code chunks can have various options. A common use for options is to set the caption and dimensions of figures. Stencila converts code chunks with the `fig.cap` option into JATS `<fig fig-type="repro-fig">` elements with a `<caption>`. This allows the user to edit the figure caption and for automatic figure numbering and referencing (although that is not working 100% right now). Other options are placed in a comment at the top of the cell so that they are preserved (and eventually will be used to apply those options within the R execution context).
```{r fig.width=7,fig.height=6,fig.cap="Figure title"}
hist(z, breaks=40, col=hsv(0.6, 0.9, 1), xlab="Value", main="")
```

Wyświetl plik

@ -1,141 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.1d3 20150301//EN" "JATS-archivearticle1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">
<front>
<article-meta>
<title-group>
<article-title>RMarkdown and Stencila</article-title>
</title-group>
<contrib-group content-type="author">
<contrib contrib-type="person">
<name>
<surname>Bentley</surname>
<given-names>Nokome</given-names>
</name>
<xref ref-type="aff" rid="stencila" />
</contrib>
<contrib contrib-type="person">
<name>
<surname>Pawlik</surname>
<given-names>Aleksandra</given-names>
</name>
</contrib>
<contrib contrib-type="person">
<name>
<surname>Aufrieter</surname>
<given-names>Michael</given-names>
</name>
<xref ref-type="aff" rid="substance" />
</contrib>
<contrib contrib-type="person">
<name>
<surname>Buchtala</surname>
<given-names>Oliver</given-names>
</name>
<xref ref-type="aff" rid="substance" />
</contrib>
</contrib-group>
<aff id="stencila">
<institution content-type="orgname">Stencila</institution>
<city>Kaikoura</city>
<country>New Zealand</country>
</aff>
<aff id="substance">
<institution content-type="orgname">Substance GmbH</institution>
<city>Linz</city>
<country>Austria</country>
</aff>
<abstract>
<p>Stencila currently supports import of RMarkdown documents. This allows use cases like allowing collaborators to work on the same document using a WYSIWYG editing environment, or for you to put the final touches on a paper before final submission to a journal.</p>
</abstract>
</article-meta>
</front>
<body>
<sec id="introduction-1">
<title>Introduction</title>
<p><ext-link ext-link-type="uri" xlink:href="https://rmarkdown.rstudio.com/">RMarkdown</ext-link> is a popular format for reproducible research using the R programming language (<xref ref-type="bibr" rid="ref-1">1</xref>,<xref ref-type="bibr" rid="ref-2">2</xref>). Stencila is a able to import RMarkdown documents. For example, the source for this example document is available on <ext-link ext-link-type="uri" xlink:href="https://github.com/stencila/stencila/blob/more-examples/data/r-markdown/rmarkdown.Rmd">Github</ext-link>. Eventually, we&#x2019;ll also support exporting to RMarkdown, allowing WYSIWYG editing of RMarkdown documents in Stencila.</p>
</sec>
<sec id="code-chunks-1">
<title>Code chunks</title>
<p>In RMarkdown, code &#x201C;chunks&#x201D; are written using &#x201C;fenced&#x201D; code blocks. Stencila converts these code &#x201C;chunks&#x201D; into Stencila code &#x201C;cells&#x201D; like this one:</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="r" executable="yes">n &lt;- 500</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
<p>Stencila cells behave like functions having zero or more named <monospace>inputs</monospace> (like function arguments) and an optional <monospace>output</monospace> (like a assigning a function&#x2019;s return value). A cell&#x2019;s inputs and outputs are determined by analyzing the cell&#x2019;s code. The cell above has no inputs but produces an output variable named <monospace>n</monospace>. Stencila&#x2019;s execution engine uses this information to make code cells reactive. For instance, the cell below has <monospace>n</monospace> as an input i.e it is dependent on the first cell. So when you update the <monospace>n</monospace> in the cell above, the following plot will update.</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="r" executable="yes">s &lt;- min(1000, n)
x &lt;- runif(s)
y &lt;- x + runif(s)
z &lt;- y + rnorm(s)
plot(x, y, cex=z*2, col=rainbow(length(z), alpha=0.5)[rank(x+z)], pch=16)</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
</sec>
<sec id="figures-1">
<title>Figures</title>
<p>In RMarkdown, code chunks can have various options. A common use for options is to set the caption and dimensions of figures. Stencila converts code chunks with the <monospace>fig.cap</monospace> option into JATS <monospace>&lt;fig fig-type=&quot;repro-fig&quot;&gt;</monospace> elements with a <monospace>&lt;caption&gt;</monospace>. This allows the user to edit the figure caption and for automatic figure numbering and referencing (although that is not working 100% right now). Other options are placed in a comment at the top of the cell so that they are preserved (and eventually will be used to apply those options within the R execution context).</p>
<fig fig-type="repro-fig">
<caption>
<title>Figure title</title>
</caption>
<alternatives>
<code specific-use="source" language="r" executable="yes">#: fig.width=7,fig.height=6
hist(z, breaks=40, col=hsv(0.6, 0.9, 1), xlab=&quot;Value&quot;, main=&quot;&quot;)</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</fig>
</sec>
</body>
<back>
<ref-list>
<ref id="ref-1">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Baumer</surname>
<given-names>Ben</given-names>
</name>
<name>
<surname>Cetinkaya-Rundel</surname>
<given-names>Mine</given-names>
</name>
<name>
<surname>Bray</surname>
<given-names>Andrew</given-names>
</name>
<name>
<surname>Loi</surname>
<given-names>Linda</given-names>
</name>
<name>
<surname>Horton</surname>
<given-names>Nicholas J</given-names>
</name>
</person-group>
<article-title>R markdown: Integrating a reproducible analysis tool into introductory statistics</article-title>
<source>arXiv preprint arXiv:1402.1894</source>
<year>2014</year>
</element-citation>
</ref>
<ref id="ref-2">
<element-citation publication-type="book">
<person-group person-group-type="author">
<name>
<surname>Xie</surname>
<given-names>Yihui</given-names>
</name>
</person-group>
<source>Bookdown: Authoring books and technical documents with r markdown</source>
<publisher-name>CRC Press</publisher-name>
<year>2016</year>
</element-citation>
</ref>
</ref-list>
</back>
</article>

Wyświetl plik

@ -1,6 +0,0 @@
#!/bin/sh
jupyter serverextension list 2>&1 | grep nbstencilaproxy
jupyter nbextension list 2>&1 | grep nbstencilaproxy
python3 -c "import stencila" 2>&1 | grep ModuleNotFoundError
R -e "library('stencila');"