More work on the documentation

This commit is contained in:
Gina Häußge committed 2015-01-16 17:11:31 +01:00
1 parent f619c1f8c4
commit 762ec228da
11 files changed
+526 -217

No files matched your search

+11 -43
View File
@@ -13,6 +13,8 @@ Developing Plugins
This section is still a heavy WIP, so take it with a bit of caution ;)
.. _sec-plugins-developing-structure:
OctoPrint Plugin Structure
==========================
@@ -37,7 +39,7 @@ a couple of properties describing the module:
Method called upon initializing of the plugin by the plugin subsystem, can be used to instantiate
plugin implementations, connecting them to hooks etc.
A very simple example plugin which only hooks into OctoPrint's startup sequence and prints out "Hello World" to stdout would
A very simple example plugin which only hooks into OctoPrint's startup sequence and logs "Oh hello!" would
be the following snippet:
.. code-block:: python
@@ -49,15 +51,17 @@ be the following snippet:
__plugin_name__ = "Example Plugin"
__plugin_version__ = "0.1"
__plugin_description__ = "Prints \"Hello World!\" to stdout upon OctoPrint's startup"
__plugin_description__ = "Logs \"Oh hello!\" upon OctoPrint's startup"
def __plugin_init__():
global __plugin_implementations__
__plugin_implementations__ = [HelloWorldPlugin()]
__plugin_implementations__ = [ExamplePlugin()]
class HelloWorldPlugin(octoprint.plugin.StartupPlugin):
class ExamplePlugin(octoprint.plugin.StartupPlugin):
def on_startup(self, host, port):
print("Hello World!")
self._logger.info("Oh hello!")
.. _sec-plugins-developing-distribution:
Distributing your plugin
========================
@@ -72,43 +76,8 @@ You can distribute a plugin with OctoPrint via two ways:
your plugin's ``setup.py``, this way it will be found automatically by OctoPrint upon initialization of the
plugin subsystem [#f1]_.
In this case you'll have a directory structure like the following:
.. code-block:: none
`-+ helloworld
| `-+ static
| | `-+ css
| | `-- helloworld.css
| | `-+ js
| | `-- helloworld.js
| | `-+ less
| | `-- helloworld.less
| `-+ templates
| | `-- helloworld_settings_dialog.js
| `-- __init__.py
`-- setup.py
The plugin itself will be distributed as a Python package, which your ``setup.py`` will refer to via the entry point
like this:
.. code-block:: python
import setuptools
def params():
name = "OctoPrint-HelloWorld"
version = "0.1"
packages = ["helloworld"]
install_requires = open("requirements.txt").read().split("\n")
entry_points = {
"octoprint.plugin" = ["helloworld = octoprint_helloworld"]
}
return locals()
setuptools.setup(**params())
For an example of how the directory structure and related files would look like in this case, please take a
look at the `helloworld example from OctoPrint's example plugins <https://github.com/OctoPrint/Plugin-Examples/tree/master/helloworld>`_.
This variant is highly recommended for pretty much any plugin besides the most basic ones since it also allows
requirements management and pretty much any thing else that Python's setuptools provide to the developer.
@@ -119,7 +88,6 @@ You can distribute a plugin with OctoPrint via two ways:
environments), so make sure to instruct your users to use the exact same Python installation for installing
the plugin that they also used for installing & running OctoPrint.
.. _sec-plugins-developing-mixins:
Available plugin mixins
+6 -48
View File
@@ -1,60 +1,18 @@
.. _sec-plugins:
#####################
Plugins Documentation
#####################
#######
Plugins
#######
Starting with OctoPrint 1.2.0, there's now a plugin system in place which allows to individually
extend OctoPrint's functionality.
Right now plugins can be used to extend OctoPrint's settings dialog, to execute specific tasks on server startup and
Right now plugins can be used to extend OctoPrint's web interface, to execute specific tasks on server startup and
shutdown, to provide custom (API) endpoints with special functionality, to react on system events or to add support for
additional slicers. More plugin types are planned for the future.
.. _sec-plugins-installation:
Installing Plugins
==================
Plugins can be installed either by unpacking them into one of the configured plugin folders (regularly those are
``<octoprint-root>/plugins`` and ``~/.octoprint/plugins`` or by installing them as regular python modules via ``pip``.
Please refer to the documentation of the plugin for installations instructions.
The latter is the more common case since all currently published plugins not bundled with OctoPrint can and should be installed
this way.
For a plugin available on the Python Package Index (PyPi), the process is as simple as issuing a
.. code-block:: bash
pip install <plugin_name>
For plugins not available on PyPi, you'll have to give ``pip`` an URL from which to install the package (e.g. the URL to
a ZIP file of the current master branch of a Github repository hosting a plugin, or even a ``git+https`` URL), example:
.. code-block:: bash
pip install https://github.com/OctoPrint/OctoPrint-Growl/archive/master.zip
See `the pip install documentation <http://pip.readthedocs.org/en/latest/reference/pip_install.html>`_ for what URL
types are possible.
.. _sec-plugins-available:
Available Plugins
=================
Currently there's no such thing as a centralized plugin repository for available plugins.
Plugins may be found in the lists provided in `the OctoPrint wiki <https://github.com/foosel/OctoPrint/wiki#plugins>`_
and on the `OctoPrint organization Github page <https://github.com/OctoPrint>`_.
Developing Plugins
==================
Please see the following sub topics for information on how to develop your own OctoPrint plugins.
.. toctree::
:maxdepth: 2
:maxdepth: 3
using.rst
developing.rst
+44
View File
@@ -0,0 +1,44 @@
.. _sec-plugins-using:
*************
Using Plugins
*************
.. _sec-plugins-using-available:
Finding Plugins
===============
Currently there's no such thing as a centralized plugin repository for available plugins.
Plugins may be found in the lists provided in `the OctoPrint wiki <https://github.com/foosel/OctoPrint/wiki#plugins>`_
and on the `OctoPrint organization Github page <https://github.com/OctoPrint>`_.
.. _sec-plugins-using-installing:
Installing Plugins
==================
Plugins can be installed either by unpacking them into one of the configured plugin folders (regularly those are
``<octoprint-root>/plugins`` and ``~/.octoprint/plugins`` or by installing them as regular python modules via ``pip``.
Please refer to the documentation of the plugin for installations instructions.
The latter is the more common case since all currently published plugins not bundled with OctoPrint can and should be installed
this way.
For a plugin available on the Python Package Index (PyPi), the process is as simple as issuing a
.. code-block:: bash
pip install <plugin_name>
For plugins not available on PyPi, you'll have to give ``pip`` an URL from which to install the package (e.g. the URL to
a ZIP file of the current master branch of a Github repository hosting a plugin, or even a ``git+https`` URL), example:
.. code-block:: bash
pip install https://github.com/OctoPrint/OctoPrint-Growl/archive/master.zip
See `the pip install documentation <http://pip.readthedocs.org/en/latest/reference/pip_install.html>`_ for what URL
types are possible.