You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Update the language/wording
- Fix several typos and improve grammar
- Fix brokend links and add new ones
- Replace single ` with double `` for code pieces in paragragh
@@ -24,13 +24,14 @@ Configure development environment and install the development dependencies.
24
24
25
25
.. note::
26
26
Python 3.5 or greater, `R`_, and `pspp`_ are required.
27
-
Python 3.6 is reccomended. It's recommended that a python version manager such as pyenv is used. Additionally it is recommended that you use a virtual environment during development.
Python 3.6 is reccomended. It's recommended that a python version manager such as `pyenv`_ is used and that you use a virtual environment such as `pyenv-virtualenv`_ during development.
For Mac OS, an example of the commands that might be run to set up MFR. Linux users will probably do the same thing but with a different package manager. If someone wants to update this guide, please do.
34
+
For Mac OS, here is an example of the commands that might be run to set up MFR. Linux users will probably do the same thing but with a different package manager. If someone wants to update this guide, please do.
34
35
35
36
.. code-block:: bash
36
37
@@ -39,23 +40,27 @@ For Mac OS, an example of the commands that might be run to set up MFR. Linux us
39
40
$ pip install setuptools==30.4.0
40
41
$ pip install invoke==0.13.0
41
42
43
+
Lastly, install MFR requirements with the development option.
To make sure a new renderer is functioning properly, it's recommended that you try to render a file of that type locally. The easiest way to do this would be to use the docker-compose files available inside the osf repository to get the MFR running, and then it should be straigtforward to interact with the service using a tool such as postman.
100
-
104
+
To make sure a new renderer is functioning properly, it's recommended that you try to render a file of that type locally. The easiest way to do this would be to use the ``docker-compose`` files available inside the osf repository to get the MFR running, and then it should be straightforward to interact with the service using a tool such as postman. Alternatively, if you are familiar with OSF and its services, you can run full OSF and render files directly with it.
101
105
102
106
Writing an extension
103
107
====================
104
108
105
-
An extension provides a 'renderer' and/or an 'exporter', and is registered in setup.py to allow the plugin to load when it is needed.
106
-
Renderers and exporters sublasses `mfr.core.extension.BaseRenderer` or `mfr.core.extension.BaseExporter` respectively. A renderer takes a file path and some file metadata and returns a string of html that provides a representation of the file. The logic for the rendering happens in a renderer's `render` function. This is an abstrac base class method, and thus is required for the implementation of a rendererer. Similarly, `BaseExporter` has an `export` method. This method should take a file and convert it to the desired output, and create the newly converted file at the `ouput_file_path`.
109
+
An extension provides a 'renderer' and/or an 'exporter', and is registered in setup.py to allow the plugin to load when it is needed. Renderers and exporters subclasses ``mfr.core.extension.BaseRenderer`` or ``mfr.core.extension.BaseExporter`` respectively. A renderer takes a file path and some file metadata and returns a string of HTML that provides a representation of the file. The logic for the rendering happens in a renderer's ``render()`` function. This is an abstract base class method, and thus is required for the implementation of a renderer. Similarly, ``BaseExporter`` has an ``export()`` method. This method should take a file and convert it to the desired output, and create the newly converted file at the ``ouput_file_path``.
107
110
108
-
Renderers have an abstract property `file_required`. This is used to determine if the renderer needs the actual content of the file in order to render it. Renderers also have a property cache_result; this is used to determine whether the ouput of the renderer may be cached to improve future requests for the rendered version of the file.
111
+
Renderers have an abstract property ``file_required``. This is used to determine if the renderer needs the actual content of the file in order to render it. Renderers also have a property ``cache_result``; this is used to determine whether the ouput of the renderer may be cached to improve future requests for the rendered version of the file.
109
112
110
113
Rendering Code
111
114
--------------
112
115
113
-
Renderers subclass `mfr.core.extension.BaseRenderer`, and implement a render function, a `file_required` property, and a `cache_result` property.
116
+
Renderers subclass ``mfr.core.extension.BaseRenderer``, and implement a render function, a ``file_required`` property, and a ``cache_result`` property.
114
117
115
118
.. code-block:: python
116
119
117
120
import os
121
+
118
122
from mako.lookup import TemplateLookup
123
+
119
124
from mfr.core import extension
120
125
126
+
121
127
classImageRenderer(extension.BaseRenderer):
122
128
123
129
TEMPLATE= TemplateLookup(
@@ -136,13 +142,12 @@ Renderers subclass `mfr.core.extension.BaseRenderer`, and implement a render fun
136
142
defcache_result(self):
137
143
returnFalse
138
144
139
-
140
145
Organization
141
146
------------
142
147
143
148
Each plugin has its own directory. At a minimum, a plugin should include:
144
149
145
-
- ``__init__.py``: This should export the `mfr.core.extensions.BaseExporter` and `mfr.core.extensions.BaseRenderer` subclasses provided by the plugin
150
+
- ``__init__.py``: This should export the ``mfr.core.extensions.BaseExporter`` and ``mfr.core.extensions.BaseRenderer`` subclasses provided by the plugin
146
151
147
152
A typical extension plugin directory structure might look like this:
0 commit comments