diff options
author | Trevor Johns <trevorjohns@google.com> | 2016-04-12 10:37:58 -0700 |
---|---|---|
committer | Trevor Johns <trevorjohns@google.com> | 2016-04-12 10:37:58 -0700 |
commit | 9bd6d548b125fdd6b9ad7cf97cf6045a502d52bd (patch) | |
tree | d6606623959dc45e2eb39e0559e915fc6a805bc5 | |
parent | a37a38464aeef5ef2eee77b8463f975d6ffa34af (diff) | |
download | platform_external_doclava-9bd6d548b125fdd6b9ad7cf97cf6045a502d52bd.tar.gz platform_external_doclava-9bd6d548b125fdd6b9ad7cf97cf6045a502d52bd.tar.bz2 platform_external_doclava-9bd6d548b125fdd6b9ad7cf97cf6045a502d52bd.zip |
Revert "Resolve merge conflicts of 91f2a6a to nyc-dev"
This reverts commit a37a38464aeef5ef2eee77b8463f975d6ffa34af, reversing
changes made to ef611642305d68e51a6dbe0e57052671c01f7c31.
-rw-r--r-- | res/assets/templates/macros.cs | 200 | ||||
-rw-r--r-- | src/com/google/doclava/ClearPage.java | 10 | ||||
-rw-r--r-- | src/com/google/doclava/DocFile.java | 304 | ||||
-rw-r--r-- | src/com/google/doclava/Doclava.java | 31 | ||||
-rw-r--r-- | src/com/google/doclava/MethodInfo.java | 126 | ||||
-rw-r--r-- | src/com/google/doclava/PageMetadata.java | 244 | ||||
-rw-r--r-- | src/com/google/doclava/ParamTagInfo.java | 1 | ||||
-rw-r--r-- | src/com/google/doclava/SampleCode.java | 4 |
8 files changed, 264 insertions, 656 deletions
diff --git a/res/assets/templates/macros.cs b/res/assets/templates/macros.cs index 750a31d..e897cca 100644 --- a/res/assets/templates/macros.cs +++ b/res/assets/templates/macros.cs @@ -1,11 +1,9 @@ -<?cs # A link to a package ?><?cs +<?cs # A link to a package ?><?cs def:package_link(pkg) ?> - <a href="<?cs var:toroot ?><?cs var:pkg.link ?>"><?cs var:pkg.name ?></a><?cs + <a href="<?cs var:toroot ?><?cs var:pkg.link ?>"><?cs var:pkg.name ?></a><?cs /def ?> - - -<?cs # A link to a type, or not if it is a primitive type +<?cs # A link to a type, or not if it's a primitive type link: whether to create a link at the top level, always creates links in recursive invocations. Overloaded version to support use of 'nav' parameter, which when true, @@ -17,16 +15,16 @@ def:package_link(pkg) ?> .superBounds.N.(more links) (... super ... & ...) .extendsBounds.N.(more links) (... extends ... & ...) .typeArguments.N.(more links) (< ... >) -?><?cs +?><?cs def:type_link_impl(type, link) ?><?cs call:type_link_impl2(type, link, "false") ?><?cs /def ?><?cs def:type_link_impl2(type, link, nav) ?><?cs if:type.link && link=="true" ?><?cs if:type.federated ?><a href="<?cs var:type.link ?>"><?cs - var:type.label ?></a><?cs + var:type.label ?></a><?cs else ?><a href="<?cs var:toroot ?><?cs var:type.link ?>"><?cs var:type.label ?></a><?cs /if ?><?cs else ?><?cs var:type.label ?><?cs - /if ?><?cs + /if ?><?cs if:subcount(type.extendsBounds) ?><?cs each:t=type.extendsBounds ?><?cs if:first(t) ?> extends <?cs else ?> & <?cs /if ?><?cs @@ -75,7 +73,7 @@ def:cond_link(text, root, path, condition) ?><?cs if:condition ?><a href="<?cs var:root ?><?cs var:path ?>"><?cs /if ?><?cs var:text ?><?cs if:condition ?></a><?cs /if ?><?cs /def ?> -<?cs # A comma separated parameter list ?><?cs +<?cs # A comma separated parameter list ?><?cs def:parameter_list(params) ?><?cs each:param = params ?><?cs call:simple_type_link(param.type)?> <?cs @@ -125,7 +123,7 @@ def:tag_list(tags) ?><?cs elif:tag.kind == "@adtZipBytes" ?><?cs var:adt.zip.bytes ?><?cs elif:tag.kind == "@adtZipChecksum" ?><?cs var:adt.zip.checksum ?><?cs elif:tag.kind == "@inheritDoc" ?><?cs # This is the case when @inheritDoc is in something - that does not inherit from anything?><?cs + that doesn't inherit from anything?><?cs elif:tag.kind == "@attr" ?><?cs else ?>{<?cs var:tag.name?> <?cs var:tag.text ?>}<?cs /if ?><?cs @@ -209,7 +207,7 @@ def:show_simple_annotations_list(obj, pre, post) ?><?cs call:show_annotations_list(obj, pre, ", ", post) ?><?cs /def ?> -<?cs # Show the red box with the deprecated warning ?><?cs +<?cs # Show the red box with the deprecated warning ?><?cs def:deprecated_warning(obj) ?><?cs if:subcount(obj.deprecated) ?><p> <p class="caution"><strong><?cs @@ -224,22 +222,22 @@ def:deprecated_warning(obj) ?><?cs /if ?><?cs /def ?> -<?cs # print the See Also: section ?><?cs -def:see_also_tags(also) ?><?cs +<?cs # print the See Also: section ?><?cs +def:see_also_tags(also) ?><?cs if:subcount(also) ?> - <div> - <p><b>See also:</b></p> - <ul class="nolist"><?cs + <div class="jd-tagdata"> + <h5 class="jd-tagtitle">See Also</h5> + <ul class="nolist"><?cs each:tag=also ?><li><?cs if:tag.kind == "@see" ?><code><a href="<?cs var:toroot ?><?cs var:tag.href ?>"><?cs var:tag.label ?></a></code><?cs elif:tag.kind == "@seeHref" ?><a href="<?cs var:tag.href ?>"><?cs var:tag.label ?></a><?cs elif:tag.kind == "@seeJustLabel" ?><?cs var:tag.label ?><?cs else ?>[ERROR: Unknown @see kind]<?cs - /if ?></li><?cs + /if ?></li><?cs /each ?> </ul> - </div><?cs + </div><?cs /if ?> <?cs /def ?> @@ -252,162 +250,127 @@ if:reference.apilevels && obj.since ?> <?cs def:federated_refs(obj) ?> <?cs if:subcount(obj.federated) ?> <div> - Also: + Also: <?cs each:federated=obj.federated ?> - <a href="<?cs var:federated.url ?>"><?cs var:federated.name ?></a><?cs + <a href="<?cs var:federated.url ?>"><?cs var:federated.name ?></a><?cs if:!last(federated) ?>,<?cs /if ?> <?cs /each ?> </div> <?cs /if ?> <?cs /def ?> -<?cs -# -# Print the long-form description for something. -# Uses the following fields: deprecated descr seeAlso since -# -?><?cs -def:description(obj) ?><?cs +<?cs # Print the long-form description for something. + Uses the following fields: deprecated descr seeAlso since ?><?cs +def:description(obj) ?><?cs call:deprecated_warning(obj) ?> - <p><?cs call:tag_list(obj.descr) ?></p><?cs + <div class="jd-tagdata jd-tagdescr"><p><?cs call:tag_list(obj.descr) ?></p></div><?cs if:subcount(obj.annotationdocumentation)?><?cs each:annodoc=obj.annotationdocumentation ?> - <div style="display:block"><?cs var:annodoc.text?></div><?cs + <div class="jd-tagdata" style="display:block"><?cs var:annodoc.text?></div><?cs /each?><?cs /if?><?cs if:subcount(obj.attrRefs) ?> - <p><b>Related XML Attributes:</b></p> - <ul class="nolist"><?cs + <div class="jd-tagdata"> + <h5 class="jd-tagtitle">Related XML Attributes</h5> + <ul class="nolist"><?cs each:attr=obj.attrRefs ?> - <li><a href="<?cs var:toroot ?><?cs var:attr.href ?>"><?cs var:attr.name ?></a></li><?cs + <li><a href="<?cs var:toroot ?><?cs var:attr.href ?>"><?cs var:attr.name ?></a></li><?cs /each ?> - </ul><?cs - /if ?><?cs + </ul> + </div><?cs + /if ?><?cs if:subcount(obj.blockTags) ?> <?cs call:block_tag_list(obj.blockTags) ?><?cs /if ?><?cs - # - # Print the @param tags - # - ?><?cs if:subcount(obj.paramTags) ?> - <table class="responsive"> - <tr><th colspan=2>Parameters</th></tr><?cs - each:param=obj.paramTags ?> - <tr> - <td><code><?cs - if:param.isTypeParameter ?><<?cs - /if ?><?cs var:param.name ?><?cs - if:param.isTypeParameter ?>><?cs - /if ?></code></td> - <td width="100%"> - <code><?cs var:param.kind ?></code><?cs - if:string.find(param.comment.0.text, "<!--") != 0 - ?>:<?cs # Do not print if param comment is an HTML comment ?><?cs - /if ?> - <?cs call:tag_list(param.comment) ?></td> - </tr><?cs - /each ?> - </table><?cs - /if ?><?cs - # - # Print the @return value - # - ?><?cs + <div class="jd-tagdata"> + <h5 class="jd-tagtitle">Parameters</h5> + <table class="jd-tagtable"><?cs + each:tag=obj.paramTags ?> + <tr> + <th><?cs if:tag.isTypeParameter ?><<?cs /if ?><?cs var:tag.name + ?><?cs if:tag.isTypeParameter ?>><?cs /if ?></td> + <td><?cs call:tag_list(tag.comment) ?></td> + </tr><?cs + /each ?> + </table> + </div><?cs + /if ?><?cs if:subcount(obj.returns) ?> - <table class="responsive"> - <tr><th colspan=2>Returns</th></tr> - <tr> - <td><code><?cs call:type_link(method.returnType) ?></code></td> - <td width="100%"><?cs call:tag_list(obj.returns) ?></td> - </tr> - </table><?cs - # - # If no return tag found, but there is a return type not 'void', print it - # - ?><?cs - elif:subcount(method.returnType) && method.returnType.label != 'void' ?> - <table class="responsive"> - <tr><th colspan=2>Returns</th></tr> - <tr> - <td><code><?cs call:type_link(method.returnType) ?></code></td> - <td width="100%"><!-- no returns description in source --></td> - </tr> - </table><?cs - /if ?><?cs - # - # Print the throwables - # - ?><?cs + <div class="jd-tagdata"> + <h5 class="jd-tagtitle">Returns</h5> + <ul class="nolist"><li><?cs call:tag_list(obj.returns) ?></li></ul> + </div><?cs + /if ?><?cs if:subcount(obj.throws) ?> - <table class="responsive"> - <tr><th colspan=2>Throws</th></tr><?cs - each:tag=obj.throws ?> + <div class="jd-tagdata"> + <h5 class="jd-tagtitle">Throws</h5> + <table class="jd-tagtable"><?cs + each:tag=obj.throws ?> <tr> - <td><code><?cs call:type_link(tag.type) ?></code></td> - <td width="100%"><?cs call:tag_list(tag.comment) ?></td> - </tr><?cs + <th><?cs call:type_link(tag.type) ?></td> + <td><?cs call:tag_list(tag.comment) ?></td> + </tr><?cs /each ?> </table> - <?cs - /if ?><?cs + </div><?cs + /if ?><?cs call:see_also_tags(obj.seeAlso) ?><?cs /def ?> <?cs # A table of links to classes with descriptions, as in a package file or the nested classes ?><?cs -def:class_link_table(classes) ?><?cs +def:class_link_table(classes) ?><?cs set:count = #1 ?> <table class="jd-sumtable-expando"><?cs each:cl=classes ?> <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:cl.type.since ?>" > - <td><?cs call:type_link(cl.type) ?></td> - <td width="100%"><?cs call:short_descr(cl) ?> </td> + <td class="jd-linkcol"><?cs call:type_link(cl.type) ?></td> + <td class="jd-descrcol" width="100%"><?cs call:short_descr(cl) ?> </td> </tr><?cs set:count = count + #1 ?><?cs /each ?> - </table><?cs + </table><?cs /def ?> -<?cs # A list of links to classes, for use in the side navigation of classes when viewing a package (panel nav) ?><?cs -def:class_link_list(label, classes) ?><?cs +<?cs # A list of links to classes, for use in the side navigation of classes when viewing a package (panel nav) ?><?cs +def:class_link_list(label, classes) ?><?cs if:subcount(classes) ?> <li><h2><?cs var:label ?></h2> - <ul><?cs + <ul><?cs each:cl=classes ?> <li class="api apilevel-<?cs var:cl.type.since ?>"><?cs call:type_link2(cl.type,"true") ?></li><?cs /each ?> </ul> - </li><?cs - /if ?><?cs + </li><?cs + /if ?><?cs /def ?> -<?cs # A list of links to classes, for use in the side navigation of classes when viewing a class (panel nav) ?><?cs -def:list(label, classes) ?><?cs +<?cs # A list of links to classes, for use in the side navigation of classes when viewing a class (panel nav) ?><?cs +def:list(label, classes) ?><?cs if:subcount(classes) ?> <li><h2><?cs var:label ?></h2> - <ul><?cs + <ul><?cs each:cl=classes ?> <li class="<?cs if:class.name == cl.label?>selected <?cs /if ?>api apilevel-<?cs var:cl.since ?>"><?cs call:type_link2(cl,"true") ?></li><?cs /each ?> </ul> - </li><?cs - /if ?><?cs + </li><?cs + /if ?><?cs /def ?> -<?cs # A list of links to packages, for use in the side navigation of packages (panel nav) ?><?cs -def:package_link_list(packages) ?><?cs +<?cs # A list of links to packages, for use in the side navigation of packages (panel nav) ?><?cs +def:package_link_list(packages) ?><?cs each:pkg=packages ?> - <li class="<?cs if:(class.package.name == pkg.name) || (package.name == pkg.name)?>selected <?cs /if ?>api apilevel-<?cs var:pkg.since ?>"><?cs call:package_link(pkg) ?></li><?cs + <li class="<?cs if:(class.package.name == pkg.name) || (package.name == pkg.name)?>selected <?cs /if ?>api apilevel-<?cs var:pkg.since ?>"><?cs call:package_link(pkg) ?></li><?cs /each ?><?cs /def ?> -<?cs # An expando trigger ?><?cs +<?cs # An expando trigger ?><?cs def:expando_trigger(id, default) ?> <a href="#" onclick="return toggleInherited(this, null)" id="<?cs var:id ?>" class="jd-expando-trigger closed" - ><img height="34" id="<?cs var:id ?>-trigger" - src="<?cs var:toroot ?>assets/images/styles/disclosure_<?cs - if:default == 'closed' ?>down<?cs else ?>up<?cs /if ?>.png" - class="jd-expando-trigger-img" /></a><?cs + ><img id="<?cs var:id ?>-trigger" + src="<?cs var:toroot ?>assets/images/triangle-<?cs var:default ?>.png" + class="jd-expando-trigger-img" /></a><?cs /def ?> -<?cs # An expandable list of classes ?><?cs +<?cs # An expandable list of classes ?><?cs def:expandable_class_list(id, classes, default) ?> <div id="<?cs var:id ?>"> <div id="<?cs var:id ?>-list" @@ -433,10 +396,11 @@ def:expandable_class_list(id, classes, default) ?> </div> <div id="<?cs var:id ?>-summary" <?cs if:default != "summary" ?>style="display: none;"<?cs /if ?> - ><?cs + ><?cs call:class_link_table(classes) ?> </div> - </div><?cs + </div><?cs /def ?> <?cs include:"components.cs" ?> + diff --git a/src/com/google/doclava/ClearPage.java b/src/com/google/doclava/ClearPage.java index 853e49d..ed1f069 100644 --- a/src/com/google/doclava/ClearPage.java +++ b/src/com/google/doclava/ClearPage.java @@ -107,9 +107,7 @@ public class ClearPage { } } data.setValue("toroot", toroot); - if (Doclava.USE_UPDATED_TEMPLATES) { - data.setValue("useUpdatedTemplates", "true"); - } + data.setValue("filename", filename); if (!fullPath) { @@ -159,7 +157,7 @@ public class ClearPage { } } - public static void copyFile(boolean allowExcepted, File from, String toPath, Boolean append) { + public static void copyFile(boolean allowExcepted, File from, String toPath) { File to = new File(outputDir + "/" + toPath); FileInputStream in; FileOutputStream out; @@ -174,9 +172,9 @@ public class ClearPage { } ensureDirectory(to); try { - out = new FileOutputStream(to, append); + out = new FileOutputStream(to); } catch (IOException e) { - System.err.println(to.getAbsolutePath() + ": Error opening file"); + System.err.println(from.getAbsolutePath() + ": Error opening file"); return; } if (!isValidContentType(allowExcepted, toPath, DROIDDOC_VALID_CONTENT_TYPES)) { diff --git a/src/com/google/doclava/DocFile.java b/src/com/google/doclava/DocFile.java index 43262d0..9e45bfd 100644 --- a/src/com/google/doclava/DocFile.java +++ b/src/com/google/doclava/DocFile.java @@ -51,8 +51,8 @@ public class DocFile { } } - public static String[] DEVSITE_VALID_LANGS = {"en", "es", "in", "ja", "ko", - "ru", "vi", "zh-cn", "zh-tw", "pt-br"}; + public static String[] DEVSITE_VALID_LANGS = {"en", "es","ja", "ko", + "ru", "zh-cn", "zh-tw", "pt-br"}; public static String getPathRoot(String filename) { //look for a valid lang string in the file path. If found, @@ -183,233 +183,87 @@ public class DocFile { // Strip out the intl and lang id substr and get back just the // guide, design, distribute, etc. filename = getPathRoot(filename); - - if (Doclava.USE_UPDATED_TEMPLATES) { - //remap types to design, dev, distribute etc. - if (filename.indexOf("design") == 0) { - hdf.setValue("design", "true"); - hdf.setValue("page.type", "design"); - hdf.setValue("page.category", "design"); - } else if (filename.indexOf("develop") == 0) { - hdf.setValue("develop", "true"); - hdf.setValue("page.type", "develop"); - hdf.setValue("page.category", "develop"); - } else if (filename.indexOf("guide") == 0) { - hdf.setValue("guide", "true"); - hdf.setValue("page.type", "develop"); - if (filename.indexOf("guide/topics/manif") == 0) { - hdf.setValue("page.category", "app manifest"); - } else { - hdf.setValue("page.category", "guide"); - } - } else if (filename.indexOf("training") == 0) { - hdf.setValue("training", "true"); - hdf.setValue("page.type", "develop"); - hdf.setValue("page.category", "training"); - } else if (filename.indexOf("more") == 0) { - hdf.setValue("more", "true"); - } else if (filename.indexOf("google") == 0) { - hdf.setValue("google", "true"); - hdf.setValue("page.type", "develop"); - hdf.setValue("page.category", "google"); - } else if (filename.indexOf("samples") == 0) { - hdf.setValue("samples", "true"); - hdf.setValue("page.type", "develop"); - hdf.setValue("page.category", "samples"); - if (Doclava.samplesNavTree != null) { - hdf.setValue("samples_toc_tree", Doclava.samplesNavTree.getValue("samples_toc_tree", "")); - } - } else if (filename.indexOf("distribute") == 0) { - hdf.setValue("distribute", "true"); - hdf.setValue("page.type", "distribute"); - hdf.setValue("page.category", "distribute"); - if (filename.indexOf("distribute/googleplay") == 0) { - hdf.setValue("page.category", "googleplay"); - hdf.setValue("page.type", "distribute"); - hdf.setValue("googleplay", "true"); - } else if (filename.indexOf("distribute/essentials") == 0) { - hdf.setValue("page.category", "essentials"); - hdf.setValue("essentials", "true"); - } else if (filename.indexOf("distribute/users") == 0) { - hdf.setValue("page.category", "users"); - hdf.setValue("users", "true"); - } else if (filename.indexOf("distribute/engage") == 0) { - hdf.setValue("page.category", "engage"); - hdf.setValue("engage", "true"); - } else if (filename.indexOf("distribute/monetize") == 0) { - hdf.setValue("page.category", "monetize"); - hdf.setValue("monetize", "true"); - } else if (filename.indexOf("distribute/analyze") == 0) { - hdf.setValue("page.category", "analyze"); - hdf.setValue("analyze", "true"); - } else if (filename.indexOf("distribute/tools") == 0) { - hdf.setValue("page.category", "essentials"); - hdf.setValue("essentials", "true"); - } else if (filename.indexOf("distribute/stories") == 0) { - hdf.setValue("page.category", "stories"); - hdf.setValue("stories", "true"); - } - } else if (filename.indexOf("about") == 0) { - hdf.setValue("about", "true"); - hdf.setValue("page.type", "about"); - hdf.setValue("page.category", "about"); - if ((filename.indexOf("about/versions") == 0)) { - hdf.setValue("versions", "true"); - hdf.setValue("page.category", "versions"); - } else if ((filename.indexOf("wear") == 0)) { - hdf.setValue("wear", "true"); - hdf.setValue("page.category", "wear"); - } else if ((filename.indexOf("tv") == 0)) { - hdf.setValue("tv", "true"); - hdf.setValue("page.category", "tv"); - } else if ((filename.indexOf("auto") == 0)) { - hdf.setValue("auto", "true"); - hdf.setValue("page.category", "auto"); - } - } else if ((filename.indexOf("tools") == 0) || (filename.indexOf("sdk") == 0)) { - hdf.setValue("tools", "true"); - hdf.setValue("page.type", "develop"); - hdf.setValue("page.category", "tools"); - fromTemplate = hdf.getValue("page.template", ""); - } else if (filename.indexOf("devices") == 0) { - hdf.setValue("devices", "true"); - hdf.setValue("page.type", "devices"); - } else if (filename.indexOf("source") == 0) { - hdf.setValue("source", "true"); - } else if (filename.indexOf("accessories") == 0) { - hdf.setValue("accessories", "true"); - } else if (filename.indexOf("compatibility") == 0) { - hdf.setValue("compatibility", "true"); - } else if (filename.indexOf("wear") == 0) { - hdf.setValue("wear", "true"); - hdf.setValue("about", "true"); - hdf.setValue("page.type", "about"); - hdf.setValue("page.category", "wear"); - } else if (filename.indexOf("preview") == 0) { - hdf.setValue("page.type", "develop"); - hdf.setValue("page.category", "preview"); - hdf.setValue("preview", "true"); - } else if (filename.indexOf("auto") == 0) { - hdf.setValue("auto", "true"); - hdf.setValue("about", "true"); - hdf.setValue("page.type", "about"); - hdf.setValue("page.category", "auto"); - } else if (filename.indexOf("tv") == 0) { - hdf.setValue("tv", "true"); - hdf.setValue("about", "true"); - hdf.setValue("page.type", "about"); - hdf.setValue("page.category", "tv"); - } else if (filename.indexOf("ndk") == 0) { - hdf.setValue("ndk", "true"); - hdf.setValue("page.type", "ndk"); - hdf.setValue("page.category", "ndk"); - if (filename.indexOf("ndk/guides") == 0) { - hdf.setValue("guide", "true"); - hdf.setValue("page.type", "ndk"); - hdf.setValue("page.category", "guide"); - } else if (filename.indexOf("ndk/reference") == 0) { - hdf.setValue("reference", "true"); - hdf.setValue("page.type", "ndk"); - hdf.setValue("page.category", "reference"); - } else if (filename.indexOf("ndk/samples") == 0) { - hdf.setValue("samples", "true"); - hdf.setValue("page.type", "ndk"); - hdf.setValue("page.category", "samples"); - } else if (filename.indexOf("ndk/downloads") == 0) { - hdf.setValue("downloads", "true"); - hdf.setValue("page.type", "ndk"); - hdf.setValue("page.category", "downloads"); - fromTemplate = hdf.getValue("page.template", ""); - } - } else { - hdf.setValue("about", "true"); - hdf.setValue("page.type", "about"); - hdf.setValue("page.category", "about"); + if (filename.indexOf("design") == 0) { + hdf.setValue("design", "true"); + hdf.setValue("page.type", "design"); + } else if (filename.indexOf("develop") == 0) { + hdf.setValue("develop", "true"); + hdf.setValue("page.type", "develop"); + } else if (filename.indexOf("guide") == 0) { + hdf.setValue("guide", "true"); + hdf.setValue("page.type", "guide"); + } else if (filename.indexOf("training") == 0) { + hdf.setValue("training", "true"); + hdf.setValue("page.type", "training"); + } else if (filename.indexOf("more") == 0) { + hdf.setValue("more", "true"); + } else if (filename.indexOf("google") == 0) { + hdf.setValue("google", "true"); + hdf.setValue("page.type", "google"); + } else if (filename.indexOf("samples") == 0) { + hdf.setValue("samples", "true"); + hdf.setValue("page.type", "samples"); + if (Doclava.samplesNavTree != null) { + hdf.setValue("samples_toc_tree", Doclava.samplesNavTree.getValue("samples_toc_tree", "")); } - } else { - //support the old mappings - if (filename.indexOf("design") == 0) { - hdf.setValue("design", "true"); - hdf.setValue("page.type", "design"); - } else if (filename.indexOf("develop") == 0) { - hdf.setValue("develop", "true"); - hdf.setValue("page.type", "develop"); - } else if (filename.indexOf("guide") == 0) { + } else if (filename.indexOf("distribute") == 0) { + hdf.setValue("distribute", "true"); + hdf.setValue("page.type", "distribute"); + if (filename.indexOf("distribute/googleplay") == 0) { + hdf.setValue("googleplay", "true"); + } else if (filename.indexOf("distribute/essentials") == 0) { + hdf.setValue("essentials", "true"); + } else if (filename.indexOf("distribute/users") == 0) { + hdf.setValue("users", "true"); + } else if (filename.indexOf("distribute/engage") == 0) { + hdf.setValue("engage", "true"); + } else if (filename.indexOf("distribute/monetize") == 0) { + hdf.setValue("monetize", "true"); + } else if (filename.indexOf("distribute/analyze") == 0) { + hdf.setValue("analyze", "true"); + } else if (filename.indexOf("distribute/tools") == 0) { + hdf.setValue("essentials", "true"); + } else if (filename.indexOf("distribute/stories") == 0) { + hdf.setValue("stories", "true"); + } + } else if (filename.indexOf("about") == 0) { + hdf.setValue("about", "true"); + hdf.setValue("page.type", "about"); + } else if ((filename.indexOf("tools") == 0) || (filename.indexOf("sdk") == 0)) { + hdf.setValue("tools", "true"); + hdf.setValue("page.type", "tools"); + fromTemplate = hdf.getValue("page.template", ""); + } else if (filename.indexOf("devices") == 0) { + hdf.setValue("devices", "true"); + hdf.setValue("page.type", "devices"); + } else if (filename.indexOf("source") == 0) { + hdf.setValue("source", "true"); + } else if (filename.indexOf("security") == 0) { + hdf.setValue("security", "true"); + } else if (filename.indexOf("compatibility") == 0) { + hdf.setValue("compatibility", "true"); + } else if (filename.indexOf("wear") == 0) { + hdf.setValue("wear", "true"); + } else if (filename.indexOf("preview") == 0) { + hdf.setValue("preview", "true"); + hdf.setValue("page.type", "preview"); + } else if (filename.indexOf("auto") == 0) { + hdf.setValue("auto", "true"); + } else if (filename.indexOf("tv") == 0) { + hdf.setValue("tv", "true"); + } else if (filename.indexOf("ndk") == 0) { + hdf.setValue("ndk", "true"); + hdf.setValue("page.type", "ndk"); + if (filename.indexOf("ndk/guides") == 0) { hdf.setValue("guide", "true"); - hdf.setValue("page.type", "guide"); - } else if (filename.indexOf("training") == 0) { - hdf.setValue("training", "true"); - hdf.setValue("page.type", "training"); - } else if (filename.indexOf("more") == 0) { - hdf.setValue("more", "true"); - } else if (filename.indexOf("google") == 0) { - hdf.setValue("google", "true"); - hdf.setValue("page.type", "google"); - } else if (filename.indexOf("samples") == 0) { + } else if (filename.indexOf("ndk/reference") == 0) { + hdf.setValue("reference", "true"); + } else if (filename.indexOf("ndk/samples") == 0) { hdf.setValue("samples", "true"); - hdf.setValue("page.type", "samples"); - if (Doclava.samplesNavTree != null) { - hdf.setValue("samples_toc_tree", Doclava.samplesNavTree.getValue("samples_toc_tree", "")); - } - } else if (filename.indexOf("distribute") == 0) { - hdf.setValue("distribute", "true"); - hdf.setValue("page.type", "distribute"); - if (filename.indexOf("distribute/googleplay") == 0) { - hdf.setValue("googleplay", "true"); - } else if (filename.indexOf("distribute/essentials") == 0) { - hdf.setValue("essentials", "true"); - } else if (filename.indexOf("distribute/users") == 0) { - hdf.setValue("users", "true"); - } else if (filename.indexOf("distribute/engage") == 0) { - hdf.setValue("engage", "true"); - } else if (filename.indexOf("distribute/monetize") == 0) { - hdf.setValue("monetize", "true"); - } else if (filename.indexOf("distribute/analyze") == 0) { - hdf.setValue("analyze", "true"); - } else if (filename.indexOf("distribute/tools") == 0) { - hdf.setValue("essentials", "true"); - } else if (filename.indexOf("distribute/stories") == 0) { - hdf.setValue("stories", "true"); - } - } else if (filename.indexOf("about") == 0) { - hdf.setValue("about", "true"); - hdf.setValue("page.type", "about"); - } else if ((filename.indexOf("tools") == 0) || (filename.indexOf("sdk") == 0)) { - hdf.setValue("tools", "true"); - hdf.setValue("page.type", "tools"); + } else if (filename.indexOf("ndk/downloads") == 0) { + hdf.setValue("downloads", "true"); fromTemplate = hdf.getValue("page.template", ""); - } else if (filename.indexOf("devices") == 0) { - hdf.setValue("devices", "true"); - hdf.setValue("page.type", "devices"); - } else if (filename.indexOf("source") == 0) { - hdf.setValue("source", "true"); - } else if (filename.indexOf("accessories") == 0) { - hdf.setValue("accessories", "true"); - } else if (filename.indexOf("compatibility") == 0) { - hdf.setValue("compatibility", "true"); - } else if (filename.indexOf("wear") == 0) { - hdf.setValue("wear", "true"); - } else if (filename.indexOf("preview") == 0) { - hdf.setValue("page.type", "preview"); - hdf.setValue("page.category", "preview"); - hdf.setValue("preview", "true"); - } else if (filename.indexOf("auto") == 0) { - hdf.setValue("auto", "true"); - } else if (filename.indexOf("tv") == 0) { - hdf.setValue("tv", "true"); - } else if (filename.indexOf("ndk") == 0) { - hdf.setValue("ndk", "true"); - hdf.setValue("page.type", "ndk"); - if (filename.indexOf("ndk/guides") == 0) { - hdf.setValue("guide", "true"); - } else if (filename.indexOf("ndk/reference") == 0) { - hdf.setValue("reference", "true"); - } else if (filename.indexOf("ndk/samples") == 0) { - hdf.setValue("samples", "true"); - } else if (filename.indexOf("ndk/downloads") == 0) { - hdf.setValue("downloads", "true"); - fromTemplate = hdf.getValue("page.template", ""); - } + } } //set metadata for this file in jd_lists_unified diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java index 24dac58..825c8f8 100644 --- a/src/com/google/doclava/Doclava.java +++ b/src/com/google/doclava/Doclava.java @@ -68,10 +68,7 @@ public class Doclava { public static final boolean SORT_BY_NAV_GROUPS = true; /* Debug output for PageMetadata, format urls from site root */ public static boolean META_DBG=false; - /* Remove after updated templates are launched */ - public static boolean USE_UPDATED_TEMPLATES = false; - /* Show Preview navigation and process preview docs */ - public static boolean INCLUDE_PREVIEW = false; + public static String outputPathBase = "/"; public static ArrayList<String> inputPathHtmlDirs = new ArrayList<String>(); public static ArrayList<String> inputPathHtmlDir2 = new ArrayList<String>(); @@ -170,12 +167,7 @@ public class Doclava { if (a[0].equals("-d")) { outputPathBase = outputPathHtmlDirs = ClearPage.outputDir = a[1]; } else if (a[0].equals("-templatedir")) { - if (USE_UPDATED_TEMPLATES) { - /* remove with updated templates are launched */ - ClearPage.addTemplateDir("build/tools/droiddoc/templates-sdk-dev"); - } else { - ClearPage.addTemplateDir(a[1]); - } + ClearPage.addTemplateDir(a[1]); } else if (a[0].equals("-hdf")) { mHDFData.add(new String[] {a[1], a[2]}); } else if (a[0].equals("-knowntags")) { @@ -269,10 +261,6 @@ public class Doclava { offlineMode = true; } else if (a[0].equals("-metadataDebug")) { META_DBG = true; - } else if (a[0].equals("-useUpdatedTemplates")) { - USE_UPDATED_TEMPLATES = true; - } else if (a[0].equals("-includePreview")) { - INCLUDE_PREVIEW = true; } else if (a[0].equals("-federate")) { try { String name = a[1]; @@ -413,11 +401,7 @@ public class Doclava { } // Write metadata for all processed files to jd_lists_unified.js in out dir if (!sTaglist.isEmpty()) { - if (USE_UPDATED_TEMPLATES) { - PageMetadata.WriteListByLang(sTaglist); - } else { - PageMetadata.WriteList(sTaglist); - } + PageMetadata.WriteList(sTaglist); } } @@ -697,12 +681,6 @@ public class Doclava { if (option.equals("-metadataDebug")) { return 1; } - if (option.equals("-useUpdatedTemplates")) { - return 1; - } - if (option.equals("-includePreview")) { - return 1; - } if (option.equals("-documentannotations")) { return 2; } @@ -841,8 +819,7 @@ public class Doclava { Data data = makeHDF(); String hdfValue = data.getValue("sac") == null ? "" : data.getValue("sac"); boolean allowExcepted = hdfValue.equals("true") ? true : false; - boolean append = false; - ClearPage.copyFile(allowExcepted, f, templ, append); + ClearPage.copyFile(allowExcepted, f, templ); } } else if (f.isDirectory()) { writeDirectory(f, relative + f.getName() + "/", js); diff --git a/src/com/google/doclava/MethodInfo.java b/src/com/google/doclava/MethodInfo.java index 5ceb0e1..0ea8c33 100644 --- a/src/com/google/doclava/MethodInfo.java +++ b/src/com/google/doclava/MethodInfo.java @@ -227,7 +227,7 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv } return mIsDeprecated; } - + public void setDeprecated(boolean deprecated) { mDeprecatedKnown = true; mIsDeprecated = deprecated; @@ -331,7 +331,7 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv public TypeInfo returnType() { return mReturnType; } - + public String prettySignature() { return name() + prettyParameters(); } @@ -339,7 +339,7 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv public String prettyQualifiedSignature() { return qualifiedName() + prettyParameters(); } - + /** * Returns a printable version of the parameters of this method's signature. */ @@ -351,7 +351,7 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv } params.append(pInfo.type().simpleTypeName()); } - + params.append(")"); return params.toString(); } @@ -417,102 +417,80 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv return mThrowsTags; } - private static int indexOfParam(String name, ParamTagInfo[] list) { + private static int indexOfParam(String name, String[] list) { final int N = list.length; for (int i = 0; i < N; i++) { - if (name.equals(list[i].parameterName())) { + if (name.equals(list[i])) { return i; } } return -1; } - /* Checks whether the name documented with the provided @param tag - * actually matches one of the method parameters. */ - private boolean isParamTagInMethod(ParamTagInfo tag) { - for (ParameterInfo paramInfo : mParameters) { - if (paramInfo.name().equals(tag.parameterName())) { - return true; - } - } - return false; - } - public ParamTagInfo[] paramTags() { if (mParamTags == null) { final int N = mParameters.size(); - final String DEFAULT_COMMENT = "<!-- no parameter comment -->"; if (N == 0) { // Early out for empty case. mParamTags = ParamTagInfo.EMPTY_ARRAY; return ParamTagInfo.EMPTY_ARRAY; } - // Where we put each result - mParamTags = ParamTagInfo.getArray(N); - // collect all the @param tag info - ParamTagInfo[] paramTags = comment().paramTags(); - - // Complain about misnamed @param tags - for (ParamTagInfo tag : paramTags) { - if (!isParamTagInMethod(tag)){ - Errors.error(Errors.UNKNOWN_PARAM_TAG_NAME, tag.position(), - "@param tag with name that doesn't match the parameter list: '" - + tag.parameterName() + "'"); - } - } + String[] names = new String[N]; + String[] comments = new String[N]; + SourcePositionInfo[] positions = new SourcePositionInfo[N]; - // Loop the parameters known from the method signature... - // Start by getting the known parameter name and data type. Then, if - // there's an @param tag that matches the current parameter name, get the - // javadoc comments. But if there's no @param comments here, then - // check if it's available from the parent class. + // get the right names so we can handle our names being different from + // our parent's names. int i = 0; for (ParameterInfo param : mParameters) { - String name = param.name(); - String type = param.type().simpleTypeName(); - String comment = DEFAULT_COMMENT; - SourcePositionInfo position = param.position(); - - // Find the matching param from the @param tags in order to get - // the parameter comments - int index = indexOfParam(name, paramTags); + names[i] = param.name(); + comments[i] = ""; + positions[i] = param.position(); + i++; + } + + // Gather our comments, and complain about misnamed @param tags. Note that we must + // exclude type parameter tags (such as "@param <T> foo") from this analysis. + for (ParamTagInfo tag : comment().paramTags()) { + int index = indexOfParam(tag.parameterName(), names); if (index >= 0) { - comment = paramTags[index].parameterComment(); - position = paramTags[index].position(); + comments[index] = tag.parameterComment(); + positions[index] = tag.position(); } else if (!tag.isTypeParameter()) { - // Complain about misnamed @param tags. Note that we must exclude type - // parameter tags (such as "@param <T> foo") from this analysis. Errors.error(Errors.UNKNOWN_PARAM_TAG_NAME, tag.position(), "@param tag with name that doesn't match the parameter list: '" + tag.parameterName() + "'"); + } + } - // get our parent's tags to fill in the blanks - MethodInfo overridden = this.findOverriddenMethod(name(), signature()); - if (overridden != null) { - ParamTagInfo[] maternal = overridden.paramTags(); - if (comment.equals(DEFAULT_COMMENT)) { - comment = maternal[i].parameterComment(); - position = maternal[i].position(); + // get our parent's tags to fill in the blanks + MethodInfo overridden = this.findOverriddenMethod(name(), signature()); + if (overridden != null) { + ParamTagInfo[] maternal = overridden.paramTags(); + for (i = 0; i < N; i++) { + if (comments[i].equals("")) { + comments[i] = maternal[i].parameterComment(); + positions[i] = maternal[i].position(); } } + } - // Okay, now add the collected parameter information to the method data + // construct the results, and cache them for next time + mParamTags = ParamTagInfo.getArray(N); + for (i = 0; i < N; i++) { mParamTags[i] = - new ParamTagInfo("@param", type, name + " " + comment, parent(), - position); - - // while we're here, if we find any parameters that are still - // undocumented at this point, complain. This warning is off by - // default, because it's really, really common; - // but, it's good to be able to enforce it. - if (comment.equals(DEFAULT_COMMENT)) { - Errors.error(Errors.UNDOCUMENTED_PARAMETER, position, - "Undocumented parameter '" + name + "' on method '" - + name() + "'"); + new ParamTagInfo("@param", "@param", names[i] + " " + comments[i], parent(), + positions[i]); + + // while we're here, if we find any parameters that are still undocumented at this + // point, complain. (this warning is off by default, because it's really, really + // common; but, it's good to be able to enforce it) + if (comments[i].equals("")) { + Errors.error(Errors.UNDOCUMENTED_PARAMETER, positions[i], "Undocumented parameter '" + + names[i] + "' on method '" + name() + "'"); } - i++; } } return mParamTags; @@ -571,7 +549,7 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv } return true; } - + /** * Checks to see if a parameter from a method signature is * compatible with a parameter given in a {@code @link} tag. @@ -719,13 +697,13 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv public String getReason() { return mReasonOpened; } - + public void addException(String exec) { ClassInfo exceptionClass = new ClassInfo(exec); mThrownExceptions.add(exceptionClass); } - + public void addParameter(ParameterInfo p) { // Name information if (mParameters == null) { @@ -755,8 +733,8 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv private AnnotationValueInfo mDefaultAnnotationElementValue; private String mReasonOpened; private ArrayList<Resolution> mResolutions; - - // TODO: merge with droiddoc version (above) + + // TODO: merge with droiddoc version (above) public String qualifiedName() { String parentQName = (containingClass() != null) ? (containingClass().qualifiedName() + ".") : ""; @@ -775,7 +753,7 @@ public class MethodInfo extends MemberInfo implements AbstractMethodInfo, Resolv } params.append(pInfo.type().fullName()); } - + params.append(")"); mSignature = params.toString(); } diff --git a/src/com/google/doclava/PageMetadata.java b/src/com/google/doclava/PageMetadata.java index 73668e2..57f27cb 100644 --- a/src/com/google/doclava/PageMetadata.java +++ b/src/com/google/doclava/PageMetadata.java @@ -109,41 +109,6 @@ public class PageMetadata { } /** - * Given a list of metadata nodes organized by lang, sort the - * root nodes by type name and render the types and their child - * metadata nodes to separate lang-specific json files in the out dir. - * - * @param rootNodesList A list of root metadata nodes, each - * representing a type and it's member child pages. - */ - public static void WriteListByLang(List<Node> rootNodesList) { - Collections.sort(rootNodesList, BY_LANG_NAME); - for (Node n : rootNodesList) { - String langFilename = ""; - String langname = n.getLang(); - langFilename = "_" + langname; - Collections.sort(n.getChildren(), BY_TYPE_NAME); - Node pageMeta = new Node.Builder().setLabel("TOP").setChildren(n.getChildren()).build(); - - StringBuilder buf = new StringBuilder(); - // write the taglist to string format - pageMeta.renderLangResources(buf,langname); - //pageMeta.renderTypesByTag(buf); - // write the taglist to js file - Data data = Doclava.makeHDF(); - data.setValue("reference_tree", buf.toString()); - data.setValue("metadata.lang", langname); - // remove when updated templates are launched - String unifiedFilename = "jd_lists_unified" + langFilename + ".js"; - String extrasFilename = "jd_extras" + langFilename + ".js"; - // write out jd_lists_unified for each lang - ClearPage.write(data, "jd_lists_unified.cs", unifiedFilename); - // append jd_extras to jd_lists_unified for each lang, then delete. - appendExtrasMetadata(extrasFilename, unifiedFilename); - } - } - - /** * Extract supported metadata values from a page and add them as * a child node of a root node based on type. Some metadata values * are normalized. Unsupported metadata fields are ignored. See @@ -172,21 +137,16 @@ public class PageMetadata { if (!excludeNode) { Node pageMeta = new Node.Builder().build(); pageMeta.setLabel(getTitleNormalized(hdf, "page.title")); - pageMeta.setCategory(hdf.getValue("page.category","")); + pageMeta.setTitleFriendly(hdf.getValue("page.titleFriendly","")); pageMeta.setSummary(hdf.getValue("page.metaDescription","")); pageMeta.setLink(getPageUrlNormalized(filename)); pageMeta.setGroup(getStringValueNormalized(hdf,"sample.group")); pageMeta.setKeywords(getPageTagsNormalized(hdf, "page.tags")); pageMeta.setTags(getPageTagsNormalized(hdf, "meta.tags")); pageMeta.setImage(getImageUrlNormalized(hdf.getValue("page.image", ""))); - pageMeta.setLang(getLangStringNormalized(hdf, filename)); + pageMeta.setLang(getLangStringNormalized(filename)); pageMeta.setType(getStringValueNormalized(hdf, "page.type")); - pageMeta.setTimestamp(hdf.getValue("page.timestamp","")); - if (Doclava.USE_UPDATED_TEMPLATES) { - appendMetaNodeByLang(pageMeta, tagList); - } else { - appendMetaNodeByType(pageMeta, tagList); - } + appendMetaNodeByType(pageMeta, tagList); } } @@ -363,9 +323,7 @@ public class PageMetadata { StringBuilder outString = new StringBuilder(); String tagList = hdf.getValue(tag, ""); tagList.replaceAll("\"", ""); - if ("".equals(tagList)) { - return tagList; - } else { + if (!tagList.isEmpty()) { int end = tagList.indexOf(","); if (end != -1) { tagList = tagList.substring(0,end); @@ -375,8 +333,8 @@ public class PageMetadata { tagList = tagList.toLowerCase(); } outString.append(tagList.trim()); - return outString.toString(); - } + } + return outString.toString(); } /** @@ -412,24 +370,19 @@ public class PageMetadata { * @param filename A path string to the file relative to root. * @return A normalized lang value. */ - public static String getLangStringNormalized(Data data, String filename) { - String[] stripStr = filename.toLowerCase().split("\\/", 3); + public static String getLangStringNormalized(String filename) { + String[] stripStr = filename.toLowerCase().split("\\/"); String outFrag = "en"; - String pathCanonical = filename; if (stripStr.length > 0) { for (String t : DocFile.DEVSITE_VALID_LANGS) { if ("intl".equals(stripStr[0])) { if (t.equals(stripStr[1])) { outFrag = stripStr[1]; - //extract the root url (exclusive of intl/nn) - pathCanonical = stripStr[2]; break; } } } } - //extract the root url (exclusive of intl/nn) - data.setValue("path.canonical", pathCanonical); return outFrag; } @@ -535,37 +488,6 @@ public class PageMetadata { * @param rootList The current list of root nodes. * @return The updated list of root nodes. */ - public static List<Node> appendMetaNodeByLang(Node gNode, List<Node> rootList) { - - String nodeLang = gNode.getLang(); - boolean matched = false; - for (Node n : rootList) { - if (n.getLang().equals(nodeLang)) { //find any matching lang node - appendMetaNodeByType(gNode,n.getChildren()); - //n.getChildren().add(gNode); - matched = true; - break; // add to the first root node only - } // tag did not match - } // end rootnodes matching iterator - if (!matched) { - List<Node> mlangList = new ArrayList<Node>(); // list of file objects that have a given lang - //mlangList.add(gNode); - Node tnode = new Node.Builder().setChildren(mlangList).setLang(nodeLang).build(); - rootList.add(tnode); - appendMetaNodeByType(gNode, mlangList); - } - return rootList; - } - - /** - * Given a metadata node, add it as a child of a root node based on its - * type. If there is no root node that matches the node's type, create one - * and add the metadata node as a child node. - * - * @param gNode The node to attach to a root node or add as a new root node. - * @param rootList The current list of root nodes. - * @return The updated list of root nodes. - */ public static List<Node> appendMetaNodeByType(Node gNode, List<Node> rootList) { String nodeTags = gNode.getType(); @@ -621,28 +543,6 @@ public class PageMetadata { return rootTagNodesList; } - /** - * Append the contents of jd_extras to jd_lists_unified for each language. - * - * @param extrasFilename The lang-specific extras file to append. - * @param unifiedFilename The lang-specific unified metadata file. - */ - public static void appendExtrasMetadata (String extrasFilename, String unifiedFilename) { - File f = new File(ClearPage.outputDir + "/" + extrasFilename); - if (f.exists() && !f.isDirectory()) { - ClearPage.copyFile(true, f, unifiedFilename, true); - try { - if (f.delete()) { - if (Doclava.META_DBG) System.out.println(" >>>>> Delete succeeded"); - } else { - if (Doclava.META_DBG) System.out.println(" >>>>> Delete failed"); - } - } catch (Exception e) { - if (Doclava.META_DBG) System.out.println(" >>>>> Exception: " + e + "\n"); - } - } - } - public static final Comparator<Node> BY_TAG_NAME = new Comparator<Node>() { public int compare (Node one, Node other) { return one.getLabel().compareTo(other.getLabel()); @@ -655,19 +555,13 @@ public class PageMetadata { } }; - public static final Comparator<Node> BY_LANG_NAME = new Comparator<Node>() { - public int compare (Node one, Node other) { - return one.getLang().compareTo(other.getLang()); - } - }; - /** * A node for storing page metadata. Use Builder.build() to instantiate. */ public static class Node { private String mLabel; // holds page.title or similar identifier - private String mCategory; // subtabs, example 'training' 'guides' + private String mTitleFriendly; // title for card or similar use private String mSummary; // Summary for card or similar use private String mLink; //link href for item click private String mGroup; // from sample.group in _index.jd @@ -676,12 +570,11 @@ public class PageMetadata { private String mImage; // holds an href, fully qualified or relative to root private List<Node> mChildren; private String mLang; - private String mType; // design, develop, distribute, youtube, blog, etc - private String mTimestamp; // optional timestamp eg 1447452827 + private String mType; // can be file, dir, video show, announcement, etc. private Node(Builder builder) { mLabel = builder.mLabel; - mCategory = builder.mCategory; + mTitleFriendly = builder.mTitleFriendly; mSummary = builder.mSummary; mLink = builder.mLink; mGroup = builder.mGroup; @@ -691,17 +584,16 @@ public class PageMetadata { mChildren = builder.mChildren; mLang = builder.mLang; mType = builder.mType; - mTimestamp = builder.mTimestamp; } private static class Builder { - private String mLabel, mCategory, mSummary, mLink, mGroup, mImage, mLang, mType, mTimestamp; + private String mLabel, mTitleFriendly, mSummary, mLink, mGroup, mImage, mLang, mType; private List<String> mKeywords = null; private List<String> mTags = null; private List<Node> mChildren = null; public Builder setLabel(String mLabel) { this.mLabel = mLabel; return this;} - public Builder setCategory(String mCategory) { - this.mCategory = mCategory; return this; + public Builder setTitleFriendly(String mTitleFriendly) { + this.mTitleFriendly = mTitleFriendly; return this; } public Builder setSummary(String mSummary) {this.mSummary = mSummary; return this;} public Builder setLink(String mLink) {this.mLink = mLink; return this;} @@ -714,7 +606,6 @@ public class PageMetadata { public Builder setChildren(List<Node> mChildren) {this.mChildren = mChildren; return this;} public Builder setLang(String mLang) {this.mLang = mLang; return this;} public Builder setType(String mType) {this.mType = mType; return this;} - public Builder setTimestamp(String mTimestamp) {this.mTimestamp = mTimestamp; return this;} public Node build() {return new Node(this);} } @@ -735,24 +626,6 @@ public class PageMetadata { } } } - - /** - * Render a tree of metadata nodes organized by lang. - * @param buf Output buffer to render to. - */ - void renderLangResources(StringBuilder buf, String langname) { - List<Node> list = mChildren; //list of type rootnodes - if (list == null || list.size() == 0) { - buf.append("null"); - } else { - final int n = list.size(); - for (int i = 0; i < n; i++) { - buf.append("METADATA['" + langname + "']." + list.get(i).mType + " = ["); - list.get(i).renderTypes(buf); //render this lang's children - buf.append("\n];\n\n"); - } - } - } /** * Render all metadata nodes for a specific type. * @param buf Output buffer to render to. @@ -765,33 +638,16 @@ public class PageMetadata { final int n = list.size(); for (int i = 0; i < n; i++) { buf.append("\n {\n"); - buf.append(" \"title\":\""); - renderStrWithUcs(buf, list.get(i).mLabel); - buf.append("\",\n" ); - buf.append(" \"summary\":\""); - renderStrWithUcs(buf, list.get(i).mSummary); - buf.append("\",\n" ); + buf.append(" \"title\":\"" + list.get(i).mLabel + "\",\n" ); + buf.append(" \"titleFriendly\":\"" + list.get(i).mTitleFriendly + "\",\n" ); + buf.append(" \"summary\":\"" + list.get(i).mSummary + "\",\n" ); buf.append(" \"url\":\"" + list.get(i).mLink + "\",\n" ); - if (!"".equals(list.get(i).mImage)) { - buf.append(" \"image\":\"" + list.get(i).mImage + "\",\n" ); - } - if (!"".equals(list.get(i).mGroup)) { - buf.append(" \"group\":\""); - renderStrWithUcs(buf, list.get(i).mGroup); - buf.append("\",\n" ); - } - if (!"".equals(list.get(i).mCategory)) { - buf.append(" \"category\":\"" + list.get(i).mCategory + "\",\n" ); - } - if ((list.get(i).mType != null) && (list.get(i).mType != "")) { - buf.append(" \"type\":\"" + list.get(i).mType + "\",\n"); - } + buf.append(" \"group\":\"" + list.get(i).mGroup + "\",\n" ); list.get(i).renderArrayType(buf, list.get(i).mKeywords, "keywords"); list.get(i).renderArrayType(buf, list.get(i).mTags, "tags"); - if (!"".equals(list.get(i).mTimestamp)) { - buf.append(" \"timestamp\":\"" + list.get(i).mTimestamp + "\",\n"); - } - buf.append(" \"lang\":\"" + list.get(i).mLang + "\"" ); + buf.append(" \"image\":\"" + list.get(i).mImage + "\",\n" ); + buf.append(" \"lang\":\"" + list.get(i).mLang + "\",\n" ); + buf.append(" \"type\":\"" + list.get(i).mType + "\""); buf.append("\n }"); if (i != n - 1) { buf.append(", "); @@ -866,7 +722,22 @@ public class PageMetadata { final int n = list.size(); for (int i = 0; i < n; i++) { String tagval = list.get(i).toString(); - renderStrWithUcs(buf,tagval); + final int L = tagval.length(); + for (int t = 0; t < L; t++) { + char c = tagval.charAt(t); + if (c >= Character.MIN_HIGH_SURROGATE && c <= Character.MAX_HIGH_SURROGATE ) { + // we have a UTF-16 multi-byte character + int codePoint = tagval.codePointAt(t); + int charSize = Character.charCount(codePoint); + t += charSize - 1; + buf.append(String.format("\\u%04x",codePoint)); + } else if (c >= ' ' && c <= '~' && c != '\\') { + buf.append(c); + } else { + // we are encoding a two byte character + buf.append(String.format("\\u%04x", (int) c)); + } + } if (i != n - 1) { buf.append(","); } @@ -874,31 +745,6 @@ public class PageMetadata { } } - /** - * Render a string that can include ucs2 encoded characters. - * @param buf Output buffer to render to. - * @param chars String to append to buf with any necessary encoding - */ - void renderStrWithUcs(StringBuilder buf, String chars) { - String strval = chars; - final int L = strval.length(); - for (int t = 0; t < L; t++) { - char c = strval.charAt(t); - if (c >= Character.MIN_HIGH_SURROGATE && c <= Character.MAX_HIGH_SURROGATE ) { - // we have a UTF-16 multi-byte character - int codePoint = strval.codePointAt(t); - int charSize = Character.charCount(codePoint); - t += charSize - 1; - buf.append(String.format("\\u%04x",codePoint)); - } else if (c >= ' ' && c <= '~' && c != '\\') { - buf.append(c); - } else { - // we are encoding a two byte character - buf.append(String.format("\\u%04x", (int) c)); - } - } - } - public String getLabel() { return mLabel; } @@ -907,12 +753,12 @@ public class PageMetadata { mLabel = label; } - public String getCategory() { - return mCategory; + public String getTitleFriendly() { + return mTitleFriendly; } - public void setCategory(String title) { - mCategory = title; + public void setTitleFriendly(String title) { + mTitleFriendly = title; } public String getSummary() { @@ -1003,16 +849,8 @@ public class PageMetadata { return mType; } - public String getTimestamp() { - return mTimestamp; - } - public void setType(String type) { mType = type; } - - public void setTimestamp(String timestamp) { - mTimestamp = timestamp; - } } } diff --git a/src/com/google/doclava/ParamTagInfo.java b/src/com/google/doclava/ParamTagInfo.java index d9353c5..13eb30b 100644 --- a/src/com/google/doclava/ParamTagInfo.java +++ b/src/com/google/doclava/ParamTagInfo.java @@ -75,7 +75,6 @@ public class ParamTagInfo extends ParsedTagInfo { @Override public void makeHDF(Data data, String base) { data.setValue(base + ".name", parameterName()); - data.setValue(base + ".kind", kind()); data.setValue(base + ".isTypeParameter", isTypeParameter() ? "1" : "0"); TagInfo.makeHDF(data, base + ".comment", commentTags()); } diff --git a/src/com/google/doclava/SampleCode.java b/src/com/google/doclava/SampleCode.java index a16fd09..57f1c54 100644 --- a/src/com/google/doclava/SampleCode.java +++ b/src/com/google/doclava/SampleCode.java @@ -206,7 +206,7 @@ public class SampleCode { if (inList(path, IMAGES)) { type = "img"; if (f.length() < MAX_FILE_SIZE_BYTES) { - ClearPage.copyFile(false, f, path, false); + ClearPage.copyFile(false, f, path); writeImageVideoPage(f, convertExtension(path, Doclava.htmlExtension), relative, type, true); } else { @@ -220,7 +220,7 @@ public class SampleCode { } else if (inList(path, VIDEOS)) { type = "video"; if (f.length() < MAX_FILE_SIZE_BYTES) { - ClearPage.copyFile(false, f, path, false); + ClearPage.copyFile(false, f, path); writeImageVideoPage(f, convertExtension(path, Doclava.htmlExtension), relative, type, true); } else { |