From 7bcdc847376fe7d45498a3d96ddd32ada27222dd Mon Sep 17 00:00:00 2001 From: Jim Gay Date: Thu, 29 Jan 2015 12:20:06 -0500 Subject: [PATCH 1/4] add initial text for building plugins --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 914c7ee..b09664e 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,24 @@ Quarto.configure do |config| end ``` +## Building plugins + +Quarto offers the ability to alter the assembly line to generate alternative output. + +Start by creating a class for your plugin which inherits from `Quarto::Plugin`. Quarto will expect that your plugin has features for different aspects of the assembly line. + +You have the option to provide custom behavior for the following methods: + +- `enhance_build(build_object)` +- `finalize_build(build_object)` +- `define_tasks` + +```ruby +class TxtOutput < Quarto::Plugin + +end +``` + ## Contributing 1. Fork it From 0383e7d6592429adef54ea76619abf99036e4223 Mon Sep 17 00:00:00 2001 From: Jim Gay Date: Thu, 29 Jan 2015 12:34:14 -0500 Subject: [PATCH 2/4] add comments around the use of standard plugin methods --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b09664e..024f8d8 100644 --- a/README.md +++ b/README.md @@ -239,9 +239,9 @@ Start by creating a class for your plugin which inherits from `Quarto::Plugin`. You have the option to provide custom behavior for the following methods: -- `enhance_build(build_object)` -- `finalize_build(build_object)` -- `define_tasks` +- `enhance_build(build_object)`: This method accepts the Quarto build object and will be used to affect the build process. See example below. +- `finalize_build(build_object)`: This method also accepts the Quarto build object and hooks into the process after the build object has been initialized and processed through all plugins and their `enhance_build` methods. +- `define_tasks`: Your plugin has access to the Rake::DSL library for creating command line rake tasks. Use this method to define tasks that can be used to manipulate and output content necessary for your plugin to function. Rake allows you to access existing rake tasks so you may compose your part of the assembly process through existing tasks. ```ruby class TxtOutput < Quarto::Plugin From d24004c0e2d54245bdcfd839d3f04c5cdb604f6d Mon Sep 17 00:00:00 2001 From: Jim Gay Date: Thu, 29 Jan 2015 13:11:57 -0500 Subject: [PATCH 3/4] add notes about plugin usage in config. fix namespace for plugin class --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 024f8d8..31006df 100644 --- a/README.md +++ b/README.md @@ -244,11 +244,25 @@ You have the option to provide custom behavior for the following methods: - `define_tasks`: Your plugin has access to the Rake::DSL library for creating command line rake tasks. Use this method to define tasks that can be used to manipulate and output content necessary for your plugin to function. Rake allows you to access existing rake tasks so you may compose your part of the assembly process through existing tasks. ```ruby -class TxtOutput < Quarto::Plugin +module Quarto + class TxtOutput < Plugin + end end ``` +You can access your plugin through the Quarto config object: + +```ruby +Quarto.configure do |config| + config.use :text_output +end +``` + +Quarto will take the argument from the `config.use` call to determine the name of your plugin class. The argument `:text_output` will be translated to `"TextOutput"` + +When hooking into the config object, Quarto expects your plugin to be stored (using this example) in "quarto/text_output". Your plugin should be created under the Quarto namespace. Quarto will attempt to find it using `Quarto.const_get` meaning it will look inside its own namespace. + ## Contributing 1. Fork it From a37e9b0499d0f5bb7ad45fe63ee47929c7c7f56c Mon Sep 17 00:00:00 2001 From: Jim Gay Date: Thu, 29 Jan 2015 13:18:11 -0500 Subject: [PATCH 4/4] add example methods to sample plugin --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 31006df..fa995b6 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,25 @@ You have the option to provide custom behavior for the following methods: module Quarto class TxtOutput < Plugin + def enhance_build(build) + # alter the build object + end + + def finalize_build(build) + # alter the build object + end + + def define_tasks + # add rake tasks + desc "Generate TXT files from the source" + task :generate_txt => generate_text + end + + # Add support methods as you need + def generate_text + #... your implementation + end + end end ```