RFR: 8345555: Improve layout of search results [v10]

Hannes Wallnöfer hannesw at openjdk.org
Fri Mar 14 13:46:09 UTC 2025


> Please review an enhancement to JavaDoc search to provide more context and a nicer layout for search results. This adds a new "kind" field to the search index to describes search items, such as "Static method", "Interface, or "System property" etc. Additionally, the drop-down search box uses a new two-column layout for search results to display this information. Previously we always displayed fully qualified names and signatures, now we mostly display simple names except if the user entered a qualified search term. 
> 
> The screenshot below shows an example of the new layout, you can of course [test the feature yourself](https://cr.openjdk.org/~hannesw/8345555/api.03/) (top-level files only). Note that the change affects moslty the drop-down search menu, the standalone search page was slightly updated to work with the new data but is otherwise unchanged.
> 
> <img width="659" alt="Screenshot 2025-02-17 at 14 56 52" src="https://github.com/user-attachments/assets/fb88a839-d3f8-4a27-957a-f1158b3ecff8" />
> 
> On the Java side, the feature is implemented by adding a new `IndexItem.Kind` enum class listing all possible kinds of index items, which include API `Element`s, JavaDoc tags and summary pages. The purpose if this enum is to send its `ordinal`s to the browser via JSON where it is used as array index into an array of localized messages. This means that the Java enum and JavaScript array have to be kept in sync manually, but it's relatively rare that new language elements or JavaDoc tags get added so that shouldn't be a problem.
> 
> There is a small change in JavaDoc HTML output because "System property" and "External specification" are now kinds of tags and no longer used as descriptions. On index pages they are now listed as "System property in package foo" rather than "Search tag in package foo" with the description "System Tag" added in the next line. 
> 
> Only actual `{@index}` tags can now have a description, which continues to be added as second line in index pages. In search, the description is now appended to the search term separated by "-", which makes it more visible and allows it to be searched for: https://cr.openjdk.org/~hannesw/8345555/api.02/search.html?q=tool&c=searchTags
> 
> On the JavaScript side, changes went a bit further than originally planned. I finally fixed the format of constructors not to show the class name twice, which required some retuning of ranking of search results. I used this occasion to add lots of comments to the code so it will be eas...

Hannes Wallnöfer has updated the pull request incrementally with two additional commits since the last revision:

 - Add bug id to more tests
 - Update copyright years
   
   Note: any commit hashes below might be outdated due to subsequent
   history rewriting (e.g. git rebase).
   
    + update src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java due to 973bf1362eb
    + update src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexWriter.java due to 65de882c21a
    + update src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/SpecTaglet.java due to 973bf1362eb
    + update src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/SystemPropertyTaglet.java due to 973bf1362eb
    + update src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/taglets/TagletWriter.java due to 973bf1362eb
    + update src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlAttr.java due to 008c331d854
    + update src/jdk.javadoc/share/classes/jdk/javadoc/internal/html/HtmlTag.java due to 008c331d854
    + update test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java due to 973bf1362eb
    + update test/langtools/jdk/javadoc/doclet/testIndexInDocFiles/TestIndexInDocFiles.java due to 973bf1362eb
    + update test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java due to 973bf1362eb
    + update test/langtools/jdk/javadoc/doclet/testModules/TestModulePackages.java due to 973bf1362eb
    + update test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java due to 973bf1362eb

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/23666/files
  - new: https://git.openjdk.org/jdk/pull/23666/files/2a2e04f1..e95acda7

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=23666&range=09
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=23666&range=08-09

  Stats: 16 lines in 14 files changed: 0 ins; 0 del; 16 mod
  Patch: https://git.openjdk.org/jdk/pull/23666.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23666/head:pull/23666

PR: https://git.openjdk.org/jdk/pull/23666


More information about the javadoc-dev mailing list