From fe52915469f7bbadc51dba5aed4624e03a1c34fc Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 14 Aug 2013 16:35:06 +0900 Subject: [PATCH] Allow separate REST API and servlet documentation sections for plugins If a plugin provides documentation files whose names are prefixed with "servlet-" or "rest-api-", the documentation will be listed under separate "Servlet" and "REST API" sections, respectively, on the index page, in the same way that files prefixed with "cmd-" are currently listed under a separate "Commands" section. Change-Id: I94326d7cba58b33c80eba61850d4221064404454 --- Documentation/dev-plugins.txt | 6 ++++++ .../google/gerrit/httpd/plugins/HttpPluginServlet.java | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index b0a0e5f64b..7765246475 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt @@ -533,6 +533,12 @@ exist, only the first discovered file will be used. If a discovered file name beings with `cmd-` it will be clustered into a 'Commands' section of the generated index page. +If a discovered file name beings with `servlet-` it will be clustered +into a 'Servlets' section of the generated index page. + +If a discovered file name beings with `rest-api-` it will be clustered +into a 'REST APIs' section of the generated index page. + All other files are clustered under a 'Documentation' section. Some optional information from the manifest is extracted and diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java index 4b3084ac3b..53abc4c2c5 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java @@ -331,6 +331,8 @@ class HttpPluginServlet extends HttpServlet String prefix, String pluginName, ResourceKey cacheKey, HttpServletResponse res) throws IOException { List cmds = Lists.newArrayList(); + List servlets = Lists.newArrayList(); + List restApis = Lists.newArrayList(); List docs = Lists.newArrayList(); JarEntry about = null; Enumeration entries = jar.entries(); @@ -345,6 +347,10 @@ class HttpPluginServlet extends HttpServlet name = name.substring(prefix.length()); if (name.startsWith("cmd-")) { cmds.add(entry); + } else if (name.startsWith("servlet-")) { + servlets.add(entry); + } else if (name.startsWith("rest-api-")) { + restApis.add(entry); } else if (name.startsWith("about.")) { if (about == null) { about = entry; @@ -395,6 +401,8 @@ class HttpPluginServlet extends HttpServlet } appendEntriesSection(jar, docs, "Documentation", md, prefix, 0); + appendEntriesSection(jar, servlets, "Servlets", md, prefix, "servlet-".length()); + appendEntriesSection(jar, restApis, "REST APIs", md, prefix, "rest-api-".length()); appendEntriesSection(jar, cmds, "Commands", md, prefix, "cmd-".length()); sendMarkdownAsHtml(md.toString(), pluginName, cacheKey, res);