From bfab83f83f88bf974f6a67d6be21287f1036bc69 Mon Sep 17 00:00:00 2001 From: Logan Jones Date: Mon, 5 Feb 2018 00:24:45 -0500 Subject: [PATCH] Updated documentation. Added sphinx-rtd theme and watchdog for better doc writing. Changed all .md files to .rst files because RTD supports it a little bit better, and mostly just to be consistent. Removed the old docs in place of a more full-featured set of docs. Cleaned up pydoc documentation as some of it didn't look quite right in the new theme. So that is all the changes. --- AUTHORS.rst | 14 ++ CHANGELOG.md | 70 ------- CHANGELOG.rst | 92 ++++++++++ CONTRIBUTING.md | 17 -- CONTRIBUTING.rst | 114 ++++++++++++ README.md | 148 --------------- README.rst | 126 +++++++++++++ brewtils/decorators.py | 20 +- brewtils/log/__init__.py | 2 + brewtils/plugin.py | 55 +++--- brewtils/rest/easy_client.py | 4 +- brewtils/rest/system_client.py | 26 ++- docs/Makefile | 81 +------- docs/authors.rst | 1 + docs/brewtils.log.rst | 10 + docs/brewtils.rest.rst | 38 ++++ docs/brewtils.rst | 94 ++++++++++ docs/changelog.rst | 1 + docs/conf.py | 326 ++++++++++++++------------------- docs/contributing.rst | 1 + docs/index.rst | 21 +-- docs/installation.rst | 51 ++++++ docs/make.bat | 242 ++++++++++++++++++++++++ docs/modules.rst | 7 + docs/readme.rst | 1 + docs/usage.rst | 5 + requirements.in | 2 + requirements.txt | 5 + 28 files changed, 1018 insertions(+), 556 deletions(-) create mode 100644 AUTHORS.rst delete mode 100644 CHANGELOG.md create mode 100644 CHANGELOG.rst delete mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTING.rst delete mode 100644 README.md create mode 100644 README.rst create mode 100644 docs/authors.rst create mode 100644 docs/brewtils.log.rst create mode 100644 docs/brewtils.rest.rst create mode 100644 docs/brewtils.rst create mode 100644 docs/changelog.rst mode change 100644 => 100755 docs/conf.py create mode 100644 docs/contributing.rst create mode 100644 docs/installation.rst create mode 100644 docs/make.bat create mode 100644 docs/modules.rst create mode 100644 docs/readme.rst create mode 100644 docs/usage.rst diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 00000000..7e79c7e8 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,14 @@ +======= +Credits +======= + +Development Leads +----------------- + +* Logan Asher Jones +* Matt Patrick + +Contributors +------------ + +None yet. Why not be the first? diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 034b2e15..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,70 +0,0 @@ -# CHANGELOG - -## 2.3.0 -Date: 1/26/18 -#### Added Features -- Added methods for interacting with the Queue API to RestClient and EasyClient -- Clients and Plugins can now be configured to skip server certificate verification when making HTTPS requests -- Timestamps now have true millisecond precision on platforms that support it -- Added `form_input_type` to Parameter model -- Plugins can now be stopped correctly by calling their `_stop` method -- Added Event model - -#### Bug Fixes -- Plugins now additionally look for `ca_cert` and `client_cert` in `BG_CA_CERT` and `BG_CLIENT_CERT` - -#### Other Changes -- Better data integrity by only allowing certain Request status transitions - -## 2.2.1 -1/11/18 -#### Bug Fixes -- Nested requests that reference a different beer-garden no longer fail - -## 2.2.0 -10/23/17 -#### Added Features -- Command descriptions can now be changed without updating the System version -- Standardized Remote Plugin logging configuration -- Added domain-specific language for dynamic choices configuration -- Added `metadata` field to Instance model - -#### Bug Fixes -- Removed some default values from model `__init__` functions -- System descriptors (description, display name, icon name, metadata) now always updated during startup -- Requests with output type 'JSON' will now have JSON error messages - -#### Other changes -- Added license file - -## 2.1.1 -8/25/17 -#### Added Features -- Added `updated_at` field to `Request` model -- `SystemClient` now allows specifying a `client_cert` -- `RestClient` now reuses the same session for subsequent connections -- `SystemClient` can now make non-blocking requests -- `RestClient` and `EasyClient` now support PATCHing a `System` - -#### Deprecations / Removals -- `multithreaded` argument to `PluginBase` has been superseded by `max_concurrent` -- These decorators are now deprecated - - `@command_registrar`, instead use `@system` - - `@plugin_param`, instead use `@parameter` - - `@register`, instead use `@command` -- These classes are now deprecated - - `BrewmasterSchemaParser`, instead use `SchemaParser` - - `BrewmasterRestClient`, instead use `RestClient` - - `BrewmasterEasyClient`, instead use `EasyClient` - - `BrewmasterSystemClient`, instead use `SystemClient` - -#### Bug fixes -- Reworked message processing to remove the possibility of a failed request being stuck in 'IN_PROGRESS' -- Correctly handle custom form definitions with a top-level array -- Smarter reconnect logic when the RabbitMQ connection fails - -#### Other changes -- Removed dependency on `pyopenssl` so there's need to compile any Python extensions -- Request processing now occurs inside of a `ThreadPoolExecutor` thread -- Better serialization handling for epoch fields - diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 00000000..9edc7423 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,92 @@ +Brewtils Changelog +================== + +2.3.0 +----- +Date: 1/26/18 + +New Features +^^^^^^^^^^^^ +- Added methods for interacting with the Queue API to RestClient and EasyClient +- Clients and Plugins can now be configured to skip server certificate verification when making HTTPS requests +- Timestamps now have true millisecond precision on platforms that support it +- Added ``form_input_type`` to Parameter model +- Plugins can now be stopped correctly by calling their ``_stop`` method +- Added Event model + +Bug Fixes +^^^^^^^^^ +- Plugins now additionally look for ``ca_cert`` and ``client_cert`` in ``BG_CA_CERT`` and ``BG_CLIENT_CERT`` + +Other Changes +^^^^^^^^^^^^^ +- Better data integrity by only allowing certain Request status transitions + +2.2.1 +----- +Date: 1/11/18 + +Bug Fixes +^^^^^^^^^ +- Nested requests that reference a different beer-garden no longer fail + +2.2.0 +----- +Date: 10/23/17 + +New Features +^^^^^^^^^^^^ + +- Command descriptions can now be changed without updating the System version +- Standardized Remote Plugin logging configuration +- Added domain-specific language for dynamic choices configuration +- Added ``metadata`` field to Instance model + +Bug Fixes +^^^^^^^^^ +- Removed some default values from model ``__init__`` functions +- System descriptors (description, display name, icon name, metadata) now always updated during startup +- Requests with output type 'JSON' will now have JSON error messages + +Other changes +^^^^^^^^^^^^^ +- Added license file + +2.1.1 +----- +Date: 8/25/17 + +New Features +^^^^^^^^^^^^ + +- Added ``updated_at`` field to ``Request`` model +- ``SystemClient`` now allows specifying a ``client_cert`` +- ``RestClient`` now reuses the same session for subsequent connections +- ``SystemClient`` can now make non-blocking requests +- ``RestClient`` and ``EasyClient`` now support PATCHing a ``System`` + +Deprecations / Removals +^^^^^^^^^^^^^^^^^^^^^^^ +- ``multithreaded`` argument to ``PluginBase`` has been superseded by ``max_concurrent`` +- These decorators are now deprecated + - ``@command_registrar``, instead use ``@system`` + - ``@plugin_param``, instead use ``@parameter`` + - ``@register``, instead use ``@command`` +- These classes are now deprecated + - ``BrewmasterSchemaParser``, instead use ``SchemaParser`` + - ``BrewmasterRestClient``, instead use ``RestClient`` + - ``BrewmasterEasyClient``, instead use ``EasyClient`` + - ``BrewmasterSystemClient``, instead use ``SystemClient`` + +Bug Fixes +^^^^^^^^^ +- Reworked message processing to remove the possibility of a failed request being stuck in ``IN_PROGRESS`` +- Correctly handle custom form definitions with a top-level array +- Smarter reconnect logic when the RabbitMQ connection fails + +Other changes +^^^^^^^^^^^^^ +- Removed dependency on ``pyopenssl`` so there's need to compile any Python extensions +- Request processing now occurs inside of a ``ThreadPoolExecutor`` thread +- Better serialization handling for epoch fields + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 83484d9e..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,17 +0,0 @@ -Contributing to the Bindings -========= - -Since many people have many different uses for Beergarden, it makes sense that you may need functionality that's not currently supported. If that's the case, and you think you can add the functionality yourself, feel free! Here's the easiest way to make changes: - -1. Clone or fork the project (`git clone git@github.com:beer-garden/brewtils.git`) -2. Create a new branch (`git checkout -b my_amazing_feature`) -3. Commit your changes (`git commit -m "It's done!"`) -4. Push to the branch (`git push origin my_amazing_feature`) -5. Create a new Merge Request in GitHub (https://github.com/beer-garden/brewtils/merge_requests/new) - -We want to do everything we can to make sure we're delivering robust software. So we just ask that before submitting a merge request you: - -1. Make sure all the existing tests work (`nosetests` for the Python bindings) -2. Create new tests for the functionality you've created. These should work too :) - -Finally, __thank you for your contribution!__ Your help is very much appreciated by the Beergarden developers and users. diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 00000000..65575d6e --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,114 @@ +.. highlight:: shell + +============ +Contributing +============ + +Contributions are welcome, and they are greatly appreciated! Every +little bit helps, and credit will always be given. + +You can contribute in many ways: + +Types of Contributions +---------------------- + +Report Bugs +~~~~~~~~~~~ + +Report bugs at https://github.com/beer-garden/brewtils/issues. + +If you are reporting a bug, please include: + +* Your operating system name and version. +* Any details about your local setup that might be helpful in troubleshooting. +* Detailed steps to reproduce the bug. + +Fix Bugs +~~~~~~~~ + +Look through the GitHub issues for bugs. Anything tagged with "bug" +and "help wanted" is open to whoever wants to implement it. + +Implement Features +~~~~~~~~~~~~~~~~~~ + +Look through the GitHub issues for features. Anything tagged with "enhancement" +and "help wanted" is open to whoever wants to implement it. + +Write Documentation +~~~~~~~~~~~~~~~~~~~ + +Brewtils could always use more documentation, whether as part of the +official Brewtils docs, in docstrings, or even on the web in blog posts, +articles, and such. + +Submit Feedback +~~~~~~~~~~~~~~~ + +The best way to send feedback is to file an issue at https://github.com/beer-garden/brewtils/issues. + +If you are proposing a feature: + +* Explain in detail how it would work. +* Keep the scope as narrow as possible, to make it easier to implement. +* Remember that this is a volunteer-driven project, and that contributions + are welcome :) + +Get Started! +------------ + +Ready to contribute? Here's how to set up ``brewtils`` for local development. + +1. Fork the ``brewtils`` repo on GitHub. +2. Clone your fork locally:: + + $ git clone git@github.com:your_name_here/brewtils.git + +3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: + + $ mkvirtualenv brewtils + $ cd brewtils/ + $ python setup.py develop + +4. Create a branch for local development:: + + $ git checkout -b name-of-your-bugfix-or-feature + + Now you can make your changes locally. + +5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: + + $ flake8 brewtils test + $ nosetests + $ tox + + To get flake8 and tox, just pip install them into your virtualenv. + +6. Commit your changes and push your branch to GitHub:: + + $ git add . + $ git commit -m "Your detailed description of your changes." + $ git push origin name-of-your-bugfix-or-feature + +7. Submit a pull request through the GitHub website. + +Pull Request Guidelines +----------------------- + +Before you submit a pull request, check that it meets these guidelines: + +1. The pull request should include tests. +2. If the pull request adds functionality, the docs should be updated. Put + your new functionality into a function with a docstring, and add the + feature to the list in README.rst. +3. The pull request should work for Python 2.7, 3.5, and 3.6. Check + https://travis-ci.org/beer-garden/brewtils/pull_requests + and make sure that the tests pass for all supported Python versions. + +Tips +---- + +To run a subset of tests:: + +$ nosetests test/models_test.py:SystemTest.test_instance_names + diff --git a/README.md b/README.md deleted file mode 100644 index b7baed70..00000000 --- a/README.md +++ /dev/null @@ -1,148 +0,0 @@ -Brewtils -========= - -Brewtils is the Python library for interfacing with Beergarden systems. It provides simple ways to query information, access systems, generate requests, and more. - -## Installation -Brewtils lives on PyPI. You can install it via: - - pip install brewtils - -If you already have a requirements definition file you can add brewtils like this: - - brewtils - -And then install with pip as normal. - -## Usage - -There are three major ways to use `brewtils`. A brief summary of each is given below so you can determine which best fits your use-case. - - -### Remote Plugin Decorators - -The `decorators` module helps you create your own remote plugin. Suppose you have the following class: - -```python -Class MyClient(object): - - def do_something(self): - print("Hello, World!") - return "Hello, World!" - - def echo_message(self, message): - print(message) - return message -``` - -There are two steps for making this class into a Beergarden plugin. First, you'll need to decorate your class and methods: - -```python -from brewtils.decorators import system, parameter, command - -@system -Class MyClient(object): - - @command - def do_something(self): - print("Hello, World!") - return "Hello, World!" - - @parameter(key="message", description="The message to echo", type="String") - def echo_message(self, message): - print(message) - return message -``` - -The `@system` tells us that the `MyClient` class is going to be a Beergarden plugin. - -The `@command` tells us that `do_something` is going to be a command. - -The `@parameter` tells us information about the parameters to the `echo_message` method. - -Now that we've decorated the client definition we just need to point the remote plugin at a Beergarden and start it. We can do that like this: - -```python -from brewtils.plugin import RemotePlugin - -#...MyClient definition... - -def main(): - client = MyClient() - plugin = RemotePlugin(client, name="My Client", version="0.0.1", bg_host='127.0.0.1', bg_port=2337) - plugin.run() - -if __name__ == "__main__": - main() -``` - -Assuming you have a Beergarden running on port 2337 on localhost, running this will register and start your plugin. - - -### System Client - -The `SystemClient` is designed to help you interact with registered Systems as if they were native Python objects. Suppose the following System has been registered with Beergarden: - - System: - Name: foo - Version: 0.0.1 - Commands: - do_something1 - Params: - key1 - key2 - - do_something2 - Params: - key3 - key4 - -That is, we have a System named "foo" with two possible commands: `do_something1` and `do_something2`, each of which takes 2 parameters (key1-4). - -Now suppose we want to exercise `do_something1` and inspect the result. The `SystemClient` makes this trivial: - -```python -from brewtils.rest.system_client import SystemClient - -foo_client = SystemClient('localhost', 2337, 'foo') - -request = foo_client.do_something1(key1="k1", key2="k2") - -print(request.status) # 'SUCCESS' -print(request.output) # do_something1 output -``` -When you call `do_something1` on the `SystemClient` object it will make a REST call to Beergarden to generate a Request. It will then block until that request has completed, at which point the returned object can be queried the same way as any other Request object. - -If the system you are using has multiple instances, you can specify the default instance to use: - -```python -foo_client = SystemClient('localhost', 2337, 'foo', default_instance="01") - -foo_client.do_something1(key1="k1", key2="k2") # Will set instance_name to '01' -``` - -If you want to operate on multiple instances of the same system, you can specify the instance name each time: - -```python -foo_client = SystemClient('localhost', 2337, 'foo') -request = foo_client.do_something1(key1="k1", key2="k2", _instance_name="01") # Will set instance_name to '01' -``` - -Notice the leading `_` in the `_instance_name` keyword argument. This is necessary to distinguish command arguments (things to pass to `do_something1`) from Beergarden arguments. In general, you should try to avoid naming parameters with a leading underscore to avoid name collisions. - -### Easy Client - -The `EasyClient` is intended to make it easy to directly query Beergarden. Suppose the same `foo` System as above has been registered in Beergarden. We can use the `EasyClient` to gather information: - -```python -from brewtils.rest.easy_client import EasyClient - -client = EasyClient('localhost', 2337) - -foo_system = client.find_unique_system(name='foo', version='0.0.1') - -for command in foo_system.commands: - print(command.name) -``` - -The `EasyClient` is full of helpful commands so feel free to explore all the methods that are exposed. diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..9301d11d --- /dev/null +++ b/README.rst @@ -0,0 +1,126 @@ +Brewtils +======== + +.. image:: https://img.shields.io/pypi/v/brewtils.svg + :target: https://pypi.python.org/pypi/brewtils + +.. image:: https://img.shields.io/travis/loganasherjones/yapconf.svg + :target: https://travis-ci.org/beer-garden/brewtils?branch=master + +.. image:: https://codecov.io/gh/beer-garden/brewtils/branch/master/graph/badge.svg + :target: https://codecov.io/gh/beer-garden/brewtils + +.. image:: https://readthedocs.org/projects/brewtils/badge/?version=latest + :target: https://brewtils.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +.. image:: https://pyup.io/repos/github/beer-garden/brewtils/shield.svg + :target: https://pyup.io/repos/github/beer-garden/brewtils/ + :alt: Updates + + +Brewtils is the Python library for interfacing with Beergarden systems. If you are planning on +writing beer-garden plugins, this is the correct library for you. In addition to writing plugins, +it provides simple ways to query the API and is officially supported by the beer-garden team. + +Features +-------- +Brewtils helps you interact with beer-garden. + +* Easy way to create beer-garden plugins +* Full support of the entire Beer-Garden API +* Officially supported by the beer-garden team + +Installation +------------ + +To install brewtils, run this command in your terminal: + +.. code-block:: console + + $ pip install brewtils + +Or add it to your ``requirements.txt`` + +.. code-block:: console + + $ cat brewtils >> requirements.txt + $ pip install -r requirements.txt + + +Quick Start +----------- + +You can create your own beer-garden plugins without much problem at all. To start, we'll create +the obligatory hello-world plugin. Creating a plugin is as simple as: + +.. code-block:: python + + from brewtils.decorators import system, parameter, command + from brewtils.plugin import RemotePlugin + + @system + class HelloWorld(object): + + @parameter(key="message", description="The message to echo", type="String") + def say_hello(self, message="World!"): + print("Hello, %s!" % message) + return "Hello, %s!" % message + + if __name__ == "__main__": + client = HelloWorld() + plugin = RemotePlugin(client, + name="hello", + version="0.0.1", + bg_host='127.0.0.1', + bg_port=2337) + plugin.run() + +Assuming you have a Beer Garden running on port 2337 on localhost, running this will register and +start your plugin! You now have your first plugin running in beer-garden. Let's use another part +of the ``brewtils`` library to exercise your plugin from python. + +The ``SystemClient`` is designed to help you interact with registered Systems as if they were native +Python objects. + +.. code-block:: python + + from brewtils.rest.system_client import SystemClient + + hello_client = SystemClient('localhost', 2337, 'hello') + + request = hello_client.say_hello(message="from system client") + + print(request.status) # 'SUCCESS' + print(request.output) # Hello, from system client! + +In the background, the ``SystemClient`` has executed an HTTP POST with the payload required to get +beer-garden to execute your command. The ``SystemClient`` is how most people interact with +beer-garden when they are in the context of python and want to be making requests. + +Of course, the rest of the API is accessible through the ``brewtils`` package. The ``EasyClient`` +provides simple convenient methods to call the API and auto-serialize the responses. Suppose you +want to get a list of all the commands on all systems: + +.. code-block:: python + + from brewtils.rest.easy_client import EasyClient + + client = EasyClient('localhost', 2337) + + systems = client.find_systems() + + for system in systems: + for command in system.commands: + print(command.name) + +This is just a small taste of what is possible with the ``EasyClient``. Feel free to explore all the +methods that are exposed. + +For more detailed information and better walkthroughs, checkout the full documentation! + +Documentation +------------- + +- Full Beer Garden documentation is available at https://beer-garden.io +- Brewtils Documentation is available at https://brewtils.readthedocs.io diff --git a/brewtils/decorators.py b/brewtils/decorators.py index 1560201a..8d503bc8 100644 --- a/brewtils/decorators.py +++ b/brewtils/decorators.py @@ -27,7 +27,7 @@ def system(cls): """Class decorator that marks a class as a beer-garden System - Creates a _commands property on the class that holds all registered commands. + Creates a ``_commands`` property on the class that holds all registered commands. :param cls: The class to decorated :return: The decorated class @@ -50,9 +50,11 @@ def command(_wrapped=None, command_type='ACTION', output_type='STRING', schema=N For example: - @command(output_type='JSON') - def echo_json(self, message): - return message + .. code-block:: python + + @command(output_type='JSON') + def echo_json(self, message): + return message :param _wrapped: The function to decorate. This is handled as a positional argument and shouldn't be explicitly set. @@ -99,12 +101,12 @@ def parameter(_wrapped=None, key=None, type=None, multi=None, display_name=None, This decorator is intended to be used when more specification is desired for a Parameter. - For example: + For example:: - @parameter(key="message", description="Message to echo", optional=True, type="String", - default="Hello, World!") - def echo(self, message): - return message + @parameter(key="message", description="Message to echo", optional=True, type="String", + default="Hello, World!") + def echo(self, message): + return message :param _wrapped: The function to decorate. This is handled as a positional argument and shouldn't be explicitly set. diff --git a/brewtils/log/__init__.py b/brewtils/log/__init__.py index fedcbce5..fb9ad295 100644 --- a/brewtils/log/__init__.py +++ b/brewtils/log/__init__.py @@ -6,6 +6,8 @@ In order to use this, you should simply call ``setup_logger`` in the same file where you initialize your plugin sometime before you initialize your Plugin object. + .. code-block:: python + host = 'localhost' port = 2337 ssl_enabled = False diff --git a/brewtils/plugin.py b/brewtils/plugin.py index 4d250da0..cea4b5b9 100644 --- a/brewtils/plugin.py +++ b/brewtils/plugin.py @@ -29,25 +29,25 @@ class PluginBase(object): and process Requests. To work, a Plugin needs a Client instance - an instance of a class defining which Requests - this plugin can accept and process. The easiest way to define a `Client` is by annotating a - class with the @system decorator. + this plugin can accept and process. The easiest way to define a ``Client`` is by annotating a + class with the ``@system`` decorator. When creating a Plugin you can pass certain keyword arguments to let the Plugin know how to communicate with the beer-garden instance. These are: - - bg_host - - bg_port - - ssl_enabled - - ca_cert - - client_cert - - bg_url_prefix + - ``bg_host`` + - ``bg_port`` + - ``ssl_enabled`` + - ``ca_cert`` + - ``client_cert`` + - ``bg_url_prefix`` A Plugin also needs some identifying data. You can either pass parameters to the Plugin or - pass a fully defined System object (but not both). Note that some fields are optional: + pass a fully defined System object (but not both). Note that some fields are optional:: - PluginBase(name="Test", version="1.0.0", instance_name="default, description="A Test") + PluginBase(name="Test", version="1.0.0", instance_name="default", description="A Test") - or + or:: the_system = System(name="Test", version="1.0.0", @@ -56,26 +56,33 @@ class with the @system decorator. PluginBase(system=the_system) If passing parameters directly note that these fields are required: - - name (Environment variable BG_NAME will be used if not specified) - - version (Environment variable BG_VERSION will be used if not specified) - - instance_name (Environment variable BG_INSTANCE_NAME will be used if not specified. - 'default' will be used if not specified and loading from environment - variable is unsuccessful) + + name + Environment variable ``BG_NAME`` will be used if not specified + + version + Environment variable ``BG_VERSION`` will be used if not specified + + instance_name + Environment variable ``BG_INSTANCE_NAME`` will be used if not specified. 'default' will + be used if not specified and loading from envirornment variable was unsuccessful And these fields are optional: - - description (Will use docstring summary line from Client if not specified) - - icon_name - - metadata - - display_name + + - description (Will use docstring summary line from Client if not specified) + - icon_name + - metadata + - display_name Plugins service requests using a :py:class:`concurrent.futures.ThreadPoolExecutor`. The maximum number of threads available is controlled by the max_concurrent argument (the 'multithreaded' argument has been deprecated). - **WARNING**: The default value for max_concurrent is 1. This means that a Plugin that invokes - a Command on itself in the course of processing a Request will deadlock! If you intend to do - this, please set max_concurrent to a value that makes sense and be aware that Requests are - processed in separate thread contexts! + .. warning:: + The default value for ``max_concurrent`` is 1. This means that a Plugin that invokes + a Command on itself in the course of processing a Request will deadlock! If you intend + to do this, please set ``max_concurrent`` to a value that makes sense and be aware that + Requests are processed in separate thread contexts! :param client: Instance of a class annotated with @system. :param str bg_host: Hostname of a beer-garden. diff --git a/brewtils/rest/easy_client.py b/brewtils/rest/easy_client.py index 5e548a9c..e672bae8 100644 --- a/brewtils/rest/easy_client.py +++ b/brewtils/rest/easy_client.py @@ -42,6 +42,7 @@ def get_version(self, **kwargs): else: self._handle_response_failure(response, default_exc=BrewmasterFetchError) + def find_unique_system(self, **kwargs): """Find a unique system using keyword arguments as search parameters. @@ -209,7 +210,8 @@ def instance_heartbeat(self, instance_id): def find_unique_request(self, **kwargs): """Find a unique request using keyword arguments as search parameters. - *NOTE: If 'id' is present in kwargs then all other parameters will be ignored. + .. note:: + If 'id' is present in kwargs then all other parameters will be ignored. :param kwargs: Search parameters :return: One request instance diff --git a/brewtils/rest/system_client.py b/brewtils/rest/system_client.py index 0744b45a..3ff0f6ce 100644 --- a/brewtils/rest/system_client.py +++ b/brewtils/rest/system_client.py @@ -16,7 +16,7 @@ class SystemClient(object): SystemClient creation: This class is intended to be the main way to create beer-garden requests. Create an instance with beer-garden connection information (optionally including a url_prefix) and - a system name: + a system name:: client = SystemClient(host, port, 'example_system', ssl_enabled=True, url_prefix=None) @@ -46,7 +46,7 @@ class SystemClient(object): before making each request, not just the first. Making a Request: - The standard way to create and send requests is by calling object attributes: + The standard way to create and send requests is by calling object attributes:: request = client.example_command(param_1='example_param') @@ -54,13 +54,15 @@ class SystemClient(object): determined by periodically polling beer-garden to check the Request status. The time between polling requests starts at 0.5s and doubles each time the request has still not completed, up to max_delay. If a timeout was specified and the Request has not completed - within that time a BrewmasterTimeoutError will be raised. + within that time a ``BrewmasterTimeoutError`` will be raised. It is also possible to create the SystemClient in non-blocking mode by specifying blocking=False. In this case the request creation will immediately return a Future and will spawn a separate thread to poll for Request completion. The max_concurrent parameter is used to control the maximum threads available for polling. + .. code-block:: python + # Create a SystemClient with blocking=False client = SystemClient(host, port, 'example_system', ssl_enabled=True, blocking=False) @@ -81,10 +83,12 @@ class SystemClient(object): denote these as intended for beer-garden itself (rather than a parameter to be passed to the Plugin) prepend a leading underscore to the argument name. - Sending to another instance: + Sending to another instance:: + request = client.example_command(_instance_name='instance_2', param_1='example_param') - Request with a comment: + Request with a comment:: + request = client.example_command(_comment='I'm a beer-garden comment!', param_1='example_param') @@ -144,7 +148,8 @@ def create_bg_request(self, command_name, **kwargs): Normally you interact with the SystemClient by accessing attributes, but there could be certain cases where you want to create a request without sending it. - Example: + Example:: + client = SystemClient(host, port, 'system', blocking=False) requests = [] @@ -179,10 +184,11 @@ def create_bg_request(self, command_name, **kwargs): def send_bg_request(self, **kwargs): """Actually create a Request and send it to beer-garden - NOTE: This method is intended for advanced use only, mainly cases where you're using the - SystemClient without a predefined System. It assumes that everything needed to construct - the request is being passed in kwargs. If this doesn't sound like what you want you should - check out create_bg_request. + .. note:: + This method is intended for advanced use only, mainly cases where you're using the + SystemClient without a predefined System. It assumes that everything needed to + construct the request is being passed in kwargs. If this doesn't sound like what you + want you should check out create_bg_request. :param kwargs: All necessary request parameters, including beer-garden internal parameters :raise BrewmasterValidationError: If the Request creation failed validation on the server diff --git a/docs/Makefile b/docs/Makefile index 49e95faa..89e829b8 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,16 +1,16 @@ # Makefile for Sphinx documentation # -# Module name -MODULE_NAME = brewtils - # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build -APIBUILD = sphinx-apidoc -GENERATEDDIR = generated_docs + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 @@ -19,10 +19,8 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -.PHONY: default -default: clean apidocs html +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext -.PHONY: help help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @@ -32,10 +30,8 @@ help: @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" - @echo " applehelp to make an Apple Help Book" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" - @echo " epub3 to make an epub3" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @@ -49,97 +45,64 @@ help: @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" - @echo " coverage to run coverage check of the documentation (if enabled)" - @echo " dummy to check syntax errors of document sources" -.PHONY: clean clean: rm -rf $(BUILDDIR)/* - rm -rf $(GENERATEDDIR)/* - -.PHONY: apidocs -apidocs: - $(APIBUILD) -o $(GENERATEDDIR) ../$(MODULE_NAME) -.PHONY: html html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." -.PHONY: dirhtml dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." -.PHONY: singlehtml singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." -.PHONY: pickle pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." -.PHONY: json json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." -.PHONY: htmlhelp htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." -.PHONY: qthelp qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Brewtils.qhcp" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/yapconf.qhcp" @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Brewtils.qhc" - -.PHONY: applehelp -applehelp: - $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp - @echo - @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." - @echo "N.B. You won't be able to view it unless you put it in" \ - "~/Library/Documentation/Help or install it in your application" \ - "bundle." + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/yapconf.qhc" -.PHONY: devhelp devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/Brewtils" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Brewtils" + @echo "# mkdir -p $$HOME/.local/share/devhelp/yapconf" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/yapconf" @echo "# devhelp" -.PHONY: epub epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." -.PHONY: epub3 -epub3: - $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 - @echo - @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." - -.PHONY: latex latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @@ -147,33 +110,28 @@ latex: @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." -.PHONY: latexpdf latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." -.PHONY: latexpdfja latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." -.PHONY: text text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." -.PHONY: man man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." -.PHONY: texinfo texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @@ -181,58 +139,39 @@ texinfo: @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." -.PHONY: info info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." -.PHONY: gettext gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." -.PHONY: changes changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." -.PHONY: linkcheck linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." -.PHONY: doctest doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." -.PHONY: coverage -coverage: - $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage - @echo "Testing of coverage in the sources finished, look at the " \ - "results in $(BUILDDIR)/coverage/python.txt." - -.PHONY: xml xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." -.PHONY: pseudoxml pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." - -.PHONY: dummy -dummy: - $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy - @echo - @echo "Build finished. Dummy builder generates no files." diff --git a/docs/authors.rst b/docs/authors.rst new file mode 100644 index 00000000..e122f914 --- /dev/null +++ b/docs/authors.rst @@ -0,0 +1 @@ +.. include:: ../AUTHORS.rst diff --git a/docs/brewtils.log.rst b/docs/brewtils.log.rst new file mode 100644 index 00000000..f075ae98 --- /dev/null +++ b/docs/brewtils.log.rst @@ -0,0 +1,10 @@ +brewtils\.log package +===================== + +Module contents +--------------- + +.. automodule:: brewtils.log + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/brewtils.rest.rst b/docs/brewtils.rest.rst new file mode 100644 index 00000000..373ed645 --- /dev/null +++ b/docs/brewtils.rest.rst @@ -0,0 +1,38 @@ +brewtils\.rest package +====================== + +Submodules +---------- + +brewtils\.rest\.client module +----------------------------- + +.. automodule:: brewtils.rest.client + :members: + :undoc-members: + :show-inheritance: + +brewtils\.rest\.easy\_client module +----------------------------------- + +.. automodule:: brewtils.rest.easy_client + :members: + :undoc-members: + :show-inheritance: + +brewtils\.rest\.system\_client module +------------------------------------- + +.. automodule:: brewtils.rest.system_client + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: brewtils.rest + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/brewtils.rst b/docs/brewtils.rst new file mode 100644 index 00000000..5b133c7b --- /dev/null +++ b/docs/brewtils.rst @@ -0,0 +1,94 @@ +brewtils package +================ + +Subpackages +----------- + +.. toctree:: + + brewtils.log + brewtils.rest + +Submodules +---------- + +brewtils\.choices module +------------------------ + +.. automodule:: brewtils.choices + :members: + :undoc-members: + :show-inheritance: + +brewtils\.decorators module +--------------------------- + +.. automodule:: brewtils.decorators + :members: + :undoc-members: + :show-inheritance: + +brewtils\.errors module +----------------------- + +.. automodule:: brewtils.errors + :members: + :undoc-members: + :show-inheritance: + +brewtils\.models module +----------------------- + +.. automodule:: brewtils.models + :members: + :undoc-members: + :show-inheritance: + +brewtils\.plugin module +----------------------- + +.. automodule:: brewtils.plugin + :members: + :undoc-members: + :show-inheritance: + +brewtils\.request\_consumer module +---------------------------------- + +.. automodule:: brewtils.request_consumer + :members: + :undoc-members: + :show-inheritance: + +brewtils\.schema\_parser module +------------------------------- + +.. automodule:: brewtils.schema_parser + :members: + :undoc-members: + :show-inheritance: + +brewtils\.schemas module +------------------------ + +.. automodule:: brewtils.schemas + :members: + :undoc-members: + :show-inheritance: + +brewtils\.stoppable\_thread module +---------------------------------- + +.. automodule:: brewtils.stoppable_thread + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: brewtils + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/changelog.rst b/docs/changelog.rst new file mode 100644 index 00000000..565b0521 --- /dev/null +++ b/docs/changelog.rst @@ -0,0 +1 @@ +.. include:: ../CHANGELOG.rst diff --git a/docs/conf.py b/docs/conf.py old mode 100644 new mode 100755 index 97cf28f3..a12b49cd --- a/docs/conf.py +++ b/docs/conf.py @@ -1,7 +1,8 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- # -# Brewtils documentation build configuration file, created by -# sphinx-quickstart on Wed Sep 7 17:04:53 2016. +# brewtils documentation build configuration file, created by +# sphinx-quickstart on Sun Feb 4 13:14:36 2018. # # This file is execfile()d with the current directory set to its # containing dir. @@ -12,323 +13,264 @@ # All configuration values have a default; values that are commented out # serve to show the default. -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os import sys -sys.path.insert(0, os.path.abspath('../')) +import os + +# If extensions (or modules to document with autodoc) are in another +# directory, add these directories to sys.path here. If the directory is +# relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) -# -- General configuration ------------------------------------------------ +# Get the project root dir, which is the parent dir of this +cwd = os.getcwd() +project_root = os.path.dirname(cwd) + +# Insert the project root dir as the first element in the PYTHONPATH. +# This lets us ensure that the source package is imported, and that its +# version is used. +sys.path.insert(0, project_root) + +import brewtils + +# -- General configuration --------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' +#needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', -] +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', + 'sphinx.ext.napoleon'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] +# The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. -# -# source_encoding = 'utf-8-sig' +#source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Brewtils' -copyright = u'2016, Logan Asher Jones' -author = u'Logan Asher Jones' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -from brewtils import _version -release = _version.__version__ +copyright = u"2018, Logan Asher Jones" +# The version info for the project you're documenting, acts as replacement +# for |version| and |release|, also used in various other places throughout +# the built documents. +# # The short X.Y version. -version = '.'.join(release.split('.')[0:2]) +version = brewtils.__version__ +# The full version, including alpha/beta/rc tags. +release = brewtils.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None +#language = None -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# -# today = '' -# +# There are two options for replacing |today|: either, you set today to +# some non-false value, then it is used: +#today = '' # Else, today_fmt is used as the format for a strftime call. -# -# today_fmt = '%B %d, %Y' +#today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -# This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. -# -# default_role = None +#default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -# -# add_function_parentheses = True +#add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -# -# add_module_names = True +#add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -# -# show_authors = False +#show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False +#modindex_common_prefix = [] -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False +# If true, keep warnings as "system message" paragraphs in the built +# documents. +#keep_warnings = False -# -- Options for HTML output ---------------------------------------------- +# -- Options for HTML output ------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -# -html_theme = 'alabaster' +html_theme = 'sphinx_rtd_theme' -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the +# Theme options are theme-specific and customize the look and feel of a +# theme further. For a list of options available for each theme, see the # documentation. -# -# html_theme_options = {} +#html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] +#html_theme_path = [] -# The name for this set of Sphinx documents. -# " v documentation" by default. -# -# html_title = u'Brewtils v1.0.0' +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None -# A shorter title for the navigation bar. Default is the same as html_title. -# -# html_short_title = None +# A shorter title for the navigation bar. Default is the same as +# html_title. +#html_short_title = None -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# -# html_logo = None +# The name of an image file (relative to this directory) to place at the +# top of the sidebar. +#html_logo = None -# The name of an image file (relative to this directory) to use as a favicon of -# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# -# html_favicon = None +# The name of an image file (within the static path) to use as favicon +# of the docs. This file should be a Windows icon file (.ico) being +# 16x16 or 32x32 pixels large. +#html_favicon = None -# 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". +# 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 = ['_static'] -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# -# html_extra_path = [] - -# If not None, a 'Last updated on:' timestamp is inserted at every page +# If not '', a 'Last updated on:' timestamp is inserted at every page # bottom, using the given strftime format. -# The empty string is equivalent to '%b %d, %Y'. -# -# html_last_updated_fmt = None +#html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -# -# html_use_smartypants = True +#html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -# -# html_sidebars = {} +#html_sidebars = {} -# Additional templates that should be rendered to pages, maps page names to -# template names. -# -# html_additional_pages = {} +# Additional templates that should be rendered to pages, maps page names +# to template names. +#html_additional_pages = {} # If false, no module index is generated. -# -# html_domain_indices = True +#html_domain_indices = True # If false, no index is generated. -# -# html_use_index = True +#html_use_index = True # If true, the index is split into individual pages for each letter. -# -# html_split_index = False +#html_split_index = False # If true, links to the reST sources are added to the pages. -# -# html_show_sourcelink = True +#html_show_sourcelink = True -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# -# html_show_sphinx = True +# If true, "Created using Sphinx" is shown in the HTML footer. +# Default is True. +#html_show_sphinx = True -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# -# html_show_copyright = True +# If true, "(C) Copyright ..." is shown in the HTML footer. +# Default is True. +#html_show_copyright = True -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# -# html_use_opensearch = '' +# If true, an OpenSearch description file will be output, and all pages +# will contain a tag referring to it. The value of this option +# must be the base URL from which the finished HTML is served. +#html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' -# -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# 'ja' uses this config value. -# 'zh' user can custom change `jieba` dictionary path. -# -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# -# html_search_scorer = 'scorer.js' +#html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'Brewtilsdoc' +htmlhelp_basename = 'brewtilsdoc' -# -- Options for LaTeX output --------------------------------------------- -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', +# -- Options for LaTeX output ------------------------------------------ - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). +# (source start file, target name, title, author, documentclass +# [howto/manual]). latex_documents = [ - (master_doc, 'Brewtils.tex', u'Brewtils Documentation', - u'Logan Jones', 'manual'), + ('index', 'brewtils.tex', + u'Brewtils Documentation', + u'Logan Asher Jones', 'manual'), ] -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# -# latex_logo = None +# The name of an image file (relative to this directory) to place at +# the top of the title page. +#latex_logo = None -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# -# latex_use_parts = False +# For "manual" documents, if this is true, then toplevel headings +# are parts, not chapters. +#latex_use_parts = False # If true, show page references after internal links. -# -# latex_show_pagerefs = False +#latex_show_pagerefs = False # If true, show URL addresses after external links. -# -# latex_show_urls = False +#latex_show_urls = False # Documents to append as an appendix to all manuals. -# -# latex_appendices = [] +#latex_appendices = [] # If false, no module index is generated. -# -# latex_domain_indices = True +#latex_domain_indices = True -# -- Options for manual page output --------------------------------------- +# -- Options for manual page output ------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'brewtils', u'Brewtils Documentation', - [author], 1) + ('index', 'brewtils', + u'Brewtils Documentation', + [u'Logan Asher Jones'], 1) ] # If true, show URL addresses after external links. -# -# man_show_urls = False +#man_show_urls = False -# -- Options for Texinfo output ------------------------------------------- +# -- Options for Texinfo output ---------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'Brewtils', u'Brewtils Documentation', - author, 'Brewtils', 'One line description of project.', + ('index', 'brewtils', + u'Brewtils Documentation', + u'Logan Asher Jones', + 'brewtils', + 'Python Bindings for beer-garden', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. -# -# texinfo_appendices = [] +#texinfo_appendices = [] # If false, no module index is generated. -# -# texinfo_domain_indices = True +#texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -# -# texinfo_show_urls = 'footnote' +#texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -# -# texinfo_no_detailmenu = False +#texinfo_no_detailmenu = False diff --git a/docs/contributing.rst b/docs/contributing.rst new file mode 100644 index 00000000..e582053e --- /dev/null +++ b/docs/contributing.rst @@ -0,0 +1 @@ +.. include:: ../CONTRIBUTING.rst diff --git a/docs/index.rst b/docs/index.rst index 6021ab31..c1a5d5db 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,8 +1,3 @@ -.. Brewtils documentation master file, created by - sphinx-quickstart on Wed Sep 7 17:04:53 2016. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - Welcome to Brewtils's documentation! ==================================== @@ -11,12 +6,10 @@ Contents: .. toctree:: :maxdepth: 2 - generated_docs/modules - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - + readme + installation + usage + modules + contributing + authors + changelog diff --git a/docs/installation.rst b/docs/installation.rst new file mode 100644 index 00000000..e45472a1 --- /dev/null +++ b/docs/installation.rst @@ -0,0 +1,51 @@ +.. highlight:: shell + +============ +Installation +============ + + +Stable release +-------------- + +To install Brewtils, run this command in your terminal: + +.. code-block:: console + + $ pip install brewtils + +This is the preferred method to install Brewtils, as it will always install the most recent stable release. + +If you don't have `pip`_ installed, this `Python installation guide`_ can guide +you through the process. + +.. _pip: https://pip.pypa.io +.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ + + +From sources +------------ + +The sources for Brewtils can be downloaded from the `Github repo`_. + +You can either clone the public repository: + +.. code-block:: console + + $ git clone git@github.com/beer-garden/brewtils.git + +Or download the `tarball`_: + +.. code-block:: console + + $ curl -OL https://github.com/beer-garden/brewtils/tarball/master + +Once you have a copy of the source, you can install it with: + +.. code-block:: console + + $ python setup.py install + + +.. _Github repo: https://github.com/beer-garden/brewtils +.. _tarball: https://github.com/beer-garden/brewtils/tarball/master diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 00000000..b6e45a49 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,242 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\yapconf.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\yapconf.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %BUILDDIR%/.. + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +:end diff --git a/docs/modules.rst b/docs/modules.rst new file mode 100644 index 00000000..5ab3e1e7 --- /dev/null +++ b/docs/modules.rst @@ -0,0 +1,7 @@ +brewtils +======== + +.. toctree:: + :maxdepth: 4 + + brewtils diff --git a/docs/readme.rst b/docs/readme.rst new file mode 100644 index 00000000..72a33558 --- /dev/null +++ b/docs/readme.rst @@ -0,0 +1 @@ +.. include:: ../README.rst diff --git a/docs/usage.rst b/docs/usage.rst new file mode 100644 index 00000000..4a641c0a --- /dev/null +++ b/docs/usage.rst @@ -0,0 +1,5 @@ +===== +Usage +===== + +.. include:: ../README.rst diff --git a/requirements.in b/requirements.in index eaf024d2..f26fc48a 100644 --- a/requirements.in +++ b/requirements.in @@ -11,6 +11,8 @@ futures ; python_version < "3.0" # Documentation Dependencies sphinx +sphinx_rtd_theme +watchdog # Build / Test Dependencies mock diff --git a/requirements.txt b/requirements.txt index d509924d..b2daf0ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ # pip-compile --output-file requirements.txt requirements.in # alabaster==0.7.10 # via sphinx +argh==0.26.2 # via watchdog babel==2.5.1 # via sphinx certifi==2017.7.27.1 # via requests chardet==3.0.4 # via requests @@ -24,6 +25,7 @@ mccabe==0.6.1 # via flake8 mock==2.0.0 nose==1.3.7 nosexcover==1.0.11 +pathtools==0.1.2 # via watchdog pbr==3.1.1 # via mock pika==0.11.0 pluggy==0.5.2 # via tox @@ -32,14 +34,17 @@ pycodestyle==2.3.1 # via flake8 pyflakes==1.6.0 # via flake8 pygments==2.2.0 # via sphinx pytz==2017.2 +pyyaml==3.12 # via watchdog rednose==1.2.2 requests==2.18.4 six==1.11.0 snowballstemmer==1.2.1 # via sphinx +sphinx-rtd-theme==0.2.4 sphinx==1.6.4 sphinxcontrib-websupport==1.0.1 # via sphinx termstyle==0.1.11 # via rednose tox==2.9.1 urllib3==1.22 # via requests virtualenv==15.1.0 # via tox +watchdog==0.8.3 wrapt==1.10.11