docfx icon indicating copy to clipboard operation
docfx copied to clipboard

feat!: search improvements

Open frarees opened this issue 7 months ago • 0 comments

Motivation

DocFX's current state of the search functionality has some flaws:

  • Searching through APIs can yield no results unless you type the complete symbol name
    • For example, if I have a page ManagedReferenceExample and I search for Managed I will get no results. Same goes for ManagedReference
    • This is specially important for API pages, since one of the reasons users want to use the search functionality is because they've forgotten the full name of a member
  • Searching multiple terms doesn't narrow the search, but the opposite
  • When I finish inputting my search query, I press Enter instinctively, which clears the search and reloads the page

What has changed

  • New global metadata keys _searchIndexUseMetadata and _searchIndexUseMetadataTitle to opt-in
  • New build step for MREFs: FillMetadata
    • Stores Title and Summary in ManifestProperties
  • Search Index
    • Includes new property summary
    • Entries for MREFs can be loaded from metadata instead of HTML scrapping
  • SearchIndexItem.Keywords holds different content for MREFs
    • Parses through the symbol's full name and creates permutations of the words found
      • ManagedReferenceExample -> Managed ManagedReference ManagedReferenceExample ManagedExample Reference ReferenceExample Example
    • Keywords is still present and it's used to store exclusively for keywords, and processed by the search engine
    • Summary is rendered by the themes (brief)
  • Modern theme
    • Don't allow Enter/Submit on search
    • Search is additive: searching multiple terms uses AND instead of OR

Notes / TODO

  • The regex used to create keywords, while accounting for most cases, is not perfect
  • Default theme could use similar changes to modern theme, so UX is similar

frarees avatar Jul 15 '24 09:07 frarees