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
This commit is contained in:
David Pursehouse
2013-08-14 16:35:06 +09:00
parent 3e05f81f8c
commit fe52915469
2 changed files with 14 additions and 0 deletions

View File

@@ -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 If a discovered file name beings with `cmd-` it will be clustered
into a 'Commands' section of the generated index page. 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. All other files are clustered under a 'Documentation' section.
Some optional information from the manifest is extracted and Some optional information from the manifest is extracted and

View File

@@ -331,6 +331,8 @@ class HttpPluginServlet extends HttpServlet
String prefix, String pluginName, String prefix, String pluginName,
ResourceKey cacheKey, HttpServletResponse res) throws IOException { ResourceKey cacheKey, HttpServletResponse res) throws IOException {
List<JarEntry> cmds = Lists.newArrayList(); List<JarEntry> cmds = Lists.newArrayList();
List<JarEntry> servlets = Lists.newArrayList();
List<JarEntry> restApis = Lists.newArrayList();
List<JarEntry> docs = Lists.newArrayList(); List<JarEntry> docs = Lists.newArrayList();
JarEntry about = null; JarEntry about = null;
Enumeration<JarEntry> entries = jar.entries(); Enumeration<JarEntry> entries = jar.entries();
@@ -345,6 +347,10 @@ class HttpPluginServlet extends HttpServlet
name = name.substring(prefix.length()); name = name.substring(prefix.length());
if (name.startsWith("cmd-")) { if (name.startsWith("cmd-")) {
cmds.add(entry); 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.")) { } else if (name.startsWith("about.")) {
if (about == null) { if (about == null) {
about = entry; about = entry;
@@ -395,6 +401,8 @@ class HttpPluginServlet extends HttpServlet
} }
appendEntriesSection(jar, docs, "Documentation", md, prefix, 0); 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()); appendEntriesSection(jar, cmds, "Commands", md, prefix, "cmd-".length());
sendMarkdownAsHtml(md.toString(), pluginName, cacheKey, res); sendMarkdownAsHtml(md.toString(), pluginName, cacheKey, res);