From 9d92d0eebb1f6ff233ccb7753cfe197ea11e7f85 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Tue, 8 Aug 2017 13:49:04 -0700 Subject: [PATCH] Add registering documentation to plugins. --- .../java/org/nwapw/abacus/plugin/Plugin.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/org/nwapw/abacus/plugin/Plugin.java b/src/main/java/org/nwapw/abacus/plugin/Plugin.java index 7a78764..b92a9f4 100644 --- a/src/main/java/org/nwapw/abacus/plugin/Plugin.java +++ b/src/main/java/org/nwapw/abacus/plugin/Plugin.java @@ -1,5 +1,7 @@ package org.nwapw.abacus.plugin; +import org.nwapw.abacus.function.Documentation; +import org.nwapw.abacus.function.DocumentationType; import org.nwapw.abacus.function.Function; import org.nwapw.abacus.function.Operator; import org.nwapw.abacus.number.NumberInterface; @@ -94,6 +96,15 @@ public abstract class Plugin { manager.registerNumberImplementation(name, implementation); } + /** + * To be used in load(). Registers a documentation instance + * used to explain some element of the plugin to the user. + * @param documentation the documentation instance. + */ + protected final void registerDocumentation(Documentation documentation){ + manager.registerDocumentation(documentation); + } + /** * Searches the PluginManager for the given function name. * This can be used by the plugins internally in order to call functions @@ -130,6 +141,17 @@ public abstract class Plugin { return manager.numberImplementationFor(name); } + /** + * Searches the PluginManager for the given documentation name and type. + * + * @param name the name for which to search. + * @param type the type of documentation to search for. + * @return the found documentation, or null if none was found. + */ + protected final Documentation documentationFor(String name, DocumentationType type){ + return manager.documentationFor(name, type); + } + /** * Searches the plugin manager for a Pi value for the given number implementation. * This is done so that number implementations with various degrees of precision