From 1d0eb14918e5df259ee1bf6bad080e2cd1eeb116 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 24 Sep 2013 15:23:15 +0200 Subject: [PATCH] Added WSF_SELF_DOCUMENTED_AGENT_HANDLER and variants for uri, uri_template, starts_with, ... to provide a way to documentate easily wsf agent handler. --- .../wsf_self_documented_agent_handler.e | 78 +++++++++++++++++++ .../wsf_self_documented_handler.e | 8 +- ...elf_documented_starts_with_agent_handler.e | 61 +++++++++++++++ .../wsf_self_documented_uri_agent_handler.e | 62 +++++++++++++++ ...lf_documented_uri_template_agent_handler.e | 62 +++++++++++++++ 5 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 library/server/wsf/router/documentation/wsf_self_documented_agent_handler.e create mode 100644 library/server/wsf/router/support/starts_with/helpers/wsf_self_documented_starts_with_agent_handler.e create mode 100644 library/server/wsf/router/support/uri/helpers/wsf_self_documented_uri_agent_handler.e create mode 100644 library/server/wsf/router/support/uri_template/wsf_self_documented_uri_template_agent_handler.e diff --git a/library/server/wsf/router/documentation/wsf_self_documented_agent_handler.e b/library/server/wsf/router/documentation/wsf_self_documented_agent_handler.e new file mode 100644 index 00000000..1e55ce7f --- /dev/null +++ b/library/server/wsf/router/documentation/wsf_self_documented_agent_handler.e @@ -0,0 +1,78 @@ +note + description: "[ + Interface defining a self documented handler using a function + to build the `mapping_documentation' + ]" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_SELF_DOCUMENTED_AGENT_HANDLER + +inherit + WSF_SELF_DOCUMENTED_HANDLER + +feature -- Access + + is_hidden: BOOLEAN + -- Is hidden from self documentation? + + descriptions: detachable ARRAYED_LIST [READABLE_STRING_GENERAL] + + self_documentation_builder: detachable FUNCTION [ANY, TUPLE [WSF_ROUTER_MAPPING, detachable WSF_REQUEST_METHODS], WSF_ROUTER_MAPPING_DOCUMENTATION] + -- Function building the `mapping_documentation'. + +feature -- Change + + add_description (d: READABLE_STRING_GENERAL) + local + lst: like descriptions + do + lst := descriptions + if lst = Void then + create lst.make (1) + descriptions := lst + end + lst.force (d) + end + + set_self_documentation_builder (fct: like self_documentation_builder) + -- Set `self_documentation_builder' to `fct'. + do + self_documentation_builder := fct + end + +feature -- Documentation + + mapping_documentation (m: WSF_ROUTER_MAPPING; a_request_methods: detachable WSF_REQUEST_METHODS): WSF_ROUTER_MAPPING_DOCUMENTATION + -- + do + if attached self_documentation_builder as fct then + Result := fct.item ([m, a_request_methods]) + else + create Result.make (m) + end + if attached descriptions as l_descriptions then + across + l_descriptions as c + loop + Result.add_description (c.item) + end + end + if is_hidden then + Result.set_is_hidden (True) + end + end + +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/library/server/wsf/router/documentation/wsf_self_documented_handler.e b/library/server/wsf/router/documentation/wsf_self_documented_handler.e index 9558a1b2..b6d644fd 100644 --- a/library/server/wsf/router/documentation/wsf_self_documented_handler.e +++ b/library/server/wsf/router/documentation/wsf_self_documented_handler.e @@ -1,6 +1,10 @@ note - description: "Summary description for {WSF_SELF_DOCUMENTED_HANDLER}." - author: "" + description: "[ + Interface defining a self documented handler + + inherit from this class and define mapping_documentation to generate + auto self documentation on demand. + ]" date: "$Date$" revision: "$Revision$" diff --git a/library/server/wsf/router/support/starts_with/helpers/wsf_self_documented_starts_with_agent_handler.e b/library/server/wsf/router/support/starts_with/helpers/wsf_self_documented_starts_with_agent_handler.e new file mode 100644 index 00000000..c8f6f5bf --- /dev/null +++ b/library/server/wsf/router/support/starts_with/helpers/wsf_self_documented_starts_with_agent_handler.e @@ -0,0 +1,61 @@ +note + description: "Summary description for {WSF_SELF_DOCUMENTED_STARTS_WITH_AGENT_HANDLER}." + date: "$Date$" + revision: "$Revision$" + +class + WSF_SELF_DOCUMENTED_STARTS_WITH_AGENT_HANDLER + +inherit + WSF_STARTS_WITH_AGENT_HANDLER + rename + make as make_handler + end + + WSF_SELF_DOCUMENTED_AGENT_HANDLER + +create + make, + make_with_descriptions, + make_hidden + +feature {NONE} -- Initialization + + make (a_action: like action; a_self_doc: like self_documentation_builder) + -- + -- and using `a_self_doc' function to build the `mapping_documentation'. + do + set_self_documentation_builder (a_self_doc) + make_handler (a_action) + end + + make_with_descriptions (a_action: like action; a_descriptions: ITERABLE [READABLE_STRING_GENERAL]) + do + across + a_descriptions as c + loop + add_description (c.item) + end + make_handler (a_action) + end + + make_hidden (a_action: like action) + -- + -- and using `a_self_doc' function to build the `mapping_documentation' + -- mark it as `hidden'. + do + is_hidden := True + make (a_action, Void) + end + +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/support/uri/helpers/wsf_self_documented_uri_agent_handler.e b/library/server/wsf/router/support/uri/helpers/wsf_self_documented_uri_agent_handler.e new file mode 100644 index 00000000..b47cba25 --- /dev/null +++ b/library/server/wsf/router/support/uri/helpers/wsf_self_documented_uri_agent_handler.e @@ -0,0 +1,62 @@ +note + description: "Summary description for {WSF_SELF_DOCUMENTED_URI_AGENT_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_SELF_DOCUMENTED_URI_AGENT_HANDLER + +inherit + WSF_URI_AGENT_HANDLER + rename + make as make_handler + end + + WSF_SELF_DOCUMENTED_AGENT_HANDLER + +create + make, + make_with_descriptions, + make_hidden + +feature {NONE} -- Initialization + + make (a_action: like action; a_self_doc: like self_documentation_builder) + -- + -- and using `a_self_doc' function to build the `mapping_documentation'. + do + set_self_documentation_builder (a_self_doc) + make_handler (a_action) + end + + make_with_descriptions (a_action: like action; a_descriptions: ITERABLE [READABLE_STRING_GENERAL]) + -- Make Current with `a_action' and `a_descriptions'. + do + across + a_descriptions as c + loop + add_description (c.item) + end + make_handler (a_action) + end + + make_hidden (a_action: like action) + -- Make Current with `a_action' + -- mark it as `hidden'. + do + is_hidden := True + make (a_action, Void) + end + +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/router/support/uri_template/wsf_self_documented_uri_template_agent_handler.e b/library/server/wsf/router/support/uri_template/wsf_self_documented_uri_template_agent_handler.e new file mode 100644 index 00000000..6a6801bb --- /dev/null +++ b/library/server/wsf/router/support/uri_template/wsf_self_documented_uri_template_agent_handler.e @@ -0,0 +1,62 @@ +note + description: "Summary description for {WSF_SELF_DOCUMENTED_URI_TEMPLATE_AGENT_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_SELF_DOCUMENTED_URI_TEMPLATE_AGENT_HANDLER + +inherit + WSF_URI_TEMPLATE_AGENT_HANDLER + rename + make as make_handler + end + + WSF_SELF_DOCUMENTED_AGENT_HANDLER + +create + make, + make_with_descriptions, + make_hidden + +feature {NONE} -- Initialization + + make (a_action: like action; a_self_doc: like self_documentation_builder) + -- + -- and using `a_self_doc' function to build the `mapping_documentation'. + do + set_self_documentation_builder (a_self_doc) + make_handler (a_action) + end + + make_with_descriptions (a_action: like action; a_descriptions: ITERABLE [READABLE_STRING_GENERAL]) + do + across + a_descriptions as c + loop + add_description (c.item) + end + make_handler (a_action) + end + + make_hidden (a_action: like action) + -- + -- and using `a_self_doc' function to build the `mapping_documentation' + -- mark it as `hidden'. + do + is_hidden := True + make (a_action, Void) + end + +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end