diff --git a/docs/plugins/gettingstarted.rst b/docs/plugins/gettingstarted.rst index 96815e42..0c2c0b65 100644 --- a/docs/plugins/gettingstarted.rst +++ b/docs/plugins/gettingstarted.rst @@ -4,11 +4,13 @@ Getting Started =============== Over the course of this little tutorial we'll build a full fledged, installable OctoPrint plugin that displays "Hello World!" -at various places throughout OctoPrint. +at some locations throughout OctoPrint and also offers some other basic functionality to give you an idea of what +you can achieve with OctoPrint's plugin system. We'll start at the most basic form a plugin can take - just a couple of simple lines of Python code: .. code-block:: python + :linenos: # coding=utf-8 from __future__ import absolute_import @@ -37,6 +39,7 @@ Apart from being discovered by OctoPrint, our plugin does nothing yet. We want t .. code-block:: python :emphasize-lines: 4-8,13 + :linenos: # coding=utf-8 from __future__ import absolute_import @@ -100,6 +103,7 @@ Then edit the configuration in the ``setup.py`` file to mirror our own "Hello Wo look something like this: .. code-block:: python + :linenos: plugin_identifier = "helloworld" plugin_name = "OctoPrint-HelloWorld" @@ -137,6 +141,7 @@ Something is still a bit ugly though. Take a look into ``__init__.py`` and ``set of information now defined twice: .. code-block:: python + :linenos: # __init__.py: __plugin_name__ = "Hello World" @@ -153,6 +158,7 @@ within ``setup.py``! So, we don't really need to define all this data twice. Rem and ``__plugin_description__``: .. code-block:: python + :linenos: # coding=utf-8 from __future__ import absolute_import @@ -174,6 +180,7 @@ Our "Hello World" Plugin still gets detected fine, but it's now listed under the .. code-block:: python :emphasize-lines: 10 + :linenos: # coding=utf-8 from __future__ import absolute_import @@ -218,6 +225,7 @@ add the :class:`TemplatePlugin` to our ``HelloWorldPlugin`` class: .. code-block:: python :emphasize-lines: 7 + :linenos: # coding=utf-8 from __future__ import absolute_import @@ -236,6 +244,7 @@ Next, we'll create a sub folder ``templates`` underneath our ``octoprint_hellowo ``helloworld_navbar.jinja2`` like so: .. code-block:: html + :linenos: Hello World! @@ -279,6 +288,7 @@ Let's take a look at how all that would look in our plugin's ``__init__.py``: .. code-block:: python :emphasize-lines: 8, 10, 12-13 + :linenos: # coding=utf-8 from __future__ import absolute_import @@ -312,6 +322,7 @@ Adjust your plugin's ``__init__.py`` like this: .. code-block:: python :emphasize-lines: 15-16 + :linenos: # coding=utf-8 from __future__ import absolute_import @@ -336,6 +347,7 @@ Adjust your plugin's ``__init__.py`` like this: Also adjust your plugin's ``templates/helloworld_navbar.jinja2`` like this: .. code-block:: html + :linenos: Hello World! @@ -372,6 +384,7 @@ So in your plugin's ``templates`` folder create a new file ``helloworld_settings into it: .. code-block:: html + :linenos: