Skip to content

Commit 0e1ef15

Browse files
committed
Further polish CONTRIBUTING.rst
- 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
1 parent 38f05f3 commit 0e1ef15

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

CONTRIBUTING.rst

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ Contributing guidelines
33
***********************
44

55
- `PEP 8`_, when sensible.
6-
- Test ruthlessly. Write docs for new features.
7-
- Make sure any new logic is easy for others to understand.
8-
- If you add an extension to setup.py, add it to supportedextensions.md.
9-
- Please update AUTHORS.rst when you contribute.
6+
- Test-driven: test ruthlessly and write docs for new features.
7+
- Human-driven: make sure any new logic is easy for others to understand.
8+
- If you add an extension to setup.py, add it to ``supportedextensions.md``.
9+
- Please update ``AUTHORS.rst`` when you contribute.
1010

1111
.. _`PEP 8`: http://www.python.org/dev/peps/pep-0008/
1212

@@ -24,13 +24,14 @@ Configure development environment and install the development dependencies.
2424

2525
.. note::
2626
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.
28-
.. _pyenv: https://github.com/pyenv/pyenv
29-
.. _pyenv-virtualenv: https://github.com/pyenv/pyenv-virtualenv
27+
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.
28+
3029
.. _R: https://www.r-project.org/
3130
.. _pspp: https://www.gnu.org/software/pspp/
31+
.. _pyenv: https://github.com/pyenv/pyenv
32+
.. _pyenv-virtualenv: https://github.com/pyenv/pyenv-virtualenv
3233

33-
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.
3435

3536
.. code-block:: bash
3637
@@ -39,23 +40,27 @@ For Mac OS, an example of the commands that might be run to set up MFR. Linux us
3940
$ pip install setuptools==30.4.0
4041
$ pip install invoke==0.13.0
4142
43+
Lastly, install MFR requirements with the development option.
4244

43-
Lastly, install mfr in development mode. ::
45+
.. code-block:: bash
4446
4547
$ inv install -d
4648
$ inv server
4749
4850
Running tests
4951
=============
5052

53+
To run all tests (requires ``pytest``)
5154

52-
To run all tests (requires pytest) ::
55+
.. code-block:: bash
5356
5457
$ inv test
5558
56-
You can also use pytest directly. ::
59+
You can also use ``pytest`` directly.
5760

58-
$ py.test
61+
.. code-block:: bash
62+
63+
$ py.test --cov-report term-missing --cov mfr tests
5964
6065
Writing tests
6166
=============
@@ -88,36 +93,37 @@ Tests should be encapsulated within a class and written as functions. There are
8893
assets_url
8994
).render() == '<p>Rendered file for my_extension</p>'
9095
91-
Check out pytest documentation to learn more about fixtures
92-
93-
.. _pytest fixtures: https://pytest.org/latest/fixture.html
96+
Check out `pytest`_ documentation to learn more about fixtures
9497

98+
.. _pytest fixtures: https://docs.pytest.org/en/latest/fixture.html
99+
.. _pytest: https://docs.pytest.org/en/latest/
95100

96101
Manual Local Testing
97102
====================
98103

99-
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.
101105

102106
Writing an extension
103107
====================
104108

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``.
107110

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.
109112

110113
Rendering Code
111114
--------------
112115

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.
114117

115118
.. code-block:: python
116119
117120
import os
121+
118122
from mako.lookup import TemplateLookup
123+
119124
from mfr.core import extension
120125
126+
121127
class ImageRenderer(extension.BaseRenderer):
122128
123129
TEMPLATE = TemplateLookup(
@@ -136,13 +142,12 @@ Renderers subclass `mfr.core.extension.BaseRenderer`, and implement a render fun
136142
def cache_result(self):
137143
return False
138144
139-
140145
Organization
141146
------------
142147

143148
Each plugin has its own directory. At a minimum, a plugin should include:
144149

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
146151

147152
A typical extension plugin directory structure might look like this:
148153

0 commit comments

Comments
 (0)