Skip to content

Commit

Permalink
embed PV in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
biasmv committed Jun 27, 2015
1 parent 0cb165b commit 0573281
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
12 changes: 12 additions & 0 deletions doc/_static/bio-pv.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
html_static_path = [ '_static' ]

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down
12 changes: 9 additions & 3 deletions doc/ext/pvsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from sphinx.util.compat import make_admonition
from sphinx.util.nodes import set_source_info
from sphinx.locale import _
import os

class PVSample(nodes.Admonition, nodes.Element):
pass

RAW_CODE_PRELUDE='''
<script type='text/javascript' src='/bio-pv.min.js'></script>
<script type='text/javascript' src='%s/bio-pv.min.js'></script>
<style>
#viewer {
Expand All @@ -22,7 +23,7 @@ class PVSample(nodes.Admonition, nodes.Element):
}
#viewer-wrap {
text-align:center;
width: 100%;
width: 100%%;
}
</style>
Expand All @@ -42,8 +43,13 @@ def run(self):

literal = nodes.literal_block(code, code)
literal['language' ] = 'html'
print env.docname
doc_dir = os.path.dirname(env.docname)
relative_static_path = os.path.relpath(env.config.html_static_path[0],
doc_dir)

raw_html_code = nodes.raw(code, RAW_CODE_PRELUDE + code,
prelude = RAW_CODE_PRELUDE % relative_static_path
raw_html_code = nodes.raw(code, prelude + code,
format='html')
set_source_info(self, literal)
set_source_info(self, raw_html_code)
Expand Down
9 changes: 5 additions & 4 deletions doc/samples/ensemble/index.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Display an NMR ensemble
=================================================

In this sample we are going to use the *loadAllModels* option of the PDB parser to load all structures present in a multi-model PDB file. The models are then displayed together in the viewer.
In this sample we are going to use the *loadAllModels* option of the :func:`PDB parser<pv.io.fetchPdb>` to load all structures present in a multi-model PDB file. The models are then displayed together in the viewer using the :func:`cartoon render mode <pv.Viewer.cartoon>`.

.. pv-sample::

<script>
var viewer = pv.Viewer(document.getElementById('viewer'),
{ width : 300, height : 300, antialias : true });

pv.io.fetchPdb('/pdbs/1nmr.pdb', function(structures) {
pv.io.fetchPdb('http://www.rcsb.org/pdb/files/2mjx.pdb', function(structures) {
// put this in the viewerReady block to make sure we don't try to add the
// object before the viewer is ready. In case the viewer is completely
// loaded, the function will be immediately executed.
Expand All @@ -19,8 +19,9 @@ In this sample we are going to use the *loadAllModels* option of the PDB parser
viewer.cartoon('structure_' + (index++), s);
});
// adjust center of view and zoom such that all structures can be seen.
viewer.centerOn(structures[0]);
viewer.setZoom(70);
var rotation = pv.viewpoint.principalAxes(viewer.all()[0]);
viewer.setRotation(rotation)
viewer.autoZoom();
});
}, { loadAllModels : true });
</script>
Expand Down

0 comments on commit 0573281

Please sign in to comment.